@xopcai/xopc 0.0.129 → 0.0.131
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/icons/icon-128.png +0 -0
- package/dist/browser-ext/icons/icon-16.png +0 -0
- package/dist/browser-ext/icons/icon-32.png +0 -0
- package/dist/browser-ext/icons/icon-48.png +0 -0
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/apple-touch-icon.png +0 -0
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DHzfg5D-.js → agent-avatar-dicebear-BJYeTxQ9.js} +1 -1
- package/dist/gateway/static/root/assets/agents-kVsY4Iz_.js +2 -0
- package/dist/gateway/static/root/assets/app-management-settings-panel-Bj8iJ-7d.js +1 -0
- package/dist/gateway/static/root/assets/{appearance-settings-bYeEj3IW.js → appearance-settings-6TjISbHB.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-DC4YwXLL.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-Dy6lsTHw.js → archive-plugin-2G62raBg.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-qOtBYR6Y.js → attachment-load-kLNJMEJh.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-BFH-RfaV.js → automation-suggestion-card-CpcZSSD8.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-MZ8m4bYP.js +4 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DJvi_thc.js → binary-plugins-C_zSrWow.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DlMnizlt.js → block-editor-D_PMrT-l.js} +4 -4
- package/dist/gateway/static/root/assets/browser-settings-page-C89wKfPd.js +8 -0
- package/dist/gateway/static/root/assets/capability-presets-api-CPFtajl7.js +1 -0
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-Dng8Grpv.js → capability-presets-settings-panel-DWw31-4v.js} +1 -1
- package/dist/gateway/static/root/assets/channel-recipient-api-BUi8syv2.js +1 -0
- package/dist/gateway/static/root/assets/channels-settings-DOYzcMAE.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-DCE-PgQF.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-BYV16wez.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-B-u63N4e.js → desktop-pet-settings-DGIaFqPR.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-8p1ehIHn.js → directory-picker-path-field-BEhDuShd.js} +1 -1
- package/dist/gateway/static/root/assets/dreaming-settings-BIkgLFDH.js +3 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DJ1ABK95.js → extension-debug-page-BIjLZMAQ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CP9P2lGM.js → extension-page-Cxv4Bgj5.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-DNd0tRFl.js +1 -0
- package/dist/gateway/static/root/assets/fetch-Bl7zMnmd.js +1 -0
- package/dist/gateway/static/root/assets/gateway-config-api-BiqKIkkp.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-D_Cvasqi.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CY5W2Pp4.js → gateway-startup-retry-CPOgTcpv.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-create-dialog-2lPbGfp3.js → goal-create-dialog-DZ68qzpm.js} +1 -1
- package/dist/gateway/static/root/assets/goal-detail-page-DF8QhTHH.js +4 -0
- package/dist/gateway/static/root/assets/goals-config-api-h26_-2Vm.js +1 -0
- package/dist/gateway/static/root/assets/goals-page-BzBKHZJg.js +2 -0
- package/dist/gateway/static/root/assets/goals-settings-BFG1uTI8.js +1 -0
- package/dist/gateway/static/root/assets/heartbeat-settings-5vV8vTva.js +1 -0
- package/dist/gateway/static/root/assets/index-DOetFpTt.js +262 -0
- package/dist/gateway/static/root/assets/index-W4ogAiHt.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BrENZzM7.js → keyboard-shortcuts-settings-Dpx1ovO6.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-3QO3elfx.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-BYF4ReGM.js → markdown-split-Ba4EsPkV.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CpQDz-QJ.js → media-plugins-lA5rvtCq.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-YzjnURPJ.js → messages-Bq4REfIj.js} +2 -2
- package/dist/gateway/static/root/assets/models-hub-panel-BBG87CHZ.js +2 -0
- package/dist/gateway/static/root/assets/notes-page-DrUGE-Hn.js +1 -0
- package/dist/gateway/static/root/assets/notes-workbench-eAIE8iKV.js +2 -0
- package/dist/gateway/static/root/assets/{page-tabs-RnYYOIWO.js → page-tabs-Cy7bX7Ce.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CTRt06Ri.js → preview-open-alternatives-B9_iql49.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-Cwct6pCV.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BXZlzV8t.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-C29EWM0P.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-c4pZeikq.js → save-bar-controls-nMloZ0mp.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-Cb6R7iuP.js → schedule-field-BuajpVNF.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-BqET_hEP.js → schema-form-IeXV_yQk.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-DHHVDqsy.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-hDvmobsT.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-DuOvqNsI.js → settings-collapsible-section-ByixWwvu.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-DptSsbWd.js → settings-form-section-C-5-n-jM.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-BlVfBCb9.js → settings-loading-skeleton-CTA5Gje4.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-DzqxeemF.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-layout-DVt69dJJ.js → settings-page-layout-DgFTf6nM.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-svpHcJ62.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-IOjU69FC.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-Ddg8gHPN.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-DcNOEJsK.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DoonnYRs.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-CW22OkZ4.js → system-settings-panel-BMDD7FXg.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-BqpGAKxV.js → typed-models-lib-DayamJ56.js} +1 -1
- package/dist/gateway/static/root/assets/use-channel-catalog-ChYwFiqo.js +1 -0
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-CERVLuaW.js → user-profile-settings-panel-Dd0X3mPv.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-BnmysurA.js → utils-D9v9ZpK4.js} +1 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-QXGvjTwa.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-CP-5OUYI.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Ci9GSPnS.js → workflow-run-setup-panel-IidqhbUI.js} +2 -2
- package/dist/gateway/static/root/assets/{workflow-start-dialog-BhDj8pqH.js → workflow-start-dialog-BQQkr8YD.js} +1 -1
- package/dist/gateway/static/root/assets/workflows-page-DtVIjVSX.js +18 -0
- package/dist/gateway/static/root/favicon-16x16.png +0 -0
- package/dist/gateway/static/root/favicon-32x32.png +0 -0
- package/dist/gateway/static/root/favicon-icon.svg +23 -1
- package/dist/gateway/static/root/favicon.ico +0 -0
- package/dist/gateway/static/root/favicon.png +0 -0
- package/dist/gateway/static/root/favicon.svg +20 -24
- package/dist/gateway/static/root/index.html +11 -11
- package/dist/gateway/static/root/logo-dark.svg +18 -23
- package/dist/gateway/static/root/logo.svg +18 -24
- package/dist/gateway/static/root/pwa-192x192.png +0 -0
- package/dist/gateway/static/root/pwa-512x512.png +0 -0
- package/dist/gateway/static/root/site.webmanifest +23 -0
- package/dist/package.js +1 -1
- package/dist/src/cli/commands/gateway/probe.js +6 -6
- package/dist/src/cli/commands/gateway/probe.js.map +1 -1
- package/dist/src/cli/commands/onboard.js +2 -2
- package/dist/src/cli/commands/onboard.js.map +1 -1
- package/dist/src/cli/commands/tui.js +11 -4
- package/dist/src/cli/commands/tui.js.map +1 -1
- package/dist/src/cli/utils/gateway-client-options.d.ts +3 -0
- package/dist/src/cli/utils/gateway-client-options.js +2 -1
- package/dist/src/cli/utils/gateway-client-options.js.map +1 -1
- package/dist/src/cli/utils/gateway-client.d.ts +6 -3
- package/dist/src/cli/utils/gateway-client.js +14 -8
- package/dist/src/cli/utils/gateway-client.js.map +1 -1
- package/dist/src/gateway/credential.d.ts +9 -0
- package/dist/src/gateway/credential.js +16 -0
- package/dist/src/gateway/credential.js.map +1 -0
- package/dist/src/gateway/hono/app.d.ts +0 -1
- package/dist/src/gateway/hono/app.js +2 -9
- package/dist/src/gateway/hono/app.js.map +1 -1
- package/dist/src/gateway/hono/middleware/auth.d.ts +0 -2
- package/dist/src/gateway/hono/middleware/auth.js +46 -21
- package/dist/src/gateway/hono/middleware/auth.js.map +1 -1
- package/dist/src/gateway/hono/routes/sessions.js +2 -27
- package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
- package/dist/src/gateway/server.js +1 -5
- package/dist/src/gateway/server.js.map +1 -1
- package/dist/src/mcp/channel-bridge.d.ts +2 -1
- package/dist/src/mcp/channel-bridge.js +10 -6
- package/dist/src/mcp/channel-bridge.js.map +1 -1
- package/dist/src/mcp/channel-server.d.ts +2 -1
- package/dist/src/mcp/channel-server.js +1 -1
- package/dist/src/mcp/channel-server.js.map +1 -1
- package/dist/src/mcp/gateway-http-client.d.ts +3 -2
- package/dist/src/mcp/gateway-http-client.js +9 -7
- package/dist/src/mcp/gateway-http-client.js.map +1 -1
- package/dist/src/tui/backends/gateway-sse-backend.d.ts +3 -2
- package/dist/src/tui/backends/gateway-sse-backend.js +45 -41
- package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
- package/dist/src/tui/tui-types.d.ts +3 -2
- package/dist/src/tui/tui-types.js.map +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/tui/tui.js.map +1 -1
- package/package.json +5 -2
- package/dist/gateway/static/root/assets/agents-CMxKKFQD.js +0 -2
- package/dist/gateway/static/root/assets/app-management-settings-panel-ptk9c5BN.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-DdZvDf5B.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-B8JTjkCr.js +0 -4
- package/dist/gateway/static/root/assets/browser-settings-page-slHLiZgi.js +0 -8
- package/dist/gateway/static/root/assets/capability-presets-api-D4q7vHVJ.js +0 -1
- package/dist/gateway/static/root/assets/channel-recipient-api-BrW5Kcgc.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-KIsISXw0.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-C5fx4Qs9.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-Jmdn6q47.js +0 -1
- package/dist/gateway/static/root/assets/dreaming-settings-CCkKP-I4.js +0 -3
- package/dist/gateway/static/root/assets/extension-settings-page-DnhU-tx0.js +0 -1
- package/dist/gateway/static/root/assets/fetch-BMjlW0g1.js +0 -1
- package/dist/gateway/static/root/assets/gateway-config-api-CjxDn46s.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-TING7224.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-DHWVRafk.js +0 -4
- package/dist/gateway/static/root/assets/goals-config-api-BqhuxG8P.js +0 -1
- package/dist/gateway/static/root/assets/goals-page-CMk-9ZYN.js +0 -2
- package/dist/gateway/static/root/assets/goals-settings-BHzOAU_l.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-BQIm0P3V.js +0 -1
- package/dist/gateway/static/root/assets/index-C4k6QSXw.js +0 -257
- package/dist/gateway/static/root/assets/index-EKmpPvZj.css +0 -1
- package/dist/gateway/static/root/assets/logs-page-BiL302Ve.js +0 -2
- package/dist/gateway/static/root/assets/models-hub-panel-CFPpl3Cq.js +0 -2
- package/dist/gateway/static/root/assets/notes-page-BurgcdVZ.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-BAELRM_O.js +0 -2
- package/dist/gateway/static/root/assets/project-detail-page-iXX1Ceo2.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-GDVTFAY7.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BUrbUnwv.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-CiOreA2k.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-C-qvptlu.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-xQx2Pkg5.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DWB8VdLK.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-8m_ACH0z.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-CgxfhNxI.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BBFUOxmf.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-bo695odu.js +0 -2
- package/dist/gateway/static/root/assets/url-DFGNSBNT.js +0 -1
- package/dist/gateway/static/root/assets/use-channel-catalog-CPdJ0o0i.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-Jr3jvPcB.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-B-8rex4u.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-Brb3UGvs.js +0 -18
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-YzjnURPJ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{a as s,t as c}from"./fetch-BMjlW0g1.js";import{$i as l,Ac as u,As as d,Ba as f,Cl as p,Dl as m,Do as h,Ds as g,El as _,Es as v,Fc as y,Ga as b,Gi as x,Go as S,Ha as C,Hi as w,Ka as T,Ki as E,L as D,Mc as O,Oo as k,Qc as A,Qi as j,Ss as M,St as N,Tc as P,Ua as F,Ui as I,Va as ee,Vc as L,Vo as R,Vr as z,Vs as B,Wa as te,Wi as ne,Xi as V,Yi as re,Zi as ie,Zo as ae,Zs as oe,_a as se,_i as ce,_l as le,_o as ue,_t as de,a as H,aa as fe,bc as U,bi as pe,bl as me,bn as he,d as ge,da as _e,dc as ve,di as ye,do as be,ea as xe,el as Se,f as Ce,fi as we,fo as Te,gi as Ee,gt as De,hi as Oe,hs as ke,i as Ae,ia as je,il as Me,io as Ne,js as Pe,kc as Fe,ko as Ie,l as W,lo as Le,lt as Re,ma as ze,mi as Be,na as Ve,nc as He,no as Ue,nr as We,o as Ge,oa as Ke,os as qe,p as Je,pi as Ye,ps as Xe,qa as Ze,qi as Qe,r as $e,ra as et,rl as tt,s as nt,sa as rt,st as it,u as at,ua as ot,ui as st,uo as ct,us as lt,vi as ut,wc as dt,ws as ft,xc as pt,y as mt,yi as ht,yn as gt,yt as _t}from"./index-C4k6QSXw.js";import{t as vt}from"./notes-workbench-BAELRM_O.js";import{t as yt}from"./page-tabs-RnYYOIWO.js";import{t as bt}from"./directory-picker-path-field-8p1ehIHn.js";import{t as xt}from"./goals-config-api-BqhuxG8P.js";import{n as St,t as Ct}from"./goal-create-dialog-2lPbGfp3.js";import{t as wt}from"./workflow-start-dialog-BhDj8pqH.js";var G=n(),K=e(t(),1),q=r(),Tt=`application/x-xopc-work-item`,Et=[`backlog`,`todo`,`in_progress`,`blocked`,`needs_input`,`in_review`,`done`],Dt=[`low`,`normal`,`high`,`urgent`];function Ot(e){return e===`done`||e===`in_review`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`blocked`||e===`needs_input`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`in_progress`?`bg-accent-soft text-accent-fg`:e===`backlog`||e===`todo`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-muted text-fg-subtle`}function kt(e){return e?new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e)):``}function At(e){return!Number.isFinite(e)||e<=0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(+(e<10*1024))} KB`:`${(e/(1024*1024)).toFixed(+(e<10*1024*1024))} MB`}function J(e){return`${e.name}:${e.size}:${e.lastModified}`}function jt(e,t){return st(e,t)!==`unsupported`}function Mt(e,t){return e.startsWith(`image/`)?`image`:e.startsWith(`audio/`)?`audio`:t===`image`||t===`audio`||t===`video`?t:`document`}function Nt(e,t){return{id:e.id,name:e.fileName,type:Mt(e.mimeType,e.type),mimeType:e.mimeType,size:e.size,...t?{content:t,preview:e.mimeType.startsWith(`image/`)?t:void 0}:{}}}async function Pt(e,t){let n=we(e.name||`upload`,e.type||`application/octet-stream`),r=ot(await e.arrayBuffer());return{id:t,name:e.name||`upload`,type:Mt(n),mimeType:n,size:e.size,content:r,preview:n.startsWith(`image/`)?r:void 0}}function Ft(e){let t=(0,G.c)(3),[n,r]=(0,K.useState)(``),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e){r(``);return}let t=URL.createObjectURL(e);return r(t),()=>URL.revokeObjectURL(t)},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,K.useEffect)(i,a),n}function It(e,t){let n=(0,G.c)(5),[r,i]=(0,K.useState)(``),a,o;return n[0]!==t.id||n[1]!==t.mimeType||n[2]!==e?(a=()=>{if(!e||!t.mimeType.startsWith(`image/`)){i(``);return}let n=!1,r=``;return(async()=>{let a=await c(Je(e,t.id));if(!a.ok||n)return;let o=await a.blob();n||(r=URL.createObjectURL(o),i(r))})().catch(()=>{n||i(``)}),()=>{n=!0,r&&URL.revokeObjectURL(r)}},o=[t.id,t.mimeType,e],n[0]=t.id,n[1]=t.mimeType,n[2]=e,n[3]=a,n[4]=o):(a=n[3],o=n[4]),(0,K.useEffect)(a,o),r}function Lt(e){let t=(0,G.c)(11),{name:n,mimeType:r,thumbnailUrl:i,previewable:a,disabled:o,onOpen:s}=e,c;t[0]===r?c=t[1]:(c=r.startsWith(`image/`),t[0]=r,t[1]=c);let l=c,u;t[2]!==l||t[3]!==n||t[4]!==i?(u=l&&i?(0,q.jsx)(`img`,{src:i,alt:n,className:`size-10 rounded-md object-cover`}):(0,q.jsx)(`span`,{className:`inline-flex size-10 items-center justify-center rounded-md border border-edge bg-surface-muted`,children:(0,q.jsx)(P,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),t[2]=l,t[3]=n,t[4]=i,t[5]=u):u=t[5];let d=u;if(!a)return d;let f;return t[6]!==d||t[7]!==o||t[8]!==n||t[9]!==s?(f=(0,q.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel disabled:cursor-wait disabled:opacity-70`,title:n,"aria-label":n,disabled:o,onClick:s,children:d}),t[6]=d,t[7]=o,t[8]=n,t[9]=s,t[10]=f):f=t[10],f}function Rt(e){return e.kind===`chat`?`/chat/${encodeURIComponent(e.targetId)}`:e.kind===`goal`?`/goals/${encodeURIComponent(e.targetId)}`:e.kind===`workflow_run`?`/workflows?run=${encodeURIComponent(e.targetId)}`:e.kind===`automation`?`/automations?automationId=${encodeURIComponent(e.targetId)}`:`#`}function zt(e){return e instanceof Element?!!e.closest(`a,button,input,select,textarea,[contenteditable="true"],[draggable="true"],[data-board-pan-skip="true"]`):!0}function Bt(e,t){return e.nextAction||e.blockedReason||e.description||t.noNextAction}function Vt(e){let t=(0,G.c)(63),{item:n,dragging:r,onOpen:a,onToggleDone:o,onDragStart:s,onDragEnd:c,t:l}=e,u=n.status===`done`,d;t[0]!==n||t[1]!==s?(d=e=>s(n,e),t[0]=n,t[1]=s,t[2]=d):d=t[2];let f=l.dragToUpdate,m=r&&`opacity-50`,h;t[3]===m?h=t[4]:(h=i(`flex min-h-24 w-full min-w-0 max-w-full cursor-grab flex-col overflow-hidden rounded-lg bg-surface-panel px-3 py-3 shadow-surface transition-colors hover:bg-surface-hover active:cursor-grabbing`,m),t[3]=m,t[4]=h);let g=u?`border-success bg-success text-white`:`border-edge bg-surface-base hover:border-accent/50`,_;t[5]===g?_=t[6]:(_=i(`mt-0.5 inline-flex size-3.5 shrink-0 items-center justify-center rounded border transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,g),t[5]=g,t[6]=_);let v=u?l.markTodo:l.markDone,y=u?l.markTodo:l.markDone,b;t[7]!==n||t[8]!==o?(b=()=>o(n),t[7]=n,t[8]=o,t[9]=b):b=t[9];let x;t[10]===u?x=t[11]:(x=u?(0,q.jsx)(A,{className:`size-3`,"aria-hidden":!0}):null,t[10]=u,t[11]=x);let S;t[12]!==x||t[13]!==_||t[14]!==v||t[15]!==y||t[16]!==b?(S=(0,q.jsx)(`button`,{type:`button`,className:_,"aria-label":v,title:y,onClick:b,children:x}),t[12]=x,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=S):S=t[17];let C;t[18]!==n||t[19]!==a?(C=()=>a(n),t[18]=n,t[19]=a,t[20]=C):C=t[20];let w;t[21]===n.title?w=t[22]:(w=(0,q.jsx)(`h4`,{className:`min-w-0 flex-1 basis-0 text-sm font-medium leading-5 text-fg line-clamp-2`,children:n.title}),t[21]=n.title,t[22]=w);let T;t[23]!==n||t[24]!==l?(T=Bt(n,l),t[23]=n,t[24]=l,t[25]=T):T=t[25];let E;t[26]===T?E=t[27]:(E=(0,q.jsx)(`p`,{className:`mt-2 max-w-full break-words text-xs leading-5 text-fg-muted line-clamp-1`,children:T}),t[26]=T,t[27]=E);let D;t[28]!==C||t[29]!==w||t[30]!==E?(D=(0,q.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,onClick:C,children:[w,E]}),t[28]=C,t[29]=w,t[30]=E,t[31]=D):D=t[31];let O;t[32]!==S||t[33]!==D?(O=(0,q.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-start gap-2`,children:[S,D]}),t[32]=S,t[33]=D,t[34]=O):O=t[34];let k;t[35]===n.status?k=t[36]:(k=i(`rounded-full px-2 py-0.5 text-[11px] font-medium`,Ot(n.status)),t[35]=n.status,t[36]=k);let j=l.statuses[n.status],M;t[37]!==k||t[38]!==j?(M=(0,q.jsx)(`span`,{className:k,children:j}),t[37]=k,t[38]=j,t[39]=M):M=t[39];let N=l.priorities[n.priority],P;t[40]===N?P=t[41]:(P=(0,q.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-[11px] text-fg-muted`,children:N}),t[40]=N,t[41]=P);let F;t[42]===n.attachments?F=t[43]:(F=n.attachments?.length?(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-surface-muted px-2 py-0.5 text-[11px] text-fg-muted`,children:[(0,q.jsx)(Pe,{className:`size-3`,"aria-hidden":!0}),n.attachments.length]}):null,t[42]=n.attachments,t[43]=F);let I;t[44]===n.links?I=t[45]:(I=n.links?.length?(0,q.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-[11px] text-fg-muted`,children:n.links.length}):null,t[44]=n.links,t[45]=I);let ee=`/work-items/${encodeURIComponent(n.id)}`,L;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,q.jsx)(Fe,{className:`size-3`,"aria-hidden":!0}),t[46]=L):L=t[46];let R;t[47]!==l.detail.openItem||t[48]!==ee?(R=(0,q.jsxs)(p,{to:ee,className:`ml-auto inline-flex shrink-0 items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium text-accent hover:bg-accent-soft hover:text-accent-fg`,children:[l.detail.openItem,L]}),t[47]=l.detail.openItem,t[48]=ee,t[49]=R):R=t[49];let z;t[50]!==M||t[51]!==P||t[52]!==F||t[53]!==I||t[54]!==R?(z=(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[M,P,F,I,R]}),t[50]=M,t[51]=P,t[52]=F,t[53]=I,t[54]=R,t[55]=z):z=t[55];let B;return t[56]!==c||t[57]!==l.dragToUpdate||t[58]!==d||t[59]!==O||t[60]!==z||t[61]!==h?(B=(0,q.jsxs)(`article`,{draggable:!0,onDragStart:d,onDragEnd:c,title:f,className:h,children:[O,z]}),t[56]=c,t[57]=l.dragToUpdate,t[58]=d,t[59]=O,t[60]=z,t[61]=h,t[62]=B):B=t[62],B}function Ht(){let e=(0,G.c)(3),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`size-3.5 shrink-0 rounded-full bg-surface-muted`}),(0,q.jsx)(`div`,{className:`h-3 w-36 rounded bg-surface-muted`})]}),n=(0,q.jsx)(`div`,{className:`mt-3 h-3 w-48 rounded bg-surface-muted`}),e[0]=t,e[1]=n):(t=e[0],n=e[1]);let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,q.jsxs)(`article`,{className:`flex h-24 w-full min-w-0 max-w-full flex-col overflow-hidden rounded-lg bg-surface-panel px-3 pt-3 pb-0 shadow-surface`,children:[t,n,(0,q.jsxs)(`div`,{className:`mt-3 flex gap-1.5`,children:[(0,q.jsx)(`div`,{className:`h-5 w-16 rounded-full bg-surface-muted`}),(0,q.jsx)(`div`,{className:`h-5 w-10 rounded-full bg-surface-muted`})]})]}),e[2]=r):r=e[2],r}function Ut(e){let t=(0,G.c)(44),{file:n,index:r,busy:a,previewBusy:o,t:s,onOpen:c,onRemove:l}=e,u,d,f,p;t[0]===n?(u=t[1],d=t[2],f=t[3],p=t[4]):(u=we(n.name||`upload`,n.type||`application/octet-stream`),d=jt(n.name||`upload`,u),f=Ft,p=u.startsWith(`image/`)?n:null,t[0]=n,t[1]=u,t[2]=d,t[3]=f,t[4]=p);let m=f(p),h=n.name||`upload`,g=a||o,_;t[5]!==n||t[6]!==c?(_=()=>c(n),t[5]=n,t[6]=c,t[7]=_):_=t[7];let v;t[8]!==u||t[9]!==d||t[10]!==h||t[11]!==g||t[12]!==_||t[13]!==m?(v=(0,q.jsx)(Lt,{name:h,mimeType:u,thumbnailUrl:m,previewable:d,disabled:g,onOpen:_}),t[8]=u,t[9]=d,t[10]=h,t[11]=g,t[12]=_,t[13]=m,t[14]=v):v=t[14];let y=d?`rounded-md hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`:`cursor-default`,b;t[15]===y?b=t[16]:(b=i(`min-w-0 flex-1 text-left`,y),t[15]=y,t[16]=b);let x=!d||a||o,S;t[17]!==n||t[18]!==c?(S=()=>c(n),t[17]=n,t[18]=c,t[19]=S):S=t[19];let C=n.name||`upload`,w;t[20]===C?w=t[21]:(w=(0,q.jsx)(`div`,{className:`truncate font-medium text-fg`,children:C}),t[20]=C,t[21]=w);let T;t[22]===n.size?T=t[23]:(T=At(n.size),t[22]=n.size,t[23]=T);let E;t[24]===T?E=t[25]:(E=(0,q.jsx)(`div`,{className:`text-xs text-fg-subtle`,children:T}),t[24]=T,t[25]=E);let D;t[26]!==S||t[27]!==w||t[28]!==E||t[29]!==b||t[30]!==x?(D=(0,q.jsxs)(`button`,{type:`button`,className:b,disabled:x,onClick:S,children:[w,E]}),t[26]=S,t[27]=w,t[28]=E,t[29]=b,t[30]=x,t[31]=D):D=t[31];let O;t[32]!==r||t[33]!==l?(O=()=>l(r),t[32]=r,t[33]=l,t[34]=O):O=t[34];let k;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,q.jsx)(Ie,{className:`size-3.5`,"aria-hidden":!0}),t[35]=k):k=t[35];let A;t[36]!==a||t[37]!==s.attachments.remove||t[38]!==O?(A=(0,q.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,title:s.attachments.remove,"aria-label":s.attachments.remove,disabled:a,onClick:O,children:k}),t[36]=a,t[37]=s.attachments.remove,t[38]=O,t[39]=A):A=t[39];let j;return t[40]!==D||t[41]!==A||t[42]!==v?(j=(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-panel px-2 py-2 text-sm`,children:[v,D,A]}),t[40]=D,t[41]=A,t[42]=v,t[43]=j):j=t[43],j}function Wt(e){let t=(0,G.c)(56),{item:n,attachment:r,busy:a,previewBusy:o,t:s,onOpen:c,onDownload:l,onRemove:u}=e,d;t[0]!==r.fileName||t[1]!==r.mimeType?(d=jt(r.fileName,r.mimeType),t[0]=r.fileName,t[1]=r.mimeType,t[2]=d):d=t[2];let f=d,p=It(n.id,r),m=a||o,h;t[3]!==r||t[4]!==n||t[5]!==c?(h=()=>c(n,r),t[3]=r,t[4]=n,t[5]=c,t[6]=h):h=t[6];let g;t[7]!==r.fileName||t[8]!==r.mimeType||t[9]!==f||t[10]!==m||t[11]!==h||t[12]!==p?(g=(0,q.jsx)(Lt,{name:r.fileName,mimeType:r.mimeType,thumbnailUrl:p,previewable:f,disabled:m,onOpen:h}),t[7]=r.fileName,t[8]=r.mimeType,t[9]=f,t[10]=m,t[11]=h,t[12]=p,t[13]=g):g=t[13];let _=f?`rounded-md hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`:`cursor-default`,v;t[14]===_?v=t[15]:(v=i(`min-w-0 flex-1 text-left`,_),t[14]=_,t[15]=v);let y=!f||a||o,b;t[16]!==r||t[17]!==n||t[18]!==c?(b=()=>c(n,r),t[16]=r,t[17]=n,t[18]=c,t[19]=b):b=t[19];let x;t[20]===r.fileName?x=t[21]:(x=(0,q.jsx)(`div`,{className:`truncate font-medium text-fg`,children:r.fileName}),t[20]=r.fileName,t[21]=x);let S=r.mimeType,C;t[22]===r.size?C=t[23]:(C=At(r.size),t[22]=r.size,t[23]=C);let w;t[24]!==r.mimeType||t[25]!==C?(w=(0,q.jsxs)(`div`,{className:`truncate text-xs text-fg-subtle`,children:[S,` · `,C]}),t[24]=r.mimeType,t[25]=C,t[26]=w):w=t[26];let T;t[27]!==w||t[28]!==v||t[29]!==y||t[30]!==b||t[31]!==x?(T=(0,q.jsxs)(`button`,{type:`button`,className:v,disabled:y,onClick:b,children:[x,w]}),t[27]=w,t[28]=v,t[29]=y,t[30]=b,t[31]=x,t[32]=T):T=t[32];let E;t[33]!==r||t[34]!==n||t[35]!==l?(E=()=>l(n,r),t[33]=r,t[34]=n,t[35]=l,t[36]=E):E=t[36];let D;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,q.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),t[37]=D):D=t[37];let k;t[38]!==a||t[39]!==s.attachments.download||t[40]!==E?(k=(0,q.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,title:s.attachments.download,"aria-label":s.attachments.download,disabled:a,onClick:E,children:D}),t[38]=a,t[39]=s.attachments.download,t[40]=E,t[41]=k):k=t[41];let A;t[42]!==r||t[43]!==n||t[44]!==u?(A=()=>u(n,r),t[42]=r,t[43]=n,t[44]=u,t[45]=A):A=t[45];let j;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,q.jsx)(R,{className:`size-3.5`,"aria-hidden":!0}),t[46]=j):j=t[46];let M;t[47]!==a||t[48]!==s.attachments.remove||t[49]!==A?(M=(0,q.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-danger`,title:s.attachments.remove,"aria-label":s.attachments.remove,disabled:a,onClick:A,children:j}),t[47]=a,t[48]=s.attachments.remove,t[49]=A,t[50]=M):M=t[50];let N;return t[51]!==T||t[52]!==k||t[53]!==M||t[54]!==g?(N=(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-panel px-2 py-2 text-sm`,children:[g,T,k,M]}),t[51]=T,t[52]=k,t[53]=M,t[54]=g,t[55]=N):N=t[55],N}function Gt({mode:e,item:t,pendingFiles:n,busy:r,t:a,onPendingFilesChange:o,onUpload:l,onRemove:u,onDownload:d,onPreviewError:f}){let p=(0,K.useRef)(null),[m,g]=(0,K.useState)(!1),[_,v]=(0,K.useState)(!1),[y,b]=(0,K.useState)(null),[x,S]=(0,K.useState)(null),C=s(e=>e.token),w=t?.attachments??[];function T(r){if(!r.length)return;if(e===`detail`&&t){l(t,r);return}let i=new Set(n.map(J)),a=[...n];for(let e of r){let t=J(e);i.has(t)||(i.add(t),a.push(e))}o(a)}function E(e){o(n.filter((t,n)=>n!==e))}async function D(e){let t=J(e);S(`pending:${t}`);try{b(await Pt(e,`pending:${t}`)),v(!0)}catch(e){f(e instanceof Error?e.message:String(e))}finally{S(null)}}async function O(e,t){S(`saved:${t.id}`);try{let n=await c(Je(e.id,t.id));if(!n.ok)throw Error(`HTTP ${n.status}`);b(Nt(t,ot(await n.arrayBuffer()))),v(!0)}catch(e){f(e instanceof Error?e.message:String(e))}finally{S(null)}}return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`section`,{className:i(`grid gap-3 rounded-lg border border-edge bg-surface-base p-3`,m&&`border-accent bg-accent-soft/40`),onDragOver:e=>{e.preventDefault(),g(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||g(!1)},onDrop:e=>{e.preventDefault(),g(!1),T(Array.from(e.dataTransfer.files))},children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsxs)(`h3`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,q.jsx)(Pe,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`truncate`,children:a.attachments.title})]}),(0,q.jsxs)(h,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:r,onClick:()=>p.current?.click(),children:[(0,q.jsx)(M,{className:`size-3.5`,"aria-hidden":!0}),a.attachments.add]}),(0,q.jsx)(`input`,{ref:p,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{T(Array.from(e.target.files??[])),e.currentTarget.value=``}})]}),n.length?(0,q.jsx)(`div`,{className:`grid gap-2`,children:n.map((e,t)=>(0,q.jsx)(Ut,{file:e,index:t,busy:r,previewBusy:x===`pending:${J(e)}`,t:a,onOpen:e=>void D(e),onRemove:E},J(e)))}):null,t&&w.length?(0,q.jsx)(`div`,{className:`grid gap-2`,children:w.map(e=>(0,q.jsx)(Wt,{item:t,attachment:e,busy:r,previewBusy:x===`saved:${e.id}`,t:a,onOpen:(e,t)=>void O(e,t),onDownload:d,onRemove:u},e.id))}):null,!n.length&&!w.length?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.attachments.empty}):null]}),(0,q.jsx)(it,{open:_,attachment:y,authToken:C,layerClassName:`z-[100]`,onClose:()=>{v(!1),b(null)}})]})}function Kt(e){let t=(0,G.c)(170),{mode:n,item:r,initialStatus:a,events:o,busy:s,error:c,notice:l,t:u,onClose:d,onCreate:m,onSave:g,onStartChat:_,onCreateGoal:v,onAddAttachments:y,onRemoveAttachment:x,onDownloadAttachment:w,onPreviewError:E}=e,D=n!==null,[O,k]=(0,K.useState)(``),[j,N]=(0,K.useState)(``),[P,I]=(0,K.useState)(`todo`),[L,R]=(0,K.useState)(`normal`),[z,ne]=(0,K.useState)(``),[V,re]=(0,K.useState)(``),ie;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(ie=[],t[0]=ie):ie=t[0];let[ae,oe]=(0,K.useState)(ie),se,ce;t[1]!==a||t[2]!==r||t[3]!==n?(se=()=>{if(n===`create`){k(``),N(``),I(a),R(`normal`),ne(``),re(``),oe([]);return}n===`detail`&&r&&(k(r.title),N(r.description??``),I(r.status),R(r.priority),ne(r.nextAction??``),re(r.blockedReason??``),oe([]))},ce=[a,r,n],t[1]=a,t[2]=r,t[3]=n,t[4]=se,t[5]=ce):(se=t[4],ce=t[5]),(0,K.useEffect)(se,ce);let le;t[6]!==V||t[7]!==j||t[8]!==r||t[9]!==n||t[10]!==z||t[11]!==m||t[12]!==g||t[13]!==ae||t[14]!==L||t[15]!==P||t[16]!==O?(le=function(e){e.preventDefault();let t=O.trim();if(t){if(n===`create`){m({title:t,description:j.trim()||void 0,priority:L,status:P,nextAction:z.trim()||void 0,blockedReason:V.trim()||void 0,attachments:ae});return}r&&g(r,{title:t,description:j.trim()||null,status:P,priority:L,nextAction:z.trim()||null,blockedReason:V.trim()||null})}},t[6]=V,t[7]=j,t[8]=r,t[9]=n,t[10]=z,t[11]=m,t[12]=g,t[13]=ae,t[14]=L,t[15]=P,t[16]=O,t[17]=le):le=t[17];let ue=le,de;t[18]===d?de=t[19]:(de=e=>!e&&d(),t[18]=d,t[19]=de);let H;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,q.jsx)(F,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[20]=H):H=t[20];let fe=n===`create`?u.create.title:r?.title||u.title,U;t[21]===fe?U=t[22]:(U=(0,q.jsx)(T,{className:`truncate text-base font-semibold text-fg`,children:fe}),t[21]=fe,t[22]=U);let pe;t[23]===u.detail.description?pe=t[24]:(pe=(0,q.jsx)(C,{className:`mt-1 text-sm text-fg-muted`,children:u.detail.description}),t[23]=u.detail.description,t[24]=pe);let me;t[25]!==U||t[26]!==pe?(me=(0,q.jsxs)(`div`,{className:`min-w-0`,children:[U,pe]}),t[25]=U,t[26]=pe,t[27]=me):me=t[27];let he;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,q.jsx)(Ie,{className:`size-4`,"aria-hidden":!0}),t[28]=he):he=t[28];let ge;t[29]===s?ge=t[30]:(ge=(0,q.jsx)(f,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,disabled:s,children:he})}),t[29]=s,t[30]=ge);let _e;t[31]!==me||t[32]!==ge?(_e=(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[me,ge]}),t[31]=me,t[32]=ge,t[33]=_e):_e=t[33];let ve;t[34]===c?ve=t[35]:(ve=c?(0,q.jsx)(`div`,{className:`rounded-lg border border-danger/30 bg-danger-soft px-3 py-2 text-sm text-danger`,children:c}):null,t[34]=c,t[35]=ve);let ye;t[36]!==c||t[37]!==l?(ye=!c&&l?(0,q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-success/30 bg-success-soft px-3 py-2 text-sm text-fg`,role:`status`,"aria-live":`polite`,children:[(0,q.jsx)(A,{className:`mt-0.5 size-4 shrink-0 text-success`,"aria-hidden":!0}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`div`,{className:`font-medium text-success`,children:l.title}),(0,q.jsx)(`div`,{className:`mt-1 text-fg-muted`,children:l.message})]})]}):null,t[36]=c,t[37]=l,t[38]=ye):ye=t[38];let be;t[39]===u.create.titleLabel?be=t[40]:(be=(0,q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:u.create.titleLabel}),t[39]=u.create.titleLabel,t[40]=be);let xe;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(xe=e=>k(e.target.value),t[41]=xe):xe=t[41];let Se=n===`create`,Ce;t[42]!==Se||t[43]!==O?(Ce=(0,q.jsx)(`input`,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:O,onChange:xe,autoFocus:Se}),t[42]=Se,t[43]=O,t[44]=Ce):Ce=t[44];let we;t[45]!==be||t[46]!==Ce?(we=(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[be,Ce]}),t[45]=be,t[46]=Ce,t[47]=we):we=t[47];let Te;t[48]===u.detail.status?Te=t[49]:(Te=(0,q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:u.detail.status}),t[48]=u.detail.status,t[49]=Te);let Ee;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=e=>I(e.target.value),t[50]=Ee):Ee=t[50];let De;t[51]===u.statuses?De=t[52]:(De=Et.map(e=>(0,q.jsx)(Ne,{value:e,children:u.statuses[e]},e)),t[51]=u.statuses,t[52]=De);let Oe;t[53]!==P||t[54]!==De?(Oe=(0,q.jsx)(Ue,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:P,onChange:Ee,children:De}),t[53]=P,t[54]=De,t[55]=Oe):Oe=t[55];let ke;t[56]!==Te||t[57]!==Oe?(ke=(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[Te,Oe]}),t[56]=Te,t[57]=Oe,t[58]=ke):ke=t[58];let Ae;t[59]===u.create.priorityLabel?Ae=t[60]:(Ae=(0,q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:u.create.priorityLabel}),t[59]=u.create.priorityLabel,t[60]=Ae);let je;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(je=e=>R(e.target.value),t[61]=je):je=t[61];let Me;t[62]===u.priorities?Me=t[63]:(Me=Dt.map(e=>(0,q.jsx)(Ne,{value:e,children:u.priorities[e]},e)),t[62]=u.priorities,t[63]=Me);let Pe;t[64]!==L||t[65]!==Me?(Pe=(0,q.jsx)(Ue,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:L,onChange:je,children:Me}),t[64]=L,t[65]=Me,t[66]=Pe):Pe=t[66];let W;t[67]!==Ae||t[68]!==Pe?(W=(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[Ae,Pe]}),t[67]=Ae,t[68]=Pe,t[69]=W):W=t[69];let Le;t[70]!==ke||t[71]!==W?(Le=(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ke,W]}),t[70]=ke,t[71]=W,t[72]=Le):Le=t[72];let Re;t[73]===u.create.descriptionLabel?Re=t[74]:(Re=(0,q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:u.create.descriptionLabel}),t[73]=u.create.descriptionLabel,t[74]=Re);let ze;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(ze=e=>N(e.target.value),t[75]=ze):ze=t[75];let Be;t[76]===j?Be=t[77]:(Be=(0,q.jsx)(`textarea`,{className:`min-h-28 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:j,onChange:ze}),t[76]=j,t[77]=Be);let Ve;t[78]!==Re||t[79]!==Be?(Ve=(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[Re,Be]}),t[78]=Re,t[79]=Be,t[80]=Ve):Ve=t[80];let He;t[81]!==s||t[82]!==r||t[83]!==n||t[84]!==y||t[85]!==w||t[86]!==E||t[87]!==x||t[88]!==ae||t[89]!==u?(He=(0,q.jsx)(Gt,{mode:n,item:r,pendingFiles:ae,busy:s,t:u,onPendingFilesChange:oe,onUpload:y,onRemove:x,onDownload:w,onPreviewError:E}),t[81]=s,t[82]=r,t[83]=n,t[84]=y,t[85]=w,t[86]=E,t[87]=x,t[88]=ae,t[89]=u,t[90]=He):He=t[90];let We;t[91]!==V||t[92]!==n||t[93]!==z||t[94]!==P||t[95]!==u.blockedReason||t[96]!==u.nextAction?(We=n===`detail`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:u.nextAction}),(0,q.jsx)(`textarea`,{className:`min-h-20 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:z,onChange:e=>ne(e.target.value)})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,q.jsx)(`span`,{className:i(`font-medium`,P===`blocked`||P===`needs_input`?`text-red-700 dark:text-red-300`:`text-fg-muted`),children:u.blockedReason}),(0,q.jsx)(`textarea`,{className:i(`min-h-20 rounded-lg border bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,P===`blocked`||P===`needs_input`?`border-red-500/40`:`border-edge`),value:V,onChange:e=>re(e.target.value)})]})]}):null,t[91]=V,t[92]=n,t[93]=z,t[94]=P,t[95]=u.blockedReason,t[96]=u.nextAction,t[97]=We):We=t[97];let Ge;t[98]!==ve||t[99]!==ye||t[100]!==we||t[101]!==Le||t[102]!==Ve||t[103]!==He||t[104]!==We?(Ge=(0,q.jsxs)(`div`,{className:`grid content-start gap-4`,children:[ve,ye,we,Le,Ve,He,We]}),t[98]=ve,t[99]=ye,t[100]=we,t[101]=Le,t[102]=Ve,t[103]=He,t[104]=We,t[105]=Ge):Ge=t[105];let Ke;t[106]!==s||t[107]!==r||t[108]!==n||t[109]!==v||t[110]!==_||t[111]!==u.detail.actions||t[112]!==u.detail.createGoal||t[113]!==u.detail.openItem||t[114]!==u.detail.startChat?(Ke=n===`detail`&&r?(0,q.jsxs)(`section`,{children:[(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:u.detail.actions}),(0,q.jsxs)(`div`,{className:`mt-2 grid gap-2`,children:[(0,q.jsxs)(h,{type:`button`,variant:`secondary`,className:`justify-start rounded-lg`,disabled:s,onClick:()=>_(r),children:[(0,q.jsx)(B,{className:`size-4`,"aria-hidden":!0}),u.detail.startChat]}),(0,q.jsxs)(h,{type:`button`,variant:`secondary`,className:`justify-start rounded-lg`,disabled:s,onClick:()=>v(r),children:[(0,q.jsx)(S,{className:`size-4`,"aria-hidden":!0}),u.detail.createGoal]}),(0,q.jsx)(h,{asChild:!0,variant:`secondary`,className:`justify-start rounded-lg`,children:(0,q.jsxs)(p,{to:`/work-items/${encodeURIComponent(r.id)}`,children:[(0,q.jsx)(Fe,{className:`size-4`,"aria-hidden":!0}),u.detail.openItem]})})]})]}):null,t[106]=s,t[107]=r,t[108]=n,t[109]=v,t[110]=_,t[111]=u.detail.actions,t[112]=u.detail.createGoal,t[113]=u.detail.openItem,t[114]=u.detail.startChat,t[115]=Ke):Ke=t[115];let qe;t[116]===u.detail.links?qe=t[117]:(qe=(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:u.detail.links}),t[116]=u.detail.links,t[117]=qe);let Je;t[118]!==r||t[119]!==u.detail.noLinks||t[120]!==u.linkKinds?(Je=r?.links?.length?r.links.slice(0,6).map(e=>(0,q.jsxs)(p,{to:Rt(e),className:`flex min-w-0 items-center justify-between gap-3 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,q.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title||e.targetId}),(0,q.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[u.linkKinds[e.kind],(0,q.jsx)(Fe,{className:`size-3.5`,"aria-hidden":!0})]})]},e.id)):(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.detail.noLinks}),t[118]=r,t[119]=u.detail.noLinks,t[120]=u.linkKinds,t[121]=Je):Je=t[121];let Ye;t[122]===Je?Ye=t[123]:(Ye=(0,q.jsx)(`div`,{className:`mt-2 grid gap-2 text-sm`,children:Je}),t[122]=Je,t[123]=Ye);let Xe;t[124]!==qe||t[125]!==Ye?(Xe=(0,q.jsxs)(`section`,{children:[qe,Ye]}),t[124]=qe,t[125]=Ye,t[126]=Xe):Xe=t[126];let Ze;t[127]===u.detail.activity?Ze=t[128]:(Ze=(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:u.detail.activity}),t[127]=u.detail.activity,t[128]=Ze);let Qe;t[129]!==o||t[130]!==u.detail.noActivity||t[131]!==u.eventTypes?(Qe=o.length?o.slice(0,5).map(e=>(0,q.jsxs)(`div`,{className:`text-sm`,children:[(0,q.jsx)(`div`,{className:`font-medium text-fg`,children:u.eventTypes[e.type]??e.type}),(0,q.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:kt(e.createdAt)})]},e.id)):(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.detail.noActivity}),t[129]=o,t[130]=u.detail.noActivity,t[131]=u.eventTypes,t[132]=Qe):Qe=t[132];let $e;t[133]===Qe?$e=t[134]:($e=(0,q.jsx)(`div`,{className:`mt-2 grid gap-2`,children:Qe}),t[133]=Qe,t[134]=$e);let et;t[135]!==Ze||t[136]!==$e?(et=(0,q.jsxs)(`section`,{children:[Ze,$e]}),t[135]=Ze,t[136]=$e,t[137]=et):et=t[137];let tt;t[138]!==Ke||t[139]!==Xe||t[140]!==et?(tt=(0,q.jsxs)(`aside`,{className:`grid content-start gap-5`,children:[Ke,Xe,et]}),t[138]=Ke,t[139]=Xe,t[140]=et,t[141]=tt):tt=t[141];let nt;t[142]!==Ge||t[143]!==tt?(nt=(0,q.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-6 overflow-y-auto px-5 py-4 lg:grid-cols-[minmax(0,1fr)_16rem]`,children:[Ge,tt]}),t[142]=Ge,t[143]=tt,t[144]=nt):nt=t[144];let rt;t[145]!==s||t[146]!==d||t[147]!==u.create.cancel?(rt=(0,q.jsx)(h,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:d,disabled:s,children:u.create.cancel}),t[145]=s,t[146]=d,t[147]=u.create.cancel,t[148]=rt):rt=t[148];let it;t[149]!==s||t[150]!==O?(it=s||!O.trim(),t[149]=s,t[150]=O,t[151]=it):it=t[151];let at;t[152]===n?at=t[153]:(at=n===`create`?(0,q.jsx)(M,{className:`size-4`,"aria-hidden":!0}):null,t[152]=n,t[153]=at);let ot=n===`create`?u.create.submit:u.detail.save,st;t[154]!==it||t[155]!==at||t[156]!==ot?(st=(0,q.jsxs)(h,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:it,children:[at,ot]}),t[154]=it,t[155]=at,t[156]=ot,t[157]=st):st=t[157];let ct;t[158]!==rt||t[159]!==st?(ct=(0,q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[rt,st]}),t[158]=rt,t[159]=st,t[160]=ct):ct=t[160];let lt;t[161]!==ue||t[162]!==_e||t[163]!==nt||t[164]!==ct?(lt=(0,q.jsxs)(te,{children:[H,(0,q.jsx)(ee,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(86dvh,48rem)] w-[min(60rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:(0,q.jsxs)(`form`,{onSubmit:ue,className:`flex min-h-0 flex-1 flex-col`,children:[_e,nt,ct]})})]}),t[161]=ue,t[162]=_e,t[163]=nt,t[164]=ct,t[165]=lt):lt=t[165];let ut;return t[166]!==D||t[167]!==de||t[168]!==lt?(ut=(0,q.jsx)(b,{open:D,onOpenChange:de,children:lt}),t[166]=D,t[167]=de,t[168]=lt,t[169]=ut):ut=t[169],ut}function qt({projectId:e,createRequestKey:t=0}){let n=_(),r=a(o(e=>e.language)).projectDetailPage.workItems,s=(0,K.useRef)(null),c=(0,K.useRef)(null),[l,d]=(0,K.useState)([]),[f,p]=(0,K.useState)(!0),[m,g]=(0,K.useState)(null),[v,y]=(0,K.useState)(null),[b,x]=(0,K.useState)(!1),[S,C]=(0,K.useState)(null),[w,T]=(0,K.useState)(null),[E,D]=(0,K.useState)(!1),[O,k]=(0,K.useState)(!1),[A,j]=(0,K.useState)(!1),[N,P]=(0,K.useState)(`todo`),[F,I]=(0,K.useState)(null),[ee,L]=(0,K.useState)([]),R=(0,K.useCallback)(async(t=`replace`,n=0)=>{p(!0),g(null);try{let r=await nt(e,{limit:100,offset:n});d(e=>t===`append`?[...e,...r.items]:r.items),k(r.hasMore)}catch(e){g(e instanceof Error?e.message:String(e))}finally{p(!1)}},[e]);(0,K.useEffect)(()=>{R(`replace`,0)},[R]),(0,K.useEffect)(()=>{t&&(I(null),L([]),g(null),y(null),P(`todo`),j(!0))},[t]);let z=(0,K.useMemo)(()=>Et.map(e=>({status:e,title:r.statuses[e],items:l.filter(t=>t.status===e)})),[l,r.statuses]),B=(0,K.useCallback)(e=>{d(t=>t.map(t=>t.id===e.id?e:t)),I(t=>t?.id===e.id?e:t)},[]),te=(0,K.useCallback)(async(e,t)=>{x(!0),g(null),y(null);try{let n=await at(e.id,t);n.item.archivedAt?(d(e=>e.filter(e=>e.id!==n.item.id)),I(null)):(B(n.item),y({title:r.feedback.savedTitle,message:r.feedback.savedNext}))}catch(e){g(e instanceof Error?e.message:String(e))}finally{x(!1)}},[r.feedback.savedNext,r.feedback.savedTitle,B]),ne=(0,K.useCallback)(async e=>{I(e),L([]),g(null),y(null);let t=await W(e.id).catch(()=>null);t&&L(t.events)},[]),V=(0,K.useCallback)(async t=>{x(!0),g(null),y(null);try{let n=await $e(e,t);d(e=>[n.item,...e]),j(!1),I(n.item),L((await W(n.item.id).catch(()=>({events:[]}))).events),y({title:r.feedback.createdTitle,message:r.feedback.createdNext})}catch(e){g(e instanceof Error?e.message:String(e))}finally{x(!1)}},[e,r.feedback.createdNext,r.feedback.createdTitle]),re=(0,K.useCallback)(async(e,t)=>{if(t.length){x(!0),g(null),y(null);try{let n=await Ce(e.id,t);B(n.item),L((await W(n.item.id).catch(()=>({events:[]}))).events)}catch(e){g(e instanceof Error?e.message:String(e))}finally{x(!1)}}},[B]),ie=(0,K.useCallback)(async(e,t)=>{x(!0),g(null),y(null);try{let n=await H(e.id,t.id);B(n.item),L((await W(n.item.id).catch(()=>({events:[]}))).events)}catch(e){g(e instanceof Error?e.message:String(e))}finally{x(!1)}},[B]),ae=(0,K.useCallback)(async(e,t)=>{g(null),y(null);try{await Ge(e.id,t)}catch(e){g(e instanceof Error?e.message:String(e))}},[]),oe=(0,K.useCallback)(async e=>{x(!0),g(null),y(null);try{let t=await ge(e.id);B(t.item),await ne(t.item),n(`/chat/${encodeURIComponent(t.session.key)}`)}catch(e){g(e instanceof Error?e.message:String(e))}finally{x(!1)}},[n,ne,B]),se=(0,K.useCallback)(async e=>{x(!0),g(null),y(null);try{let t=await Ae(e.id);B(t.item),await ne(t.item),n(`/goals/${encodeURIComponent(t.goal.id)}`)}catch(e){g(e instanceof Error?e.message:String(e))}finally{x(!1)}},[n,ne,B]),ce=(0,K.useCallback)((e,t)=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(Tt,e.id),C(e.id)},[]),le=(0,K.useCallback)((e,t)=>{t.preventDefault();let n=t.dataTransfer.getData(Tt)||S;T(null),C(null);let r=l.find(e=>e.id===n);!r||r.status===e||te(r,{status:e})},[S,l,te]),ue=(0,K.useCallback)(e=>{te(e,{status:e.status===`done`?`todo`:`done`})},[te]),de=(0,K.useCallback)(e=>{I(null),L([]),g(null),y(null),P(e),j(!0)},[]),fe=(0,K.useCallback)(e=>{let t=c.current;!t||t.pointerId!==e.pointerId||(c.current=null,D(!1),e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},[]),U=(0,K.useCallback)(e=>{if(e.button!==0||S||zt(e.target))return;let t=s.current;t&&(c.current={pointerId:e.pointerId,startX:e.clientX,scrollLeft:t.scrollLeft,active:!1},e.currentTarget.setPointerCapture(e.pointerId))},[S]),pe=(0,K.useCallback)(e=>{let t=c.current,n=s.current;if(!t||!n||t.pointerId!==e.pointerId)return;let r=e.clientX-t.startX;!t.active&&Math.abs(r)<5||(t.active||(t.active=!0,D(!0)),e.preventDefault(),n.scrollLeft=t.scrollLeft-r)},[]);return(0,q.jsxs)(`section`,{id:`project-panel-work-items`,role:`tabpanel`,"aria-labelledby":`project-tab-work-items`,className:`flex h-full min-h-0 flex-col`,children:[m?(0,q.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-3 text-sm text-red-700 dark:text-red-300`,children:m}):null,(0,q.jsx)(`section`,{ref:s,className:i(`min-h-0 flex-1 overflow-x-auto rounded-lg px-2 py-2 transition-opacity`,f&&`opacity-60`,E?`cursor-grabbing select-none`:`cursor-grab`),"aria-label":r.boardAria,"aria-busy":f,onPointerDown:U,onPointerMove:pe,onPointerUp:fe,onPointerCancel:fe,onLostPointerCapture:e=>{c.current?.pointerId===e.pointerId&&(c.current=null,D(!1))},children:(0,q.jsx)(`div`,{className:`flex min-h-full min-w-max items-start gap-3 pr-4`,children:z.map(e=>(0,q.jsxs)(`section`,{className:i(`flex max-h-full w-72 min-w-72 max-w-72 shrink-0 flex-col overflow-y-auto rounded-lg bg-surface-base shadow-surface`,w===e.status&&`bg-surface-active`),"aria-label":e.title,onDragOver:t=>{S&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,T(e.status))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||T(null)},onDrop:t=>le(e.status,t),children:[(0,q.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 px-3 py-3`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.title}),(0,q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:e.items.length})]}),(0,q.jsx)(u,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),(0,q.jsxs)(`div`,{className:`mx-2 mt-3 grid min-h-0 min-w-0 content-start gap-2 pb-2 pr-1 [scrollbar-gutter:stable]`,children:[e.items.length?e.items.map(e=>(0,q.jsx)(Vt,{item:e,dragging:S===e.id,onOpen:ne,onToggleDone:ue,onDragStart:ce,onDragEnd:()=>{C(null),T(null)},t:r},e.id)):f?(0,q.jsxs)(`div`,{className:`grid gap-2 animate-pulse motion-reduce:animate-none`,children:[(0,q.jsx)(Ht,{}),(0,q.jsx)(Ht,{})]}):(0,q.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-6 text-center text-xs text-fg-subtle`,children:r.emptyColumn}),f?null:(0,q.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-full items-center justify-center rounded-lg bg-surface-panel/85 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-muted`,"aria-label":r.create.addToColumn.replace(`{{status}}`,e.title),title:r.create.addToColumn.replace(`{{status}}`,e.title),onClick:()=>de(e.status),children:(0,q.jsx)(M,{className:`size-4`,"aria-hidden":!0})})]})]},e.status))})}),!f&&O?(0,q.jsx)(h,{type:`button`,variant:`secondary`,className:`justify-self-center`,onClick:()=>void R(`append`,l.length),children:r.loadMore}):null,(0,q.jsx)(Kt,{mode:A?`create`:F?`detail`:null,item:F,initialStatus:N,events:ee,busy:b,error:m,notice:v,t:r,onClose:()=>{j(!1),I(null),L([]),g(null),y(null)},onCreate:V,onSave:(e,t)=>void te(e,t),onStartChat:oe,onCreateGoal:se,onAddAttachments:(e,t)=>void re(e,t),onRemoveAttachment:(e,t)=>void ie(e,t),onDownloadAttachment:(e,t)=>void ae(e,t),onPreviewError:e=>{y(null),g(e)}})]})}var Jt=[{id:`overview`,icon:He},{id:`work-items`,icon:oe},{id:`sessions`,icon:B},{id:`goals`,icon:S},{id:`workflows`,icon:ft},{id:`files`,icon:U},{id:`activity`,icon:ve},{id:`automations`,icon:k},{id:`notes`,icon:dt},{id:`settings`,icon:qe}],Yt=Jt.map(e=>e.id),Xt=new Set(Jt.map(e=>e.id)),Zt=`xopc.projectTabs.`,Qt=`xopc.projectFiles.panelWidthPx`,$t=320,en=220,tn=560;function nn(e){return Math.min(tn,Math.max(en,Math.round(e)))}function rn(){try{let e=window.localStorage.getItem(Qt);if(e==null)return $t;let t=Number.parseInt(e,10);return Number.isFinite(t)?nn(t):$t}catch{return $t}}function an(e){try{window.localStorage.setItem(Qt,String(nn(e)))}catch{}}function on(e){return!!(e&&Xt.has(e))}function sn(e){return`${Zt}${e}`}function cn(e){let t=Array.isArray(e)?e:[],n=new Set,r=[];for(let e of t)!on(e)||n.has(e)||(n.add(e),r.push(e));for(let e of Yt)n.has(e)||r.push(e);return r}function ln(e){if(!e)return Yt;try{let t=window.localStorage.getItem(sn(e));return cn(t?JSON.parse(t):null)}catch{return Yt}}function un(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function dn(e,t=``){if(!e)return t;let n=new Date(e);return Number.isNaN(n.getTime())?String(e):new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(n)}function fn(e){return e===`active`?`bg-accent-soft text-accent-fg`:e===`done`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`paused`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`archived`?`bg-surface-muted text-fg-subtle`:`bg-surface-hover text-fg-muted`}function pn(e){return e===`succeeded`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`||e===`cancelled`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`running`||e===`queued`?`bg-accent-soft text-accent-fg`:`bg-surface-hover text-fg-muted`}function mn(e){let t=(0,G.c)(8),{label:n,hint:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,q.jsx)(`span`,{className:`text-xs leading-5 text-fg-subtle`,children:r}):null,t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function hn(e=!1){return i(`w-full rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,e?`min-h-24 py-2 leading-5`:`min-h-10`)}function gn(e){let t=(0,G.c)(10),{label:n,value:r,mono:a}=e,o=a===void 0?!1:a,s;t[0]===n?s=t[1]:(s=(0,q.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n}),t[0]=n,t[1]=s);let c=o&&`font-mono text-xs`,l;t[2]===c?l=t[3]:(l=i(`mt-1 min-w-0 truncate text-sm text-fg`,c),t[2]=c,t[3]=l);let u;t[4]!==l||t[5]!==r?(u=(0,q.jsx)(`div`,{className:l,title:r,children:r}),t[4]=l,t[5]=r,t[6]=u):u=t[6];let d;return t[7]!==s||t[8]!==u?(d=(0,q.jsxs)(`div`,{className:`min-w-0 rounded-md bg-surface-base px-3 py-2`,children:[s,u]}),t[7]=s,t[8]=u,t[9]=d):d=t[9],d}function Y(e){return[e.name,e.slug,e.workspaceRoot,e.description,e.brief].filter(Boolean).join(` `).toLowerCase()}function _n(e){let t=e.lastActiveAt??e.updatedAt??e.createdAt,n=t?new Date(t).getTime():0;return Number.isFinite(n)?n:0}function vn(e){return e.trim().replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??``}function yn(e){let t=e?.body;return t?.code===`workspace_root_missing`&&t.workspaceRoot?t.workspaceRoot:null}function bn(e){let t=e.actor;return t.name?t.name:t.agentId?t.agentId:t.id?t.id:t.sessionKey?t.sessionKey:t.kind}function xn(e){return e.primaryObject.title?.trim()||e.primaryObject.id}function Sn(e){let t=e.source;return t.toolCallId?`${t.kind} · ${t.toolCallId}`:t.runId?`${t.kind} · ${t.runId}`:t.requestId?`${t.kind} · ${t.requestId}`:t.kind}function Cn(e){let t=e.payload.changes;if(Array.isArray(t)&&t.length)return t.filter(e=>typeof e==`string`).join(`, `);let n=e.payload.contentPreview;if(typeof n==`string`&&n.trim())return n.trim();let r=e.payload.title??e.payload.name;return typeof r==`string`&&r.trim()?r.trim():``}function wn(e){return e.map(e=>({name:e.name,path:e.path,absolutePath:e.absolutePath,isDirectory:e.type===`directory`,children:e.type===`directory`?[]:void 0}))}function Tn(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:Tn(e.children,t,n)}:e)}function En({currentProject:e,pm:t,projectsText:n,wd:r}){let a=_(),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)([e]),[u,d]=(0,K.useState)(``),[p,m]=(0,K.useState)(!1),[g,v]=(0,K.useState)(null),[y,x]=(0,K.useState)(!1),[S,w]=(0,K.useState)(`new`),[E,D]=(0,K.useState)(``),[O,k]=(0,K.useState)(``),[A,j]=(0,K.useState)(!1),[N,P]=(0,K.useState)(null),[L,R]=(0,K.useState)(null),z=(0,K.useCallback)(async()=>{m(!0),v(null);try{let t=await xe({limit:100});l(n=>{let r=new Map;r.set(e.id,e);for(let e of n)r.set(e.id,e);for(let e of t.items)r.set(e.id,e);return Array.from(r.values())})}catch(e){v(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e]);(0,K.useEffect)(()=>{l(t=>[e,...t.filter(t=>t.id!==e.id)])},[e]),(0,K.useEffect)(()=>{o&&z()},[z,o]);let B=(0,K.useMemo)(()=>{let t=u.trim().toLowerCase().split(/\s+/).filter(Boolean);return c.filter(t=>t.id!==e.id).filter(e=>{if(t.length===0)return!0;let n=Y(e);return t.every(e=>n.includes(e))}).sort((e,t)=>_n(t)-_n(e))},[e.id,c,u]),ne=e=>t.statuses[e.status]??e.status,V=e=>e.workspaceRoot||e.effectiveWorkspaceRoot||e.description||e.brief||t.common.defaultWorkspace,re=e=>{w(e),D(``),k(``),P(null),x(!0),s(!1)},ie=(0,K.useCallback)(async(e={})=>{let t=O.trim(),n=E.trim()||(S===`directory`?vn(t):``);if(n){j(!0),P(null),R(null);try{let r=await I({name:n,...t?{workspaceRoot:t}:{},...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}});x(!1),D(``),k(``),l(e=>[r,...e.filter(e=>e.id!==r.id)]),a(`/projects/${encodeURIComponent(r.id)}`)}catch(e){let t=yn(e);t?(R(t),x(!1)):P(e instanceof Error?e.message:String(e))}finally{j(!1)}}},[S,E,a,O]),ae=(0,K.useCallback)(e=>{e.preventDefault(),ie()},[ie]),oe=(0,K.useCallback)(()=>{ie({createWorkspaceRoot:!0})},[ie]),se=(0,K.useCallback)(()=>{R(null),x(!0)},[]),ce=e=>{k(e),S===`directory`&&!E.trim()&&D(vn(e))},le=(e,t)=>(0,q.jsxs)(`button`,{type:`button`,className:i(`grid w-full grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-2 rounded-md px-2 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,t&&`bg-accent-soft/55 hover:bg-accent-soft/70`),onClick:()=>{s(!1),t||a(`/projects/${encodeURIComponent(e.id)}`)},children:[(0,q.jsx)(Me,{className:i(`size-4 text-accent-fg`,!t&&`invisible`),"aria-hidden":!0}),(0,q.jsxs)(`span`,{className:`min-w-0`,children:[(0,q.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,q.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:V(e)})]}),(0,q.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,fn(e.status)),children:ne(e)})]},e.id);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(be,{open:o,onOpenChange:s,children:[(0,q.jsx)(Te,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:`group -ml-2 flex max-w-full min-w-0 items-center gap-2 rounded-lg px-2 py-1 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":t.projectSwitcher.switchProject,title:t.projectSwitcher.switchProject,children:[(0,q.jsxs)(`span`,{className:`min-w-0`,children:[(0,q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:e.name}),(0,q.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,fn(e.status)),children:ne(e)})]}),(0,q.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:V(e)})]}),(0,q.jsx)(tt,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-data-[state=open]:rotate-180`,"aria-hidden":!0})]})}),(0,q.jsx)(ct,{children:(0,q.jsxs)(Le,{side:`bottom`,align:`start`,sideOffset:6,className:`z-[70] w-[min(26rem,calc(100vw-2rem))] overflow-hidden rounded-xl border border-edge bg-surface-panel p-1.5 shadow-popover outline-none`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,q.jsxs)(`label`,{className:`relative block`,children:[(0,q.jsx)(lt,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,q.jsx)(`input`,{type:`search`,className:`h-9 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:u,onChange:e=>d(e.target.value),placeholder:t.projectSwitcher.searchPlaceholder,"aria-label":t.projectSwitcher.searchPlaceholder})]}),(0,q.jsxs)(`div`,{className:`mt-1 max-h-[min(54vh,24rem)] overflow-y-auto pr-0.5 [scrollbar-gutter:stable]`,children:[(0,q.jsx)(`div`,{className:`px-2 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.current}),le(e,!0),(0,q.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.recent}),g?(0,q.jsx)(`div`,{className:`px-2 py-2 text-xs text-red-600 dark:text-red-400`,children:g}):null,p&&B.length===0?(0,q.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.loading}):null,!p&&B.length===0?(0,q.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.noMatches}):null,B.map(e=>le(e,!1))]}),(0,q.jsxs)(`div`,{className:`mt-1 border-t border-edge-subtle pt-1`,children:[(0,q.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>re(`new`),children:[(0,q.jsx)(M,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.newProject})]}),(0,q.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>re(`directory`),children:[(0,q.jsx)(U,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.openDirectory})]}),(0,q.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>{s(!1),a(`/projects`)},children:[(0,q.jsx)(qe,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.manageProjects})]})]})]})})]}),(0,q.jsx)(b,{open:y,onOpenChange:e=>!A&&x(e),children:(0,q.jsxs)(te,{children:[(0,q.jsx)(F,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,q.jsxs)(ee,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(32rem,calc(100vh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,q.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,q.jsx)(T,{className:`text-base font-semibold text-fg`,children:S===`directory`?t.projectSwitcher.createFromDirectoryTitle:n.createTitle}),(0,q.jsx)(C,{className:`mt-1 text-sm text-fg-muted`,children:S===`directory`?t.projectSwitcher.createFromDirectoryDescription:n.createDescription})]}),(0,q.jsxs)(`form`,{onSubmit:ae,className:`flex min-h-0 flex-1 flex-col`,children:[(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[N?(0,q.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:N}):null,(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.projectName}),(0,q.jsx)(`input`,{className:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:E,onChange:e=>D(e.target.value),placeholder:`xopc`,autoFocus:!0})]}),(0,q.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.workspaceRoot}),(0,q.jsx)(bt,{value:O,onChange:ce,disabled:A,wd:r,placeholder:n.workspacePlaceholder,inputClassName:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.workspaceHint})]})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,q.jsx)(f,{asChild:!0,children:(0,q.jsx)(h,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:A,children:n.cancel})}),(0,q.jsxs)(h,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:A||!(E.trim()||S===`directory`&&vn(O)),children:[(0,q.jsx)(M,{className:`size-4`,"aria-hidden":!0}),n.create]})]})]})]})]})}),(0,q.jsx)(b,{open:!!L,onOpenChange:e=>{e||R(null)},children:(0,q.jsxs)(te,{children:[(0,q.jsx)(F,{className:`fixed inset-0 z-[100] bg-scrim backdrop-blur-[2px]`}),(0,q.jsxs)(ee,{className:`fixed left-1/2 top-1/2 z-[110] flex w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,q.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,q.jsx)(T,{className:`text-base font-semibold text-fg`,children:n.workspaceMissingTitle}),(0,q.jsx)(C,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:L?un(n.workspaceMissingDescription,{workspace:L}):null})]}),L?(0,q.jsx)(`div`,{className:`px-5 py-4`,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,q.jsx)(U,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`min-w-0 truncate`,children:L})]})}):null,(0,q.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,q.jsx)(h,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:se,disabled:A,children:n.workspaceMissingBack}),(0,q.jsxs)(h,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:oe,disabled:A,children:[(0,q.jsx)(pt,{className:`size-4`,"aria-hidden":!0}),n.workspaceMissingCreate]})]})]})]})})]})}function Dn(){let{projectId:e=``,tabId:t,noteId:n}=m(),r=_(),s=o(e=>e.language),c=a(s),u=c.chat.workingDirectory,S=c.projectDetailPage,O=c.projectsPage,A=Ze(e=>e.setPageHeader),P=Ze(e=>e.clearPageHeader),[I,oe]=(0,K.useState)(null),[H,ge]=(0,K.useState)(null),[ve,be]=(0,K.useState)([]),[xe,Ce]=(0,K.useState)(``),[we,Te]=(0,K.useState)([]),[Ae,Me]=(0,K.useState)([]),[Pe,Fe]=(0,K.useState)([]),[W,Le]=(0,K.useState)([]),[He,Ge]=(0,K.useState)([]),[qe,Je]=(0,K.useState)(!1),[$e,tt]=(0,K.useState)(null),[nt,it]=(0,K.useState)([]),[at,ot]=(0,K.useState)(0),[ct,G]=(0,K.useState)(!1),[Tt,Et]=(0,K.useState)(!1),[Dt,Ot]=(0,K.useState)(!1),[kt,At]=(0,K.useState)([]),J=(0,K.useRef)(new Set),[jt,Mt]=(0,K.useState)(null),[Nt,Pt]=(0,K.useState)(rn),[Ft,It]=(0,K.useState)(!1),[Lt,Rt]=(0,K.useState)(!1),[zt,Bt]=(0,K.useState)(``),[Vt,Ht]=(0,K.useState)([]),[Ut,Wt]=(0,K.useState)(!1),[Gt,Kt]=(0,K.useState)(null),[Xt,Zt]=(0,K.useState)(!1),[Qt,$t]=(0,K.useState)(null),[en,tn]=(0,K.useState)([]),[Y,_n]=(0,K.useState)(``),[vn,Dn]=(0,K.useState)(!0),[On,kn]=(0,K.useState)(!1),[An,jn]=(0,K.useState)(!1),[Mn,Nn]=(0,K.useState)(null),[Pn,Fn]=(0,K.useState)(!1),[In,Ln]=(0,K.useState)(`fixed`),[Rn,zn]=(0,K.useState)(``),[Bn,Vn]=(0,K.useState)(null),[Hn,Un]=(0,K.useState)(!1),[Wn,Gn]=(0,K.useState)(!1),[Kn,qn]=(0,K.useState)(0),[Jn,Yn]=(0,K.useState)(!1),[Xn,Zn]=(0,K.useState)(!1),[Qn,$n]=(0,K.useState)(null),[er,tr]=(0,K.useState)(null),[nr,rr]=(0,K.useState)(!1),[ir,ar]=(0,K.useState)(!1),[or,sr]=(0,K.useState)(!1),[cr,X]=(0,K.useState)(null),[lr,ur]=(0,K.useState)({defaultAgentId:``,agents:[],models:[],checklistDecomposePolicy:`empty_only`}),[dr,fr]=(0,K.useState)({title:``,reason:``}),[pr,mr]=(0,K.useState)(()=>ln(e)),[Z,hr]=(0,K.useState)({name:``,description:``,status:`active`,defaultAgentId:``,workspaceRoot:``,brief:``,instructions:``}),gr=pr[0]??Yt[0],Q=n?`notes`:on(t)?t:gr,_r=(0,K.useCallback)(t=>{e&&r(`/projects/${encodeURIComponent(e)}/${t}`)},[r,e]),vr=(0,K.useCallback)(t=>e?`/projects/${encodeURIComponent(e)}/${t}`:`/projects`,[e]),yr=(0,K.useCallback)(e=>{let t=vr(`goals`);return`/goals/${encodeURIComponent(e)}?returnTo=${encodeURIComponent(t)}`},[vr]),br=(0,K.useCallback)(t=>{e&&r(vr(t),{replace:!0})},[r,e,vr]),$=(0,K.useCallback)((e,t)=>{br(e),r(t)},[r,br]),xr=(0,K.useCallback)(e=>t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||br(e)},[br]),Sr=(0,K.useCallback)(e=>e.startsWith(`/goals/`)?`goals`:e.startsWith(`/chat/`)?`sessions`:e.startsWith(`/workflows`)?`workflows`:e.startsWith(`/automations`)?`automations`:e.startsWith(`/notes`)?`notes`:Q,[Q]);(0,K.useEffect)(()=>{!e||!t||on(t)||r(`/projects/${encodeURIComponent(e)}/${gr}`,{replace:!0})},[gr,r,e,t]),(0,K.useEffect)(()=>{mr(ln(e))},[e]);let Cr=(0,K.useCallback)((t,n,r=`before`)=>{t!==n&&mr(i=>{let a=cn(i),o=a.indexOf(t),s=a.indexOf(n);if(o<0||s<0)return a;let[c]=a.splice(o,1),l=a.indexOf(n);return l<0?cn(i):(a.splice(r===`after`?l+1:l,0,c),e&&window.localStorage.setItem(sn(e),JSON.stringify(a)),a)})},[e]);(0,K.useEffect)(()=>{if(!e)return;let t=!1;return Dn(!0),X(null),Promise.all([j(e),l(e),ie(e),We().catch(()=>null)]).then(([e,n,r,i])=>{if(t)return;let a=e.project;oe(a),ge(e),be(n),Te(r),tn(i?.agents??[]),_n(a.defaultAgentId??``),hr({name:a.name,description:a.description??``,status:a.status,defaultAgentId:a.defaultAgentId??``,workspaceRoot:a.workspaceRoot??``,brief:a.brief??``,instructions:a.instructions??``})}).catch(e=>{t||X(e instanceof Error?e.message:String(e))}).finally(()=>{t||Dn(!1)}),()=>{t=!0}},[e]),(0,K.useEffect)(()=>{let e=!1;async function t(){let[t,n,r]=await Promise.allSettled([We(),gt(),ze()]);e||ur(e=>{let i=t.status===`fulfilled`?t.value.defaultId:e.defaultAgentId,a=I?.defaultAgentId||Y||i,o=t.status===`fulfilled`?t.value.agents:e.agents,s=n.status===`fulfilled`?n.value:e.models,c=r.status===`fulfilled`?xt(r.value.payload?.config).checklistDecomposePolicy:e.checklistDecomposePolicy;return{defaultAgentId:a,agents:o.length?o:[{id:a||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],models:s,checklistDecomposePolicy:c}})}return t(),()=>{e=!0}},[I?.defaultAgentId,Y]);let wr=(0,K.useCallback)(async()=>{if(I){Yn(!0),X(null);try{let[e,t]=await Promise.all([De(),de(100,{ownerAgentId:Y||void 0,projectId:I.id})]);Me(e),Fe(t)}catch(e){X(e instanceof Error?e.message:String(e))}finally{Yn(!1)}}},[I,Y]);(0,K.useEffect)(()=>{I&&wr()},[I,wr]);let Tr=(0,K.useCallback)(async()=>{if(I){Je(!0),X(null);try{let[e,t]=await Promise.all([mt.list({projectId:I.id}),mt.runs(50,void 0,{projectId:I.id})]);Le(e.automations),Ge(t.runs)}catch(e){X(e instanceof Error?e.message:String(e))}finally{Je(!1)}}},[I]);(0,K.useEffect)(()=>{Q===`automations`&&Tr()},[Tr,Q]);let Er=(0,K.useCallback)(async()=>{if(I){G(!0),X(null);try{let e=await re(I.id,{includeRelated:Tt,limit:100});it(e.items),ot(e.total)}catch(e){X(e instanceof Error?e.message:String(e))}finally{G(!1)}}},[I,Tt]);(0,K.useEffect)(()=>{Q===`activity`&&Er()},[Er,Q]);let Dr=(0,K.useCallback)(async e=>{tt(`run:${e.id}`),X(null);try{await mt.runNow(e.id),await Tr()}catch(e){X(e instanceof Error?e.message:String(e))}finally{tt(null)}},[Tr]),Or=(0,K.useCallback)(async e=>{tt(`toggle:${e.id}`),X(null);try{e.enabled?await mt.pause(e.id):await mt.resume(e.id),await Tr()}catch(e){X(e instanceof Error?e.message:String(e))}finally{tt(null)}},[Tr]),kr=(0,K.useCallback)(async()=>{if(!I?.effectiveWorkspaceRoot?.trim()){At([]),J.current.clear(),$t(null);return}Zt(!0),$t(null),J.current.clear();try{At(wn((await V(I.id,``)).entries)),J.current.add(``)}catch(e){At([]),J.current.clear(),$t(e instanceof Error?e.message:String(e))}finally{Zt(!1)}},[I]),Ar=(0,K.useCallback)(async e=>{if(!(!I?.effectiveWorkspaceRoot?.trim()||J.current.has(e))){J.current.add(e),$t(null);try{let t=await V(I.id,e);At(n=>Tn(n,e,wn(t.entries)))}catch(t){J.current.delete(e),$t(t instanceof Error?t.message:String(t))}}},[I]);(0,K.useEffect)(()=>{Q===`files`&&kr()},[kr,Q]);let jr=zt.trim();(0,K.useEffect)(()=>{if(Q!==`files`||!I||!Lt||!jr){Ht([]),Wt(!1),Kt(null);return}let e=!1;Wt(!0),Kt(null),Ht([]);let t=window.setTimeout(()=>{fe(I.id,jr,50).then(t=>{e||Ht(t)}).catch(t=>{e||Kt(t instanceof Error?t.message:String(t))}).finally(()=>{e||Wt(!1)})},180);return()=>{e=!0,window.clearTimeout(t)}},[jr,I,Lt,Q]);let Mr=(0,K.useCallback)(async()=>{if(I){Gn(!0),X(null);try{let e=await E(I.id);$(`sessions`,`/chat/${encodeURIComponent(e.key)}`)}catch(e){X(e instanceof Error?e.message:String(e))}finally{Gn(!1)}}},[$,I]),Nr=(0,K.useCallback)(()=>{_r(`work-items`),qn(e=>e+1)},[_r]),Pr=(0,K.useCallback)(async()=>{if(!I)return;let[e,t]=await Promise.all([j(I.id),ie(I.id)]);ge(e),oe(e.project),Te(t)},[I]),Fr=(0,K.useCallback)(async e=>{if(!I||!e.title.trim())return;let t=Number.parseInt(e.maxTurns,10),n=e.deadline?new Date(e.deadline).getTime():void 0;rr(!0),X(null);try{await x(I.id,{title:e.title.trim(),description:e.description.trim()||void 0,attachments:e.attachments.length?e.attachments:void 0,priority:e.priority,deadlineAt:Number.isFinite(n)?n:void 0,maxTurns:Number.isFinite(t)?t:void 0,agentId:e.agentId.trim()||void 0,judgeModelRef:e.judgeModelRef.trim()||void 0,contract:{objective:e.objective.trim()||e.title.trim(),scopeBoundary:e.scopeBoundary.trim()||void 0,evidencePlan:St(e.evidencePlan),criteria:St(e.checklist)}}),sr(!1),_r(`goals`),await Pr()}catch(e){throw X(e instanceof Error?e.message:String(e)),e}finally{rr(!1)}},[_r,I,Pr]),Ir=(0,K.useCallback)(async e=>{if(e.preventDefault(),!(!I||!dr.title.trim())){ar(!0),X(null);try{await ne(I.id,{title:dr.title.trim(),reason:dr.reason.trim()||void 0}),fr({title:``,reason:``}),await Pr()}catch(e){X(e instanceof Error?e.message:String(e))}finally{ar(!1)}}},[dr.reason,dr.title,I,Pr]),Lr=(0,K.useCallback)(async e=>{if(!(!I||!er)){Zn(!0),X(null);try{let t=Y||I.defaultAgentId||void 0,n=await N({definitionId:er.id,projectId:I.id,agentId:t,goal:e.goal,input:e.input,concurrency:e.concurrency,maxSubagents:e.maxSubagents});tr(null),await wr(),$(`workflows`,D(n.runId,{ownerAgentId:t}))}catch(e){X(e instanceof Error?e.message:String(e))}finally{Zn(!1)}}},[$,I,wr,Y,er]),Rr=(0,K.useCallback)(async e=>{if(I){$n(`retry:${e.id}`),X(null);try{let t=await _t(e.id,{ownerAgentId:Y||e.metadata?.agentId,projectId:e.metadata?.projectId||I.id});await wr(),$(`workflows`,D(t.runId,{ownerAgentId:Y||e.metadata?.agentId||I.defaultAgentId}))}catch(e){X(e instanceof Error?e.message:String(e))}finally{$n(null)}}},[$,I,wr,Y]),zr=(0,K.useCallback)(async e=>{$n(`cancel:${e.id}`),X(null);try{await Re(e.id,{ownerAgentId:Y||e.metadata?.agentId}),await wr()}catch(e){X(e instanceof Error?e.message:String(e))}finally{$n(null)}},[wr,Y]),Br=(0,K.useMemo)(()=>(0,q.jsx)(p,{to:`/projects`,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":S.backToProjects,children:(0,q.jsx)(le,{className:`size-4`,"aria-hidden":!0})}),[S.backToProjects]),Vr=(0,K.useMemo)(()=>I?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(h,{variant:`secondary`,className:`h-9 rounded-lg`,onClick:Nr,children:[(0,q.jsx)(M,{className:`size-4`,"aria-hidden":!0}),S.workItems.create.header]}),(0,q.jsxs)(h,{variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>void Mr(),disabled:Wn,children:[(0,q.jsx)(B,{className:`size-4`,"aria-hidden":!0}),S.common.newChat]})]}):null,[Nr,S.common.newChat,S.workItems.create.header,I,Mr,Wn]);(0,K.useLayoutEffect)(()=>(A({startExtra:Br,main:I?(0,q.jsx)(En,{currentProject:I,pm:S,projectsText:O,wd:u}):(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:S.fallbackTitle}),(0,q.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:S.fallbackContext})]}),end:Vr}),()=>P()),[P,Vr,Br,S,I,O,A,u]);function Hr(e){oe(t=>t?{...t,...e}:null),ge(t=>t?{...t,project:{...t.project,...e}}:null),_n(e.defaultAgentId??``),hr(t=>({...t,name:e.name,description:e.description??``,status:e.status,defaultAgentId:e.defaultAgentId??``,workspaceRoot:e.workspaceRoot??``,brief:e.brief??``,instructions:e.instructions??``})),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}async function Ur(){if(!(!I||!Z.name.trim())){kn(!0),X(null),Nn(null);try{Hr(await rt(I.id,{name:Z.name.trim(),status:Z.status,description:Z.description,defaultAgentId:Z.defaultAgentId,brief:Z.brief,instructions:Z.instructions}))}catch(e){let t=yn(e);t?Nn(t):X(e instanceof Error?e.message:String(e))}finally{kn(!1)}}}function Wr(e){e.preventDefault(),Ur()}let Gr=(0,K.useCallback)(()=>{if(!I)return;let e=I.workspaceRoot?.trim()??``;Ln(e?`fixed`:`follow`),zn(e||I.effectiveWorkspaceRoot||``),Fn(!0)},[I]);async function Kr(e={}){if(!I)return;let t=In===`fixed`?Rn.trim():``;if(!(In===`fixed`&&!t)){kn(!0),X(null),Nn(null);try{Hr(await rt(I.id,{workspaceRoot:t,...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}})),Fn(!1),Nn(null)}catch(e){let t=yn(e);t?(Nn(t),Fn(!1)):X(e instanceof Error?e.message:String(e))}finally{kn(!1)}}}async function qr(){if(!(!I||Bn)){Vn(`pin`),X(null);try{Hr(I.pinnedAt?await Ke(I.id):await Ve(I.id))}catch(e){X(e instanceof Error?e.message:String(e))}finally{Vn(null)}}}async function Jr(){if(!(!I||Bn)){Vn(`archive`),X(null);try{Hr(I.status===`archived`?await et(I.id):await w(I.id))}catch(e){X(e instanceof Error?e.message:String(e))}finally{Vn(null)}}}async function Yr(){if(I){Un(!0),X(null);try{await Qe(I.id),jn(!1),r(`/projects`)}catch(e){X(e instanceof Error?e.message:String(e))}finally{Un(!1)}}}async function Xr(){if(!(!I||Dt)){Ot(!0),X(null);try{await je(I.id)}catch(e){X(e instanceof Error?e.message:String(e))}finally{Ot(!1)}}}let Zr=(0,K.useCallback)(e=>{Mt(e)},[]),Qr=(0,K.useCallback)((e,t)=>{t||Mt(e)},[]),$r=(0,K.useCallback)(async(e,t,n)=>{let r=I?.id;if(r)switch(e){case`preview`:t.isDirectory||Mt(t.path);break;case`download`:if(t.isDirectory)return;try{let e=ye(t.path);if(Ye(st(e))!==`text`){let n=await Ee(t.path,{projectId:r}),i=_e(e)??`application/octet-stream`;Be(e,await n.arrayBuffer(),i)}else{let{content:n}=await ce(t.path,{projectId:r});Oe(e,n)}}catch(e){pe(`warning`,e instanceof Error?e.message:String(e),void 0,{duration:4e3})}break;case`copyPath`:try{await ue(t.absolutePath??t.path)&&pe(`success`,c.workspace.pathCopied,void 0,{duration:2500})}catch{pe(`warning`,c.clipboard.copyFailed,void 0,{duration:4e3})}break;case`openDefault`:if(!t.absolutePath||!window.electronAPI?.shell?.openPath)return;await window.electronAPI.shell.openPath(t.absolutePath);break;case`openWith`:if(!t.absolutePath||!window.electronAPI?.shell?.chooseAppAndOpenPath)return;await window.electronAPI.shell.chooseAppAndOpenPath(t.absolutePath);break;case`openWithApp`:if(!t.absolutePath||!n||!window.electronAPI?.shell?.openPathWithApp)return;await window.electronAPI.shell.openPathWithApp(t.absolutePath,n);break;case`revealInFolder`:if(!t.absolutePath||!window.electronAPI?.shell?.showItemInFolder)return;await window.electronAPI.shell.showItemInFolder(t.absolutePath);break;default:break}},[c.clipboard.copyFailed,c.workspace.pathCopied,I?.id]),ei=(0,K.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;e.preventDefault();let t=e.currentTarget,n=t.closest(`[data-project-files-grid]`);if(!n)return;t.setPointerCapture(e.pointerId),It(!0);let r=e.clientX,i=Nt,a=e.pointerId,o=0,s=i,c=i,l=()=>{o=0,c=s,n.style.setProperty(`--project-files-panel-width`,`${c}px`)},u=e=>{s=nn(i+(e.clientX-r)),o===0&&(o=window.requestAnimationFrame(l))},d=()=>{o!==0&&(window.cancelAnimationFrame(o),l());try{t.releasePointerCapture(a)}catch{}It(!1),Pt(c),an(c),window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d)};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},[Nt]);if((0,K.useEffect)(()=>{Q!==`files`&&Mt(null)},[e,Q]),vn)return(0,q.jsx)(`main`,{className:`w-full flex-1 px-3 py-3 text-sm text-fg-muted sm:px-5 sm:py-4 xl:px-6`,children:S.loading});if(!I)return(0,q.jsxs)(`main`,{className:`w-full flex-1 px-3 py-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,q.jsxs)(p,{to:`/projects`,className:`inline-flex items-center gap-2 text-sm text-accent-fg hover:underline`,children:[(0,q.jsx)(le,{className:`size-4`,"aria-hidden":!0}),S.backToProjects]}),(0,q.jsx)(`p`,{className:`mt-6 rounded-lg bg-surface-panel p-4 shadow-surface text-sm text-fg-muted`,children:cr||S.notFound})]});let ti=H?.recentSessions.length?H.recentSessions:I.recentSessions,ni=H?.attentionItems??[],ri=e=>S.statuses[e]??e,ii=e=>un(S.common.messages,{count:e}),ai=xe.trim().toLowerCase(),oi=ai?ve.filter(e=>{let t=dn(e.updatedAt),n=e.routing?.agentId||e.agentId||S.common.agent,r=e.name?.trim()||S.sessions.fallbackTitle,i=ii(e.messageCount??0);return[r,e.key,n,t,i].filter(Boolean).join(` `).toLowerCase().includes(ai)}):ve,si=ve.length>0&&oi.length===0,ci=en.find(e=>e.id===Z.defaultAgentId)?.name||Z.defaultAgentId||S.settings.globalDefaultAgent,li=en.find(e=>e.id===Z.defaultAgentId),ui=I.workspaceRoot?.trim()||``,di=I.status===`archived`,fi=!!I.pinnedAt,pi=!ui,mi=ui||li?.workspace||I.effectiveWorkspaceRoot||S.common.defaultWorkspace,hi=In===`fixed`?Rn.trim()||S.settings.workspacePlaceholder:li?.workspace||I.effectiveWorkspaceRoot||S.common.defaultWorkspace,gi=(In===`fixed`?Rn.trim():``)!==ui&&(In===`follow`||!!Rn.trim()),_i=pr.map(e=>{let t=Jt.find(t=>t.id===e);return{...t,label:t.id===`work-items`?S.workItems.tab:S.tabs[t.id]}});async function vi(){if(!mi)return;let e=await ue(mi);pe(e?`success`:`warning`,e?c.workspace.pathCopied:c.clipboard.copyFailed,void 0,{duration:e?2500:4e3})}function yi(){Nn(null),Fn(!0)}return(0,q.jsxs)(`main`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden px-3 py-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,q.jsx)(yt,{items:_i,activeTab:Q,onChange:_r,onReorder:Cr,ariaLabel:S.navAria,tabIdPrefix:`project-tab`,panelIdPrefix:`project-panel`,className:`shrink-0`}),cr?(0,q.jsx)(`p`,{className:`mt-3 shrink-0 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:cr}):null,(0,q.jsxs)(`div`,{className:i(`mt-3 min-h-0 flex-1`,Q===`work-items`?`-mx-3 -mb-3 overflow-hidden sm:-mx-5 sm:-mb-4 xl:-mx-6`:Q===`overview`?`overflow-y-auto pr-1 [scrollbar-gutter:stable] xl:overflow-hidden xl:pr-0`:`overflow-y-auto pr-1 [scrollbar-gutter:stable]`),children:[Q===`overview`?(0,q.jsxs)(`section`,{id:`project-panel-overview`,role:`tabpanel`,"aria-labelledby":`project-tab-overview`,className:`grid min-h-full gap-4 xl:h-full xl:min-h-0 xl:grid-cols-[minmax(0,1fr)_20rem] xl:overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`grid min-w-0 content-start gap-4 xl:min-h-0 xl:overflow-y-auto xl:pr-1 xl:[scrollbar-gutter:stable]`,children:[(0,q.jsx)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel p-4 shadow-surface`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:S.overview.directionTitle}),(0,q.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:H?.digest?.summary||H?.recommendedAction||I.description||I.brief||S.overview.directionFallback}),H?.digest?.nextAction?(0,q.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm font-medium leading-6 text-fg`,children:un(S.overview.recommendedNext,{action:H.digest.nextAction})}):null]}),(0,q.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:(0,q.jsxs)(h,{type:`button`,variant:`secondary`,onClick:()=>void Xr(),disabled:Dt,children:[(0,q.jsx)(Xe,{className:`size-4`,"aria-hidden":!0}),Dt?S.overview.savingDigest:S.overview.saveDigest]})})]})}),(0,q.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel shadow-surface`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:S.overview.nextActions}),(0,q.jsxs)(h,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,onClick:()=>sr(!0),children:[(0,q.jsx)(M,{className:`size-4`,"aria-hidden":!0}),S.overview.goal]})]}),(0,q.jsx)(`div`,{className:`divide-y divide-edge`,children:H?.nextActions.length?H.nextActions.map(e=>(0,q.jsxs)(p,{to:yr(e.goalId),onClick:xr(`goals`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,q.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,fn(e.status)),children:ri(e.status)})]}),(0,q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e.nextAction})]},e.goalId)):(0,q.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:S.overview.noNextActions})})]})]}),(0,q.jsxs)(`aside`,{className:`grid min-w-0 content-start gap-4 xl:min-h-0 xl:overflow-y-auto xl:pr-1 xl:[scrollbar-gutter:stable]`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:S.overview.attention}),ni.length?(0,q.jsx)(`div`,{className:`mt-3 grid gap-3`,children:ni.map(e=>{let t=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(Se,{className:`size-4 text-amber-600 dark:text-amber-300`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title})]}),(0,q.jsxs)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:[S.overview.attentionKinds[e.kind]??e.kind,e.detail?` · ${e.detail}`:e.status?` · ${ri(e.status)}`:``]})]});return e.href?(0,q.jsx)(p,{to:e.href,onClick:xr(Sr(e.href)),className:`min-w-0 rounded-md bg-surface-base p-3 hover:bg-surface-hover`,children:t},e.id):(0,q.jsx)(`div`,{className:`min-w-0 rounded-md bg-surface-base p-3`,children:t},e.id)})}):(0,q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:S.overview.noBlockedGoals}),(0,q.jsxs)(`form`,{onSubmit:Ir,className:`mt-4 flex gap-2 border-t border-edge pt-4`,children:[(0,q.jsx)(`input`,{className:`min-h-9 min-w-0 flex-1 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:dr.title,onChange:e=>fr(t=>({...t,title:e.target.value})),placeholder:S.overview.blockerTitlePlaceholder}),(0,q.jsx)(h,{type:`submit`,variant:`secondary`,className:`shrink-0 rounded-lg px-3`,disabled:ir||!dr.title.trim(),"aria-label":ir?S.overview.addingBlocker:S.overview.addBlocker,title:ir?S.overview.addingBlocker:S.overview.addBlocker,children:(0,q.jsx)(M,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,q.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel shadow-surface`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(L,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,q.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:S.overview.recentSessions})]}),(0,q.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>_r(`sessions`),children:S.common.viewAll})]}),(0,q.jsx)(`div`,{className:`divide-y divide-edge`,children:ti.length?ti.map(e=>(0,q.jsxs)(p,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:xr(`sessions`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.name||e.key}),(0,q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:dn(e.updatedAt)})]}),(0,q.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.agentId||S.common.agent})]},e.key)):(0,q.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:S.overview.noSessions})})]})]})]}):null,Q===`work-items`?(0,q.jsx)(qt,{projectId:I.id,createRequestKey:Kn}):null,Q===`workflows`?(0,q.jsxs)(`section`,{id:`project-panel-workflows`,role:`tabpanel`,"aria-labelledby":`project-tab-workflows`,className:`grid h-full min-h-[28rem] gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,q.jsx)(`div`,{className:`min-h-0`,children:(0,q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:S.workflows.runsTitle}),(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:S.workflows.runsHint})]}),(0,q.jsxs)(h,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:()=>void wr(),disabled:Jn,children:[(0,q.jsx)(ke,{className:`size-4`,"aria-hidden":!0}),S.common.refresh]})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 divide-y divide-edge overflow-y-auto`,children:Jn&&Pe.length===0?(0,q.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:S.workflows.loadingRuns}):Pe.length?Pe.map(e=>{let t=e.status===`queued`||e.status===`running`,n=e.status===`failed`||e.status===`timeout`||e.status===`cancelled`;return(0,q.jsxs)(`div`,{className:`grid gap-2 px-4 py-3 hover:bg-surface-hover`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`button`,{type:`button`,className:`min-w-0 truncate text-left text-sm font-medium text-fg hover:text-accent-fg`,onClick:()=>$(`workflows`,D(e.id,{ownerAgentId:Y||e.metadata?.agentId||I.defaultAgentId})),children:e.title||e.definitionId}),(0,q.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,pn(e.status)),children:ri(e.status)})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:un(S.workflows.runMeta,{definitionId:e.definitionId,done:e.metrics.doneAgentCount,total:e.metrics.agentCount,time:dn(e.createdAtMs)})}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(h,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,onClick:()=>$(`workflows`,D(e.id,{ownerAgentId:Y||e.metadata?.agentId||I.defaultAgentId})),children:S.common.open}),n?(0,q.jsxs)(h,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:Qn===`retry:${e.id}`,onClick:()=>void Rr(e),children:[(0,q.jsx)(ke,{className:`size-3.5`,"aria-hidden":!0}),S.common.retry]}):null,t?(0,q.jsxs)(h,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:Qn===`cancel:${e.id}`,onClick:()=>void zr(e),children:[(0,q.jsx)(ae,{className:`size-3.5`,"aria-hidden":!0}),S.common.cancel]}):null]})]})]},e.id)}):(0,q.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:S.workflows.emptyRuns})})]})}),(0,q.jsx)(`aside`,{className:`min-h-0`,children:(0,q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:[(0,q.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-4 py-3`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:S.workflows.startTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:S.workflows.startHint})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:(0,q.jsx)(`div`,{className:`grid gap-2`,children:Ae.length?Ae.map(e=>(0,q.jsxs)(`button`,{type:`button`,className:`grid gap-1 rounded-md bg-surface-base p-3 text-left hover:bg-surface-hover focus:outline-none focus:ring-2 focus:ring-accent/30`,onClick:()=>tr(e),children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,q.jsx)(ft,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}),(0,q.jsx)(`span`,{className:`line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description||e.metadata.whenToUse||e.name})]},e.id)):(0,q.jsx)(`div`,{className:`px-1 py-3 text-sm text-fg-muted`,children:S.workflows.emptyDefinitions})})})]})})]}):null,Q===`automations`?(0,q.jsxs)(`section`,{id:`project-panel-automations`,role:`tabpanel`,"aria-labelledby":`project-tab-automations`,className:`grid h-full min-h-[28rem] overflow-hidden gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:S.automations.title}),(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:S.automations.hint})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(h,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:()=>void Tr(),disabled:qe,children:[(0,q.jsx)(ke,{className:`size-4`,"aria-hidden":!0}),S.common.refresh]}),(0,q.jsxs)(h,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>$(`automations`,`/automations?projectId=${encodeURIComponent(I.id)}&action=create`),children:[(0,q.jsx)(M,{className:`size-4`,"aria-hidden":!0}),S.common.new]})]})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 divide-y divide-edge overflow-y-auto`,children:qe&&W.length===0?(0,q.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:S.automations.loading}):W.length?W.map(e=>{let t=He.find(t=>t.automationId===e.id),n=e.state.runningRunId?He.find(t=>t.id===e.state.runningRunId):null;return(0,q.jsxs)(`div`,{className:`grid gap-2 px-4 py-3 hover:bg-surface-hover`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`button`,{type:`button`,className:`min-w-0 truncate text-left text-sm font-medium text-fg hover:text-accent-fg`,onClick:()=>$(`automations`,`/automations?automation=${encodeURIComponent(e.id)}`),children:e.name}),(0,q.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,e.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`),children:e.enabled?S.automations.enabled:S.automations.paused})]}),(0,q.jsx)(`p`,{className:`line-clamp-2 text-sm leading-5 text-fg-muted`,children:e.description||e.action.kind}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:un(S.common.lastRun,{trigger:e.trigger.kind,action:e.action.kind,time:t?dn(t.createdAtMs):S.common.never})}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsxs)(h,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:$e===`run:${e.id}`||!!n,onClick:()=>void Dr(e),children:[(0,q.jsx)(ft,{className:`size-3.5`,"aria-hidden":!0}),S.automations.run]}),(0,q.jsxs)(h,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:$e===`toggle:${e.id}`,onClick:()=>void Or(e),children:[e.enabled?(0,q.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}):(0,q.jsx)(ft,{className:`size-3.5`,"aria-hidden":!0}),e.enabled?S.automations.pause:S.automations.resume]})]})]})]},e.id)}):(0,q.jsxs)(`div`,{className:`grid gap-3 px-4 py-6 text-sm text-fg-muted`,children:[(0,q.jsx)(`p`,{children:S.automations.empty}),(0,q.jsx)(`div`,{children:(0,q.jsxs)(h,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:()=>$(`automations`,`/automations?projectId=${encodeURIComponent(I.id)}&action=create`),children:[(0,q.jsx)(k,{className:`size-4`,"aria-hidden":!0}),S.automations.create]})})]})})]}),(0,q.jsxs)(`aside`,{className:`grid min-h-0 min-w-0 content-start gap-4 overflow-y-auto pr-1 [scrollbar-gutter:stable]`,children:[(0,q.jsxs)(`div`,{className:`rounded-lg bg-surface-panel shadow-surface`,children:[(0,q.jsx)(`div`,{className:`border-b border-edge px-4 py-3`,children:(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:S.automations.recentRuns})}),(0,q.jsx)(`div`,{className:`divide-y divide-edge`,children:He.length?He.slice(0,8).map(e=>(0,q.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.automationName}),(0,q.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,pn(e.status)),children:ri(e.status)})]}),(0,q.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:dn(e.createdAtMs)})]},e.id)):(0,q.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:S.automations.emptyRuns})})]}),(0,q.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:S.automations.contextTitle}),(0,q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:S.automations.contextHint}),(0,q.jsx)(`p`,{className:`mt-3 break-all text-xs text-fg-subtle`,children:I.workspaceRoot||I.effectiveWorkspaceRoot||S.common.defaultWorkspace})]})]})]}):null,Q===`notes`?(0,q.jsx)(`section`,{id:`project-panel-notes`,role:`tabpanel`,"aria-labelledby":`project-tab-notes`,className:`flex h-full min-h-[28rem] overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:(0,q.jsx)(vt,{selectedNoteId:n,basePath:`/projects/${encodeURIComponent(I.id)}/notes`,showLibrary:!1,allowMediaCapture:!1,listTag:`project:${I.id}`,captureTags:[`project:${I.id}`,I.slug],listTitle:S.notes.title,listDescription:S.notes.hint,emptyText:S.notes.emptyTitle,emptyDescription:S.notes.emptyDescription,listWidthStorageKey:`xopc.projectNotes.listWidth.${I.id}`})}):null,Q===`files`?(0,q.jsx)(`section`,{id:`project-panel-files`,role:`tabpanel`,"aria-labelledby":`project-tab-files`,className:`h-full min-h-[28rem]`,children:(0,q.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:I.effectiveWorkspaceRoot?(0,q.jsxs)(`div`,{"data-project-files-grid":!0,className:i(`grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[var(--project-files-panel-width)_6px_minmax(0,1fr)]`,Ft&&`cursor-col-resize select-none`),style:{"--project-files-panel-width":`${Nt}px`},children:[(0,q.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-b border-edge lg:border-b-0 lg:border-r`,children:[(0,q.jsxs)(`div`,{className:`flex h-11 items-center gap-1 border-b border-edge bg-surface-muted/50 px-3 text-sm`,children:[(0,q.jsx)(z,{workspacePath:mi}),(0,q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,className:i(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,Lt&&`bg-surface-hover text-fg`),onClick:()=>Rt(!0),"aria-label":S.files.search,title:S.files.search,"aria-pressed":Lt,children:(0,q.jsx)(lt,{className:`size-3.5`,"aria-hidden":!0})}),(0,q.jsx)(ht,{className:`size-7 shrink-0 rounded-md p-0`,loading:Xt,label:c.cron.refresh,onClick:()=>void kr()})]})]}),Lt?(0,q.jsx)(`div`,{className:`shrink-0 border-b border-edge bg-surface-muted/40 px-3 py-2`,children:(0,q.jsxs)(`div`,{className:`flex h-8 items-center gap-2 rounded-md border border-edge bg-surface-panel px-2 focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/20`,children:[(0,q.jsx)(lt,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,q.jsx)(`input`,{type:`text`,role:`searchbox`,value:zt,onChange:e=>Bt(e.target.value),placeholder:S.files.searchPlaceholder,"aria-label":S.files.searchPlaceholder,autoFocus:!0,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none placeholder:text-fg-subtle`}),(0,q.jsx)(`button`,{type:`button`,className:`flex size-6 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":S.files.clearSearch,title:S.files.clearSearch,onClick:()=>{Bt(``),Rt(!1)},children:(0,q.jsx)(Ie,{className:`size-3.5`,"aria-hidden":!0})})]})}):null,Qt?(0,q.jsx)(`div`,{className:`border-b border-edge bg-red-500/10 px-4 py-3 text-sm text-red-700 dark:text-red-300`,children:Qt}):null,jr?(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:Ut?(0,q.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,q.jsx)(se,{className:`h-11 w-full`}),(0,q.jsx)(se,{className:`h-11 w-full`}),(0,q.jsx)(se,{className:`h-11 w-full`})]}):Gt?(0,q.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[c.workspace.loadError,`: `,Gt]}):Vt.length===0?(0,q.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:S.files.noSearchResults}):Vt.map(e=>(0,q.jsxs)(`button`,{type:`button`,className:i(`flex w-full min-w-0 items-center gap-2 px-3 py-2 text-left hover:bg-surface-hover`,jt===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>Mt(e.path),title:e.path,children:[(0,q.jsx)(dt,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.name}),(0,q.jsx)(`span`,{className:`block truncate text-xs text-fg-subtle`,children:e.path})]})]},e.path))}):Xt&&kt.length===0?(0,q.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:S.files.loading}):(0,q.jsx)(ut,{tree:kt,selectedPath:jt,onSelectFile:Zr,onSelectEntry:Qr,onExpandDir:e=>void Ar(e),onAction:$r,actionLabels:{preview:c.workspace.preview,download:c.workspace.download,copyPath:c.workspace.copyPath,openDefault:c.workspace.openSystemApp,openWith:c.workspace.openWith,revealInFolder:c.workspace.revealInFolder,recommendedApps:c.workspace.recommendedApps},emptyHint:S.files.emptyDirectory})]}),(0,q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":S.files.resizeHandle,className:i(`hidden cursor-col-resize touch-none items-stretch justify-center bg-surface-panel transition-colors hover:bg-surface-hover lg:flex`,Ft&&`bg-surface-hover`),onPointerDown:ei,children:(0,q.jsx)(`div`,{className:`my-3 w-px rounded-full bg-edge-strong/70`})}),(0,q.jsx)(`div`,{className:`min-h-0 min-w-0 overflow-hidden bg-surface-base`,children:jt?(0,q.jsx)(he,{filePath:jt,projectId:I.id,onClose:()=>Mt(null)}):(0,q.jsx)(`div`,{className:`flex h-full min-h-[18rem] items-center justify-center px-6 text-center`,children:(0,q.jsxs)(`div`,{className:`max-w-sm`,children:[(0,q.jsx)(U,{className:`mx-auto size-8 text-fg-subtle`,"aria-hidden":!0}),(0,q.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:S.files.previewEmptyTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:S.files.previewEmptyDescription})]})})})]}):(0,q.jsxs)(`div`,{className:`grid gap-3 px-4 py-8 text-sm text-fg-muted`,children:[(0,q.jsx)(`p`,{children:S.files.needWorkspace}),(0,q.jsx)(`div`,{children:(0,q.jsx)(h,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:()=>_r(`settings`),children:S.files.openSettings})})]})})}):null,Q===`sessions`?(0,q.jsxs)(`section`,{id:`project-panel-sessions`,role:`tabpanel`,"aria-labelledby":`project-tab-sessions`,className:`grid min-h-full content-start gap-3`,children:[ve.length?(0,q.jsxs)(`label`,{className:`relative flex min-h-9 w-full max-w-lg cursor-text items-center rounded-lg bg-surface-panel py-1.5 pl-9 pr-9 shadow-surface`,children:[(0,q.jsx)(lt,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,"aria-hidden":!0}),(0,q.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:xe,onChange:e=>Ce(e.currentTarget.value),placeholder:S.sessions.searchPlaceholder,"aria-label":S.sessions.searchPlaceholder,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),xe?(0,q.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":S.sessions.clearSearch,onClick:()=>Ce(``),children:(0,q.jsx)(Ie,{className:`size-3.5`,"aria-hidden":!0})}):null]}):null,oi.length?(0,q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:oi.map(e=>{let t=dn(e.updatedAt),n=e.routing?.agentId||e.agentId||S.common.agent,r=e.name?.trim()||S.sessions.fallbackTitle,i=ii(e.messageCount??0);return(0,q.jsxs)(p,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:xr(`sessions`),className:`group flex min-h-[11rem] min-w-0 flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,q.jsx)(`span`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-base text-fg-muted`,children:(0,q.jsx)(B,{className:`size-4`,"aria-hidden":!0})}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:r}),(0,q.jsx)(`p`,{className:`mt-1 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-muted`,title:e.key,children:e.key})]})]}),(0,q.jsxs)(`div`,{className:`mt-auto grid gap-2 pt-4 text-xs text-fg-muted`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:`min-w-0 max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[S.sessions.agent,`: `,n]}),(0,q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:i})]}),t?(0,q.jsxs)(`span`,{className:`truncate rounded-md bg-surface-base px-2 py-1`,children:[S.sessions.updated,`: `,t]}):null]})]},e.key)})}):si?(0,q.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:S.sessions.noMatches})}):(0,q.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:S.sessions.emptyTitle}),(0,q.jsx)(`p`,{className:`mx-auto mt-1 max-w-md text-sm leading-6 text-fg-muted`,children:S.sessions.emptyDescription})]})})]}):null,Q===`goals`?(0,q.jsxs)(`section`,{id:`project-panel-goals`,role:`tabpanel`,"aria-labelledby":`project-tab-goals`,className:`grid min-h-full content-start gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`div`,{children:(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:S.goals.title})}),(0,q.jsxs)(h,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3`,disabled:nr,onClick:()=>sr(!0),children:[(0,q.jsx)(M,{className:`size-4`,"aria-hidden":!0}),S.goals.new]})]}),(0,q.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:we.length?we.map(e=>(0,q.jsxs)(p,{to:yr(e.id),onClick:xr(`goals`),className:`grid gap-1 border-b border-edge px-4 py-3 last:border-b-0 hover:bg-surface-hover`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,q.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,fn(e.status)),children:ri(e.status)})]}),(0,q.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:e.nextAction||e.description||S.goals.noNextAction})]},e.id)):(0,q.jsx)(`p`,{className:`p-4 text-sm text-fg-muted`,children:S.goals.empty})})]}):null,Q===`activity`?(0,q.jsxs)(`section`,{id:`project-panel-activity`,role:`tabpanel`,"aria-labelledby":`project-tab-activity`,className:`grid min-h-full content-start gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:S.activity.title}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:un(S.activity.count,{count:at})})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`label`,{className:`inline-flex min-h-9 items-center gap-2 rounded-lg bg-surface-panel px-3 text-sm text-fg-muted shadow-surface`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:Tt,onChange:e=>Et(e.currentTarget.checked),className:`size-4 rounded border-edge text-accent focus:ring-accent/30`}),S.activity.includeRelated]}),(0,q.jsxs)(h,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3`,onClick:()=>void Er(),disabled:ct,children:[(0,q.jsx)(ke,{className:i(`size-4`,ct&&`animate-spin`),"aria-hidden":!0}),S.common.refresh]})]})]}),(0,q.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:ct&&nt.length===0?(0,q.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:S.activity.loading}):nt.length?(0,q.jsx)(`div`,{className:`divide-y divide-edge`,children:nt.map(e=>{let t=S.activity.types[e.type]??e.type,n=S.activity.objectKinds[e.primaryObject.kind]??e.primaryObject.kind,r=Cn(e),i=e.relatedProjects.length>0&&!e.scopes.some(e=>e.scopeKind===`project`&&e.scopeId===I.id);return(0,q.jsxs)(`article`,{className:`grid gap-2 px-4 py-3`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:t}),i?(0,q.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-xs font-medium text-fg-muted`,children:S.activity.related}):null]}),(0,q.jsxs)(`p`,{className:`mt-1 min-w-0 truncate text-sm text-fg-muted`,children:[n,`: `,xn(e)]})]}),(0,q.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,dateTime:new Date(e.createdAt).toISOString(),children:dn(e.createdAt)})]}),r?(0,q.jsx)(`p`,{className:`line-clamp-2 text-sm leading-5 text-fg-muted`,children:r}):null,(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[S.activity.actor,`: `,bn(e)]}),(0,q.jsxs)(`span`,{className:`max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[S.activity.source,`: `,Sn(e)]})]})]},e.id)})}):(0,q.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:S.activity.empty})})]}):null,Q===`settings`?(0,q.jsxs)(`form`,{id:`project-panel-settings`,role:`tabpanel`,"aria-labelledby":`project-tab-settings`,onSubmit:Wr,className:`grid min-h-full content-start gap-4`,children:[(0,q.jsxs)(`section`,{className:`grid gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:S.settings.contextTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:S.settings.contextHint})]}),(0,q.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,fn(Z.status)),children:S.settings.statuses[Z.status]})]}),(0,q.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-5`,children:[(0,q.jsx)(gn,{label:S.settings.workspaceRoot,value:mi,mono:!0}),(0,q.jsx)(gn,{label:S.settings.defaultAgent,value:ci}),(0,q.jsx)(gn,{label:S.settings.pinState,value:fi?S.settings.pinned:S.settings.notPinned}),(0,q.jsx)(gn,{label:S.settings.createdAt,value:dn(I.createdAt)||S.common.never}),(0,q.jsx)(gn,{label:S.settings.updatedAt,value:dn(I.updatedAt)||S.common.never})]})]}),(0,q.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,q.jsx)(`div`,{children:(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:S.settings.detailsTitle})}),(0,q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,q.jsx)(mn,{label:S.settings.name,children:(0,q.jsx)(`input`,{className:hn(),value:Z.name,onChange:e=>hr(t=>({...t,name:e.target.value}))})}),(0,q.jsx)(mn,{label:S.settings.defaultAgent,children:(0,q.jsxs)(Ue,{className:hn(),value:Z.defaultAgentId,onChange:e=>hr(t=>({...t,defaultAgentId:e.target.value})),children:[(0,q.jsx)(Ne,{value:``,children:S.settings.globalDefaultAgent}),en.map(e=>(0,q.jsx)(Ne,{value:e.id,children:e.name||e.id},e.id))]})}),(0,q.jsx)(mn,{label:S.settings.status,children:di?(0,q.jsx)(`div`,{className:`grid min-h-10 content-center rounded-md border border-edge bg-surface-muted px-3 text-sm text-fg-muted`,children:S.settings.statuses.archived}):(0,q.jsxs)(Ue,{className:hn(),value:Z.status===`archived`?`active`:Z.status,onChange:e=>hr(t=>({...t,status:e.target.value})),children:[(0,q.jsx)(Ne,{value:`active`,children:S.settings.statuses.active}),(0,q.jsx)(Ne,{value:`paused`,children:S.settings.statuses.paused})]})}),(0,q.jsx)(mn,{label:S.settings.description,hint:S.settings.descriptionHint,children:(0,q.jsx)(`textarea`,{className:hn(!0),value:Z.description,onChange:e=>hr(t=>({...t,description:e.target.value}))})})]})]}),(0,q.jsx)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:(0,q.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:S.settings.workspaceRoot}),(0,q.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base px-3 py-3`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,q.jsx)(`span`,{className:`rounded-md bg-surface-muted px-2 py-0.5 text-xs font-medium text-fg-muted`,children:pi?S.settings.workspaceModeFollow:S.settings.workspaceModeFixed})}),(0,q.jsx)(`div`,{className:`mt-2 break-all font-mono text-xs leading-5 text-fg`,title:mi,children:mi})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,q.jsxs)(h,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:()=>void vi(),children:[(0,q.jsx)(y,{className:`size-4`,"aria-hidden":!0}),S.settings.copyWorkspacePath]}),(0,q.jsx)(z,{workspacePath:mi}),(0,q.jsxs)(h,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:Gr,children:[(0,q.jsx)(pt,{className:`size-4`,"aria-hidden":!0}),S.settings.migrateWorkspace]})]})]}),(0,q.jsx)(`p`,{className:`text-xs leading-5 text-fg-subtle`,children:S.settings.workspaceMigrationHint})]})]})}),(0,q.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:S.settings.agentContextTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:S.settings.agentContextHint})]}),(0,q.jsx)(mn,{label:S.settings.brief,hint:S.settings.briefHint,children:(0,q.jsx)(`textarea`,{className:hn(!0),value:Z.brief,onChange:e=>hr(t=>({...t,brief:e.target.value}))})}),(0,q.jsx)(mn,{label:S.settings.instructions,hint:S.settings.instructionsHint,children:(0,q.jsx)(`textarea`,{className:hn(!0),value:Z.instructions,onChange:e=>hr(t=>({...t,instructions:e.target.value}))})})]}),(0,q.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:S.settings.managementTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:S.settings.managementHint})]}),(0,q.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,q.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base px-3 py-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:fi?S.settings.pinnedTitle:S.settings.pinTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:S.settings.pinHint})]}),(0,q.jsxs)(h,{type:`button`,variant:`ghost`,className:`w-fit rounded-lg`,disabled:Bn===`pin`,onClick:()=>void qr(),children:[fi?(0,q.jsx)(v,{className:`size-4`,"aria-hidden":!0}):(0,q.jsx)(g,{className:`size-4`,"aria-hidden":!0}),fi?S.settings.unpinProject:S.settings.pinProject]})]}),(0,q.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base px-3 py-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:di?S.settings.restoreTitle:S.settings.archiveTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:di?S.settings.restoreHint:S.settings.archiveHint})]}),(0,q.jsxs)(h,{type:`button`,variant:di?`primary`:`ghost`,className:`w-fit rounded-lg`,disabled:Bn===`archive`,onClick:()=>void Jr(),children:[di?(0,q.jsx)(ke,{className:`size-4`,"aria-hidden":!0}):(0,q.jsx)(me,{className:`size-4`,"aria-hidden":!0}),di?S.settings.restoreProject:S.settings.archiveProject]})]})]})]}),(0,q.jsxs)(`section`,{className:`grid gap-3 rounded-lg border border-red-500/20 bg-red-500/5 p-4`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-red-700 dark:text-red-300`,children:S.settings.dangerTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-red-700/80 dark:text-red-200/80`,children:S.settings.dangerHint})]}),(0,q.jsxs)(h,{type:`button`,variant:`ghost`,className:`w-fit text-red-600 hover:bg-red-500/10 hover:text-red-700 focus-visible:ring-red-500 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>jn(!0),children:[(0,q.jsx)(R,{className:`size-4`,"aria-hidden":!0}),S.settings.deleteConfirmAction]})]}),(0,q.jsx)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-edge pt-4`,children:(0,q.jsxs)(h,{type:`submit`,variant:`primary`,disabled:On||!Z.name.trim(),children:[(0,q.jsx)(Xe,{className:`size-4`,"aria-hidden":!0}),S.common.save]})})]}):null]}),(0,q.jsx)(b,{open:An,onOpenChange:e=>{Hn||jn(e)},children:(0,q.jsxs)(te,{children:[(0,q.jsx)(F,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,q.jsxs)(ee,{className:`fixed left-1/2 top-1/2 z-[90] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-5 shadow-float focus:outline-none`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,q.jsx)(`span`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-red-500/10 text-red-600 dark:text-red-400`,children:(0,q.jsx)(Se,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(T,{className:`text-base font-semibold text-fg`,children:S.settings.deleteConfirmTitle}),(0,q.jsx)(C,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:I?un(S.settings.deleteConfirm,{name:I.name}):S.settings.deleteConfirmFallback})]})]}),(0,q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,q.jsx)(f,{asChild:!0,children:(0,q.jsx)(h,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:Hn,children:S.common.cancel})}),(0,q.jsxs)(h,{type:`button`,variant:`ghost`,className:`rounded-lg text-red-600 hover:bg-red-500/10 hover:text-red-700 focus-visible:ring-red-500 dark:text-red-400 dark:hover:text-red-300`,disabled:Hn||!I,onClick:()=>void Yr(),children:[(0,q.jsx)(R,{className:`size-4`,"aria-hidden":!0}),S.settings.deleteConfirmAction]})]})]})]})}),(0,q.jsx)(b,{open:Pn,onOpenChange:e=>{On||Fn(e)},children:(0,q.jsxs)(te,{children:[(0,q.jsx)(F,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,q.jsxs)(ee,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(34rem,calc(100vh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,q.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,q.jsx)(T,{className:`text-base font-semibold text-fg`,children:S.settings.workspaceMigrationTitle}),(0,q.jsx)(C,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:S.settings.workspaceMigrationDescription})]}),(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,q.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:S.settings.workspaceMode}),(0,q.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,q.jsxs)(`label`,{className:i(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,In===`fixed`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,q.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:In===`fixed`,onChange:()=>Ln(`fixed`),disabled:On}),(0,q.jsxs)(`span`,{className:`min-w-0`,children:[(0,q.jsx)(`span`,{className:`block font-medium`,children:S.settings.workspaceModeFixed}),(0,q.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:S.settings.workspaceMigrationFixedHint})]})]}),(0,q.jsxs)(`label`,{className:i(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,In===`follow`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,q.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:In===`follow`,onChange:()=>Ln(`follow`),disabled:On}),(0,q.jsxs)(`span`,{className:`min-w-0`,children:[(0,q.jsx)(`span`,{className:`block font-medium`,children:S.settings.workspaceModeFollow}),(0,q.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:S.settings.workspaceHint})]})]})]})]}),In===`fixed`?(0,q.jsx)(bt,{value:Rn,onChange:zn,disabled:On,wd:u,placeholder:S.settings.workspacePlaceholder,inputClassName:hn(),autoFocus:!0}):null,(0,q.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm leading-6 text-amber-800 dark:text-amber-200`,children:S.settings.workspaceMigrationImpact}),(0,q.jsx)(`div`,{className:`rounded-lg bg-surface-muted px-3 py-2 text-xs leading-5 text-fg-subtle`,children:un(S.settings.workspaceCurrent,{workspace:hi})})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,q.jsx)(f,{asChild:!0,children:(0,q.jsx)(h,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:On,children:S.common.cancel})}),(0,q.jsxs)(h,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:On||!gi,onClick:()=>void Kr(),children:[(0,q.jsx)(pt,{className:`size-4`,"aria-hidden":!0}),S.settings.workspaceMigrationConfirm]})]})]})]})}),(0,q.jsx)(b,{open:!!Mn,onOpenChange:e=>{e||Nn(null)},children:(0,q.jsxs)(te,{children:[(0,q.jsx)(F,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,q.jsxs)(ee,{className:`fixed left-1/2 top-1/2 z-[90] flex w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,q.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,q.jsx)(T,{className:`text-base font-semibold text-fg`,children:S.settings.workspaceMissingTitle}),(0,q.jsx)(C,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:Mn?un(S.settings.workspaceMissingDescription,{workspace:Mn}):null})]}),Mn?(0,q.jsx)(`div`,{className:`px-5 py-4`,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,q.jsx)(U,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`min-w-0 truncate`,children:Mn})]})}):null,(0,q.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,q.jsx)(h,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:yi,disabled:On,children:S.settings.workspaceMissingBack}),(0,q.jsxs)(h,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:()=>void Kr({createWorkspaceRoot:!0}),disabled:On,children:[(0,q.jsx)(pt,{className:`size-4`,"aria-hidden":!0}),S.settings.workspaceMissingCreate]})]})]})]})}),(0,q.jsx)(Ct,{open:or,t:c.goalsPage,chat:c.chat,busy:nr,options:lr,onClose:()=>!nr&&sr(!1),onCreate:Fr}),(0,q.jsx)(wt,{open:!!er,definition:er,language:s,starting:Xn,onClose:()=>!Xn&&tr(null),onStart:e=>void Lr(e)})]})}export{Dn as ProjectDetailPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-YzjnURPJ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{Ba as s,Cc as c,Cl as l,Do as u,El as d,Ga as f,Ha as p,Ka as m,Ss as h,Ua as g,Ui as _,Va as v,Wa as y,ea as b,gl as x,io as S,no as ee,nr as te,qa as ne,ta as re,us as ie,xc as ae}from"./index-C4k6QSXw.js";import{t as oe}from"./directory-picker-path-field-8p1ehIHn.js";var C=n(),w=e(t(),1),T=r(),se=[`all`,`active`,`paused`,`archived`],E=`__auto__`,D=`__global__`;function O(e){return e===`active`?`bg-accent-soft text-accent-fg`:e===`paused`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-muted text-fg-subtle`}function k(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function ce(e){return e.trim().replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??``}function le(e){let t=e?.body;return t?.code===`workspace_already_bound`&&t.project?t.project:null}function ue(e){let t=e?.body;return t?.code===`workspace_root_missing`&&t.workspaceRoot?t.workspaceRoot:null}function A(e,t){if(!e)return t;let n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(n)}function de(e){let t=(0,C.c)(37),{project:n,t:r}=e,a=r.statuses[n.status],o=`/projects/${encodeURIComponent(n.id)}`,s;t[0]===n.name?s=t[1]:(s=(0,T.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.name}),t[0]=n.name,t[1]=s);let c;t[2]===n.slug?c=t[3]:(c=(0,T.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.slug}),t[2]=n.slug,t[3]=c);let u;t[4]!==s||t[5]!==c?(u=(0,T.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=u):u=t[6];let d;t[7]===n.status?d=t[8]:(d=i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,O(n.status)),t[7]=n.status,t[8]=d);let f;t[9]!==a||t[10]!==d?(f=(0,T.jsx)(`span`,{className:d,children:a}),t[9]=a,t[10]=d,t[11]=f):f=t[11];let p;t[12]!==u||t[13]!==f?(p=(0,T.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[u,f]}),t[12]=u,t[13]=f,t[14]=p):p=t[14];let m=n.description||n.brief||r.noDescription,h;t[15]===m?h=t[16]:(h=(0,T.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-10 text-sm leading-5 text-fg-muted`,children:m}),t[15]=m,t[16]=h);let g=n.workspaceRoot||n.effectiveWorkspaceRoot||r.agentDefault,_;t[17]!==r.workspaceLabel||t[18]!==g?(_=k(r.workspaceLabel,{workspace:g}),t[17]=r.workspaceLabel,t[18]=g,t[19]=_):_=t[19];let v;t[20]===_?v=t[21]:(v=(0,T.jsx)(`div`,{className:`truncate`,children:_}),t[20]=_,t[21]=v);let y;t[22]!==n.lastActiveAt||t[23]!==n.updatedAt||t[24]!==r.lastActive||t[25]!==r.never?(y=k(r.lastActive,{time:A(n.lastActiveAt??n.updatedAt,r.never)}),t[22]=n.lastActiveAt,t[23]=n.updatedAt,t[24]=r.lastActive,t[25]=r.never,t[26]=y):y=t[26];let b;t[27]===y?b=t[28]:(b=(0,T.jsx)(`div`,{children:y}),t[27]=y,t[28]=b);let x;t[29]!==v||t[30]!==b?(x=(0,T.jsxs)(`div`,{className:`mt-auto grid gap-1 pt-4 text-xs text-fg-subtle`,children:[v,b]}),t[29]=v,t[30]=b,t[31]=x):x=t[31];let S;return t[32]!==o||t[33]!==x||t[34]!==p||t[35]!==h?(S=(0,T.jsxs)(l,{to:o,className:`group flex min-h-36 flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[p,h,x]}),t[32]=o,t[33]=x,t[34]=p,t[35]=h,t[36]=S):S=t[36],S}function j(){let e=d(),t=a(o(e=>e.language)),n=t.chat.workingDirectory,r=t.projectsPage,l=ne(e=>e.setPageHeader),C=ne(e=>e.clearPageHeader),[O,A]=(0,w.useState)([]),[j,fe]=(0,w.useState)(`all`),[M,pe]=(0,w.useState)(``),[me,he]=(0,w.useState)(!0),[ge,N]=(0,w.useState)(null),[P,F]=(0,w.useState)(``),[_e,ve]=(0,w.useState)(!1),[I,ye]=(0,w.useState)(``),[L,R]=(0,w.useState)(`fixed`),[z,be]=(0,w.useState)(`auto`),[B,xe]=(0,w.useState)(E),[V,Se]=(0,w.useState)([]),[H,Ce]=(0,w.useState)(),[U,we]=(0,w.useState)(),[W,Te]=(0,w.useState)(`unknown`),[G,K]=(0,w.useState)(!1),[q,Ee]=(0,w.useState)(!1),[J,Y]=(0,w.useState)(null),[X,Z]=(0,w.useState)(null),De=(0,w.useCallback)(e=>{F(e),ve(!!e.trim())},[]),Oe=(0,w.useCallback)(e=>{ye(e),_e||F(ce(e))},[_e]);(0,w.useEffect)(()=>{let e=!1;return he(!0),N(null),b({...j===`all`?{}:{status:j},...M.trim()?{search:M}:{},limit:100}).then(t=>{e||A(t.items)}).catch(t=>{e||N(t instanceof Error?t.message:String(t))}).finally(()=>{e||he(!1)}),()=>{e=!0}},[M,j]),(0,w.useEffect)(()=>{if(!G)return;let e=!1;return te().then(t=>{e||(Se(t.agents),Ce(t.defaultId))}).catch(()=>{e||(Se([]),Ce(void 0))}),()=>{e=!0}},[G]),(0,w.useEffect)(()=>{if(!G)return;let e=!1,t=window.setTimeout(()=>{re({...P.trim()?{name:P.trim()}:{},...L===`fixed`&&I.trim()?{workspaceRoot:I.trim()}:{},projectKind:z}).then(t=>{e||(we(t.defaultAgentId),Te(t.inference.kind))}).catch(()=>{e||(we(void 0),Te(`unknown`))})},250);return()=>{e=!0,window.clearTimeout(t)}},[G,P,z,L,I]);let Q=(0,w.useMemo)(()=>({active:O.filter(e=>e.status===`active`),paused:O.filter(e=>e.status===`paused`),archived:O.filter(e=>e.status===`archived`)}),[O]),$=(0,w.useCallback)(async(e={})=>{let t=P.trim(),n=L===`fixed`?I.trim():``;if(!(!t&&!n)){Ee(!0),N(null),Z(null);try{let r=await _({...t?{name:t}:{},...n?{workspaceRoot:n}:{},projectKind:z,...B===E?{}:{defaultAgentId:B===D?``:B},...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}});A(e=>[r,...e]),F(``),ve(!1),ye(``),R(`fixed`),be(`auto`),xe(E),K(!1)}catch(e){let t=le(e);if(t)A(e=>[t,...e.filter(e=>e.id!==t.id)]),Y(t),K(!1);else{let t=ue(e);t?(Z(t),K(!1)):N(e instanceof Error?e.message:String(e))}}finally{Ee(!1)}}},[B,P,z,L,I]),ke=(0,w.useCallback)(e=>{e.preventDefault(),$()},[$]),Ae=(0,w.useCallback)(()=>{if(!J)return;let t=J.id;Y(null),e(`/projects/${encodeURIComponent(t)}`)},[e,J]),je=(0,w.useCallback)(()=>{Y(null),K(!0)},[]),Me=(0,w.useCallback)(()=>{$({createWorkspaceRoot:!0})},[$]),Ne=(0,w.useCallback)(()=>{Z(null),K(!0)},[]),Pe=(0,w.useMemo)(()=>V.find(e=>e.id===U)?.name||U||``,[V,U]),Fe=(0,w.useMemo)(()=>B===D?H:B===E?U||H:B,[B,H,U]),Ie=(0,w.useMemo)(()=>V.find(e=>e.id===Fe),[V,Fe]),Le=L===`fixed`?I.trim()||r.workspacePlaceholder:Ie?.workspace||r.workspacePlaceholder,Re=(0,w.useMemo)(()=>{if(B===D)return r.agentHintGlobal;if(B!==E){let e=V.find(e=>e.id===B);return k(r.agentHintSelected,{agent:e?.name||B})}return U?k(r.agentHintCoding,{agent:Pe}):W===`coding`?r.agentHintCoderUnavailable:z===`general`||W===`general`?r.agentHintGeneral:r.agentHintAuto},[B,V,Pe,U,W,z,r]),ze=(0,w.useMemo)(()=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`label`,{className:`relative block min-w-0`,children:[(0,T.jsx)(ie,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,T.jsx)(`input`,{className:`h-9 w-40 rounded-lg border border-edge bg-surface-muted pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent sm:w-56 lg:w-72`,value:M,onChange:e=>pe(e.target.value),placeholder:r.searchPlaceholder,"aria-label":r.searchPlaceholder})]}),(0,T.jsxs)(u,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>K(e=>!e),children:[(0,T.jsx)(h,{className:`size-4`,"aria-hidden":!0}),r.create]})]}),[M,r.create,r.searchPlaceholder]);(0,w.useLayoutEffect)(()=>(l({startExtra:null,main:(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r.title}),(0,T.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:k(r.summary,{count:O.length})})]}),end:ze}),()=>C()),[C,ze,O.length,l,r.summary,r.title]);let Be=j===`all`?[[r.statuses.active,Q.active],[r.statuses.paused,Q.paused],[r.statuses.archived,Q.archived]]:[[r.statuses[j],O]];return(0,T.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,T.jsx)(f,{open:G,onOpenChange:K,children:(0,T.jsxs)(y,{children:[(0,T.jsx)(g,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,T.jsxs)(v,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(32rem,calc(100vh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,T.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,T.jsx)(m,{className:`text-base font-semibold text-fg`,children:r.createTitle}),(0,T.jsx)(p,{className:`mt-1 text-sm text-fg-muted`,children:r.createDescription})]}),(0,T.jsxs)(`form`,{onSubmit:ke,className:`flex min-h-0 flex-1 flex-col`,children:[(0,T.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,T.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,T.jsx)(`span`,{className:`font-medium text-fg-muted`,children:r.workspaceRoot}),(0,T.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,T.jsxs)(`label`,{className:i(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2 text-sm`,L===`fixed`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,T.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:L===`fixed`,onChange:()=>R(`fixed`),disabled:q}),(0,T.jsxs)(`span`,{className:`min-w-0`,children:[(0,T.jsx)(`span`,{className:`block font-medium`,children:r.workspaceModeFixed}),(0,T.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:r.workspaceFixedHint})]})]}),(0,T.jsxs)(`label`,{className:i(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2 text-sm`,L===`follow`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,T.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:L===`follow`,onChange:()=>R(`follow`),disabled:q}),(0,T.jsxs)(`span`,{className:`min-w-0`,children:[(0,T.jsx)(`span`,{className:`block font-medium`,children:r.workspaceModeFollow}),(0,T.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:r.workspaceFollowHint})]})]})]}),L===`fixed`?(0,T.jsx)(oe,{value:I,onChange:Oe,disabled:q,wd:n,placeholder:r.workspacePlaceholder,inputClassName:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,autoFocus:!0}):null,(0,T.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:k(r.workspaceCurrent,{workspace:Le})})]}),(0,T.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,T.jsx)(`span`,{className:`font-medium text-fg-muted`,children:r.projectName}),(0,T.jsx)(`input`,{className:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:P,onChange:e=>De(e.target.value),placeholder:I.trim()&&ce(I)||`xopc`})]}),(0,T.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,T.jsx)(`span`,{className:`font-medium text-fg-muted`,children:r.projectType}),(0,T.jsxs)(ee,{className:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:z,onChange:e=>be(e.target.value),disabled:q,children:[(0,T.jsx)(S,{value:`auto`,children:r.projectTypes.auto}),(0,T.jsx)(S,{value:`coding`,children:r.projectTypes.coding}),(0,T.jsx)(S,{value:`general`,children:r.projectTypes.general})]})]}),(0,T.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,T.jsx)(`span`,{className:`font-medium text-fg-muted`,children:r.defaultAgent}),(0,T.jsxs)(ee,{className:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:B,onChange:e=>xe(e.target.value),disabled:q,children:[(0,T.jsx)(S,{value:E,children:r.agentAuto}),(0,T.jsx)(S,{value:D,children:r.agentGlobalDefault}),V.map(e=>(0,T.jsx)(S,{value:e.id,children:e.name||e.id},e.id))]}),(0,T.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:Re})]})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,T.jsx)(s,{asChild:!0,children:(0,T.jsx)(u,{type:`button`,variant:`ghost`,className:`rounded-lg`,children:r.cancel})}),(0,T.jsxs)(u,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:q||!P.trim()&&(L!==`fixed`||!I.trim()),children:[(0,T.jsx)(h,{className:`size-4`,"aria-hidden":!0}),r.create]})]})]})]})]})}),(0,T.jsx)(f,{open:!!J,onOpenChange:e=>{e||Y(null)},children:(0,T.jsxs)(y,{children:[(0,T.jsx)(g,{className:`fixed inset-0 z-[100] bg-scrim backdrop-blur-[2px]`}),(0,T.jsxs)(v,{className:`fixed left-1/2 top-1/2 z-[110] flex w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,T.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,T.jsx)(m,{className:`text-base font-semibold text-fg`,children:r.workspaceConflictTitle}),(0,T.jsx)(p,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:J?k(r.workspaceConflictDescription,{projectName:J.name}):null})]}),J?(0,T.jsx)(`div`,{className:`space-y-3 px-5 py-4`,children:(0,T.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,T.jsx)(c,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`min-w-0 truncate`,children:k(r.workspaceConflictPath,{workspace:J.workspaceRoot||r.agentDefault})})]})}):null,(0,T.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,T.jsx)(u,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:je,children:r.workspaceConflictBack}),(0,T.jsxs)(u,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:Ae,children:[(0,T.jsx)(x,{className:`size-4`,"aria-hidden":!0}),r.workspaceConflictOpen]})]})]})]})}),(0,T.jsx)(f,{open:!!X,onOpenChange:e=>{e||Z(null)},children:(0,T.jsxs)(y,{children:[(0,T.jsx)(g,{className:`fixed inset-0 z-[100] bg-scrim backdrop-blur-[2px]`}),(0,T.jsxs)(v,{className:`fixed left-1/2 top-1/2 z-[110] flex w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,T.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,T.jsx)(m,{className:`text-base font-semibold text-fg`,children:r.workspaceMissingTitle}),(0,T.jsx)(p,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:X?k(r.workspaceMissingDescription,{workspace:X}):null})]}),X?(0,T.jsx)(`div`,{className:`px-5 py-4`,children:(0,T.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,T.jsx)(c,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`min-w-0 truncate`,children:X})]})}):null,(0,T.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,T.jsx)(u,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:Ne,disabled:q,children:r.workspaceMissingBack}),(0,T.jsxs)(u,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:Me,disabled:q,children:[(0,T.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),r.workspaceMissingCreate]})]})]})]})}),(0,T.jsxs)(`section`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1 rounded-lg bg-surface-panel p-1 shadow-surface`,children:se.map(e=>(0,T.jsx)(`button`,{type:`button`,onClick:()=>fe(e),className:i(`rounded-md px-3 py-1.5 text-sm font-medium transition-colors`,j===e?`bg-accent text-white`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:e===`all`?r.all:r.statuses[e]},e))}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,T.jsx)(c,{className:`size-4`,"aria-hidden":!0}),r.optionalContext]})]}),ge?(0,T.jsx)(`p`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:ge}):null,me?(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.loading}):null,!me&&O.length===0?(0,T.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-8 text-center shadow-surface`,children:[(0,T.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.emptyTitle}),(0,T.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.emptyHint})]}):null,Be.map(([e,t])=>t.length?(0,T.jsxs)(`section`,{className:`space-y-3`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wide text-fg-subtle`,children:e}),(0,T.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:t.map(e=>(0,T.jsx)(de,{project:e,t:r},e.id))})]},e):null)]})}export{j as ProjectsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-YzjnURPJ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{a as s,n as c,t as l}from"./fetch-BMjlW0g1.js";import{n as u,r as d,t as f}from"./url-DFGNSBNT.js";import{a as p,i as m}from"./vendor-swr-BIWyz7Rc.js";import{$a as h,Ar as g,Bo as _,C as v,Cl as y,Cr as b,Do as x,Dr as S,Dt as C,Eo as w,Er as T,Fc as E,Fs as D,Ga as O,Gc as k,Gs as A,Ha as j,Ka as M,Ol as N,Or as P,Sr as F,Tr as I,Ua as L,Va as R,Wa as z,Wo as B,Zr as ee,_a as V,_o as H,br as U,cs as W,dn as te,ga as G,gc as K,go as ne,gs as re,ha as q,ic as ie,il as J,jr as Y,kc as ae,kr as X,oo as oe,rs as se,so as ce,tl as le,ts as ue,wr as de,xr as fe,xs as pe,yr as me,za as he}from"./index-C4k6QSXw.js";import{n as ge,r as _e,t as ve}from"./settings-page-layout-DVt69dJJ.js";import{t as ye}from"./settings-collapsible-section-DuOvqNsI.js";import{n as be,r as xe,t as Se}from"./settings-form-section-DptSsbWd.js";import{t as Ce}from"./browser-BLJWD7WI.js";import{t as we}from"./page-tabs-RnYYOIWO.js";var Z=n(),Q=e(t(),1);function Te(e,t){let{mutate:n}=p(),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),l=(0,Q.useCallback)(async()=>{await Promise.all([n(`tunnel-pair-context`),n(`tunnel-pair`),n(`tunnel-status`),q()])},[n]);return{busy:r,error:a,confirmOpen:s,setConfirmOpen:c,runEnableLanPairing:(0,Q.useCallback)(async()=>{if(!(!e||r)){i(!0),o(null);try{let n=await b();if(!n.ok)throw Error(`Failed to enable LAN pairing`);if(n.requiresRestart){let t=await me();if(!t.ok)throw Error(t.message??`Gateway restart failed`);if(!await U(e))throw Error(`Gateway did not come back online in time`)}let r=n.requiresRestart?await fe():n.context;if(!r?.pairingReady)throw Error(`LAN pairing is still not ready after restart`);return await l(),t?.(r),c(!1),r}catch(e){return o(e instanceof Error?e.message:`Enable LAN pairing failed`),null}finally{i(!1)}}},[r,e,t,l]),clearError:()=>o(null)}}var $=r();function Ee(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,w,`dark:border-edge`)}function De(e){let t=(0,Z.c)(122),{pairQr:n,gatewayToken:r,streamlined:s,lanOnly:c,onRefreshQr:l}=e,u=s===void 0?!1:s,d=c===void 0?!1:c,f=o(Ae),p;t[0]===f?p=t[1]:(p=a(f),t[0]=f,t[1]=p);let m=p,h=m.tunnelSettings,g=d?m.remoteAccess.lan:null,_;t[2]!==m.clipboard.copyFailed||t[3]!==h.pairCopied||t[4]!==h.pairCopyLink?(_={copy:h.pairCopyLink,copied:h.pairCopied,copyFailed:m.clipboard.copyFailed},t[2]=m.clipboard.copyFailed,t[3]=h.pairCopied,t[4]=h.pairCopyLink,t[5]=_):_=t[5];let b=_,{tunnelActive:S,tunnelStatus:C,tunnelQr:w,pairContext:T,pairBaseUrl:E,setPairBaseUrl:D,applySuggestedPairUrl:O,applyCandidateUrl:k,resetPairBaseFromContext:j,baseOk:M,localhostWarn:N,pairingBlocked:P,deepLink:F,qrPayload:I,qrDataUrl:L,qrGenFailed:R,encoding:z}=n,B;t[6]===j?B=t[7]:(B=e=>{j(e.recommended.url)},t[6]=j,t[7]=B);let V=Te(r,B),H,U,W,te,G;if(t[8]!==k||t[9]!==O||t[10]!==M||t[11]!==V||t[12]!==r||t[13]!==g||t[14]!==d||t[15]!==N||t[16]!==l||t[17]!==E||t[18]!==T?.candidates||t[19]!==T?.recommended||t[20]!==P||t[21]!==D||t[22]!==u||t[23]!==h.pairBaseUrlHint||t[24]!==h.pairBaseUrlLabel||t[25]!==h.pairBaseUrlPlaceholder||t[26]!==h.pairBlockedLoopbackBody||t[27]!==h.pairBlockedNextSteps||t[28]!==h.pairBlockedTitle||t[29]!==h.pairCandidatesTitle||t[30]!==h.pairEnableLanButton||t[31]!==h.pairEnableLanEnabling||t[32]!==h.pairEnableLanSecurityAuditLink||t[33]!==h.pairInvalidBaseUrl||t[34]!==h.pairLocalhostWarning||t[35]!==h.pairSelectCandidateHint||t[36]!==h.pairSelectCandidateTitle||t[37]!==h.pairSubtitle||t[38]!==h.pairSuggestedLanLabel||t[39]!==h.pairTitle||t[40]!==h.pairTunnelActive||t[41]!==h.pairTunnelLanUrl||t[42]!==h.pairTunnelPublicUrl||t[43]!==h.pairUseSuggestedUrl||t[44]!==h.pairWaitingForTunnel||t[45]!==h.refreshQr||t[46]!==S||t[47]!==w||t[48]!==C?.publicUrl){G=Symbol.for(`react.early_return_sentinel`);bb0:{let e=T?.candidates.filter(ke)??[],n=d?(e.find(Oe)?.url??e[0]?.url??``).trim():T?.recommended.url?.trim()??``,a=(d||!S)&&e.length>1,o=function(t){if(e.length===0)return null;let n=t===`amber`?`text-amber-950 dark:text-amber-100`:`text-fg`,r=t===`amber`?`text-amber-950/80 dark:text-amber-200/90`:`text-fg-muted`;return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:i(`text-xs font-medium`,r),children:a?h.pairSelectCandidateTitle:h.pairCandidatesTitle}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:i(`w-full rounded-md border px-2 py-1.5 text-left font-mono text-[11px] transition-colors`,t===`amber`?`border-amber-300/70 hover:bg-amber-100/80 dark:border-amber-800 dark:hover:bg-amber-950/50`:`border-edge hover:bg-surface-panel`,E.trim()===e.url&&`border-accent bg-accent/5`,n),onClick:()=>k(e.url),children:[e.label?`${e.label}: `:``,e.url]})},e.url))}),a?(0,$.jsx)(`p`,{className:i(`mt-1 text-[11px] leading-relaxed`,r),children:h.pairSelectCandidateHint}):null]})};if(H=u&&!d,H&&!S){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ue,{className:`size-4 text-accent`,strokeWidth:1.75}),t[54]=e):e=t[54];let n;t[55]===h.pairTitle?n=t[56]:(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[e,h.pairTitle]}),t[55]=h.pairTitle,t[56]=n);let r;t[57]===h.pairWaitingForTunnel?r=t[58]:(r=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:h.pairWaitingForTunnel}),t[57]=h.pairWaitingForTunnel,t[58]=r);let i;t[59]!==n||t[60]!==r?(i=(0,$.jsxs)(Se,{children:[n,r]}),t[59]=n,t[60]=r,t[61]=i):i=t[61],G=i;break bb0}let s=g?.pairTitle??h.pairTitle,c=d?g?.pairSubtitle??h.pairSubtitle:S?h.pairTunnelActive:h.pairSubtitle,f=!!(l&&(d||u&&S)),p=H?`mb-2`:`mb-3`,m;t[62]===p?m=t[63]:(m=i(`flex flex-wrap items-start justify-between gap-2`,p),t[62]=p,t[63]=m);let _;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(ue,{className:`size-4 text-accent`,strokeWidth:1.75}),t[64]=_):_=t[64];let v;t[65]===s?v=t[66]:(v=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[_,s]}),t[65]=s,t[66]=v);let b;t[67]!==H||t[68]!==c||t[69]!==h.pairSubtitle?(b=H?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:h.pairSubtitle}):(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:c}),t[67]=H,t[68]=c,t[69]=h.pairSubtitle,t[70]=b):b=t[70];let j;t[71]!==v||t[72]!==b?(j=(0,$.jsxs)(`div`,{children:[v,b]}),t[71]=v,t[72]=b,t[73]=j):j=t[73];let F;t[74]!==l||t[75]!==f||t[76]!==h.refreshQr?(F=f?(0,$.jsxs)(x,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void l(),children:[(0,$.jsx)(re,{className:`size-4`}),h.refreshQr]}):null,t[74]=l,t[75]=f,t[76]=h.refreshQr,t[77]=F):F=t[77],t[78]!==m||t[79]!==j||t[80]!==F?(U=(0,$.jsxs)(`div`,{className:m,children:[j,F]}),t[78]=m,t[79]=j,t[80]=F,t[81]=U):U=t[81],W=P?(0,$.jsxs)(`div`,{className:`mb-3 space-y-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-3 dark:border-amber-900/50 dark:bg-amber-950/30`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-amber-950 dark:text-amber-100`,children:h.pairBlockedTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:h.pairBlockedLoopbackBody})]}),n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-amber-950/80 dark:text-amber-200/90`,children:h.pairSuggestedLanLabel}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-amber-950 dark:text-amber-100`,children:n})]}),(0,$.jsx)(x,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:O,children:h.pairUseSuggestedUrl})]}):null,e.length>0?o(`amber`):null,(0,$.jsx)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:(0,$.jsxs)(x,{type:`button`,className:`w-full sm:w-auto`,disabled:V.busy||!r,onClick:()=>V.setConfirmOpen(!0),children:[V.busy?(0,$.jsx)(A,{className:`size-3.5 animate-spin`}):null,V.busy?h.pairEnableLanEnabling:h.pairEnableLanButton]})}),V.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:V.error}):null,(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:d?g?.pairBlockedNextSteps??h.pairBlockedNextSteps:h.pairBlockedNextSteps}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(y,{to:`/settings/gateway`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:h.pairEnableLanSecurityAuditLink}),d&&g?.pairPublicTabLink?(0,$.jsx)(y,{to:`/settings/remote-access?tab=public`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:g.pairPublicTabLink}):null]})]}):null,te=S&&!d?H?null:(0,$.jsxs)(`div`,{className:`mb-3 space-y-2 rounded-lg bg-surface-panel/80 px-3 py-3 shadow-surface`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.pairTunnelPublicUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:C?.publicUrl})]}),w?.lanUrl?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.pairTunnelLanUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:w.lanUrl})]}):null]}):(0,$.jsxs)(`div`,{className:`mb-3 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`tunnel-mobile-pair-base`,children:h.pairBaseUrlLabel}),(0,$.jsx)(`input`,{id:`tunnel-mobile-pair-base`,className:i(Ee(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:n||h.pairBaseUrlPlaceholder,value:E,onChange:e=>D(e.target.value)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:h.pairBaseUrlHint}),!M&&E.trim()?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:h.pairInvalidBaseUrl}):null,N?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:h.pairLocalhostWarning}):null,a?o(`neutral`):null]})}t[8]=k,t[9]=O,t[10]=M,t[11]=V,t[12]=r,t[13]=g,t[14]=d,t[15]=N,t[16]=l,t[17]=E,t[18]=T?.candidates,t[19]=T?.recommended,t[20]=P,t[21]=D,t[22]=u,t[23]=h.pairBaseUrlHint,t[24]=h.pairBaseUrlLabel,t[25]=h.pairBaseUrlPlaceholder,t[26]=h.pairBlockedLoopbackBody,t[27]=h.pairBlockedNextSteps,t[28]=h.pairBlockedTitle,t[29]=h.pairCandidatesTitle,t[30]=h.pairEnableLanButton,t[31]=h.pairEnableLanEnabling,t[32]=h.pairEnableLanSecurityAuditLink,t[33]=h.pairInvalidBaseUrl,t[34]=h.pairLocalhostWarning,t[35]=h.pairSelectCandidateHint,t[36]=h.pairSelectCandidateTitle,t[37]=h.pairSubtitle,t[38]=h.pairSuggestedLanLabel,t[39]=h.pairTitle,t[40]=h.pairTunnelActive,t[41]=h.pairTunnelLanUrl,t[42]=h.pairTunnelPublicUrl,t[43]=h.pairUseSuggestedUrl,t[44]=h.pairWaitingForTunnel,t[45]=h.refreshQr,t[46]=S,t[47]=w,t[48]=C?.publicUrl,t[49]=H,t[50]=U,t[51]=W,t[52]=te,t[53]=G}else H=t[49],U=t[50],W=t[51],te=t[52],G=t[53];if(G!==Symbol.for(`react.early_return_sentinel`))return G;let K;t[82]===h.pairSecurityNote?K=t[83]:(K=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:h.pairSecurityNote}),t[82]=h.pairSecurityNote,t[83]=K);let ne;t[84]!==b||t[85]!==F||t[86]!==z||t[87]!==P||t[88]!==L||t[89]!==R||t[90]!==h.pairEncoding||t[91]!==h.pairImageError||t[92]!==h.pairQrDisabled?(ne=F?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[L&&!R?(0,$.jsx)(`img`,{src:L,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,z?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h.pairEncoding}):null,R?(0,$.jsx)(`p`,{className:`text-center text-sm text-fg-muted sm:text-left`,children:h.pairImageError}):null,(0,$.jsx)(ee,{text:F,labels:b})]}):P?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h.pairQrDisabled}):null,t[84]=b,t[85]=F,t[86]=z,t[87]=P,t[88]=L,t[89]=R,t[90]=h.pairEncoding,t[91]=h.pairImageError,t[92]=h.pairQrDisabled,t[93]=ne):ne=t[93];let q;t[94]!==H||t[95]!==I||t[96]!==h.deeplinkTitle?(q=I&&!H?(0,$.jsxs)(`details`,{className:`mt-3 rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:h.deeplinkTitle}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:I})]}):null,t[94]=H,t[95]=I,t[96]=h.deeplinkTitle,t[97]=q):q=t[97];let ie;t[98]!==H||t[99]!==h.pairMobileProbeHint||t[100]!==h.pairSchemeHint?(ie=H?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-3 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:h.pairSchemeHint}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] leading-relaxed text-fg-subtle`,children:h.pairMobileProbeHint})]}),t[98]=H,t[99]=h.pairMobileProbeHint,t[100]=h.pairSchemeHint,t[101]=ie):ie=t[101];let J,Y;t[102]===V?(J=t[103],Y=t[104]):(J=()=>void V.runEnableLanPairing(),Y=()=>{V.busy||V.setConfirmOpen(!1)},t[102]=V,t[103]=J,t[104]=Y);let ae;t[105]!==V.confirmOpen||t[106]!==h.consentCancel||t[107]!==h.pairEnableLanButton||t[108]!==h.pairEnableLanConfirmBody||t[109]!==h.pairEnableLanConfirmTitle||t[110]!==J||t[111]!==Y?(ae=(0,$.jsx)(v,{open:V.confirmOpen,title:h.pairEnableLanConfirmTitle,description:h.pairEnableLanConfirmBody,confirmLabel:h.pairEnableLanButton,cancelLabel:h.consentCancel,onConfirm:J,onCancel:Y}),t[105]=V.confirmOpen,t[106]=h.consentCancel,t[107]=h.pairEnableLanButton,t[108]=h.pairEnableLanConfirmBody,t[109]=h.pairEnableLanConfirmTitle,t[110]=J,t[111]=Y,t[112]=ae):ae=t[112];let X;return t[113]!==K||t[114]!==ne||t[115]!==q||t[116]!==ie||t[117]!==ae||t[118]!==U||t[119]!==W||t[120]!==te?(X=(0,$.jsx)(Se,{children:(0,$.jsxs)($.Fragment,{children:[U,W,te,K,ne,q,ie,ae]})}),t[113]=K,t[114]=ne,t[115]=q,t[116]=ie,t[117]=ae,t[118]=U,t[119]=W,t[120]=te,t[121]=X):X=t[121],X}function Oe(e){return e.reachable}function ke(e){return e.kind===`lan`}function Ae(e){return e.language}function je(e){let t=(0,Z.c)(40),{open:n,title:r,intro:a,bullets:o,checkboxLabel:s,confirmLabel:c,cancelLabel:l,onConfirm:u,onCancel:d}=e,[f,p]=(0,Q.useState)(!1),m;t[0]===d?m=t[1]:(m=e=>{e||(p(!1),d())},t[0]=d,t[1]=m);let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(L,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ce)}),t[2]=h):h=t[2];let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=i(`fixed left-1/2 top-1/2 max-h-[min(90vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`,oe),t[3]=g):g=t[3];let _;t[4]===r?_=t[5]:(_=(0,$.jsx)(M,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=_);let v;t[6]===a?v=t[7]:(v=(0,$.jsx)(j,{className:`mt-2 text-sm text-fg-muted`,children:a}),t[6]=a,t[7]=v);let y;t[8]===o?y=t[9]:(y=o.map(Me),t[8]=o,t[9]=y);let b;t[10]===y?b=t[11]:(b=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:y}),t[10]=y,t[11]=b);let S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>p(e.target.checked),t[12]=S):S=t[12];let C;t[13]===f?C=t[14]:(C=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:f,onChange:S}),t[13]=f,t[14]=C);let w;t[15]===s?w=t[16]:(w=(0,$.jsx)(`span`,{children:s}),t[15]=s,t[16]=w);let T;t[17]!==w||t[18]!==C?(T=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[C,w]}),t[17]=w,t[18]=C,t[19]=T):T=t[19];let E;t[20]!==l||t[21]!==d?(E=(0,$.jsx)(x,{type:`button`,variant:`secondary`,onClick:d,children:l}),t[20]=l,t[21]=d,t[22]=E):E=t[22];let D=!f,k;t[23]!==c||t[24]!==u||t[25]!==D?(k=(0,$.jsx)(x,{type:`button`,disabled:D,onClick:u,children:c}),t[23]=c,t[24]=u,t[25]=D,t[26]=k):k=t[26];let A;t[27]!==E||t[28]!==k?(A=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[E,k]}),t[27]=E,t[28]=k,t[29]=A):A=t[29];let N;t[30]!==T||t[31]!==A||t[32]!==_||t[33]!==v||t[34]!==b?(N=(0,$.jsxs)(z,{children:[h,(0,$.jsxs)(R,{className:g,onOpenAutoFocus:Ne,children:[_,v,b,T,A]})]}),t[30]=T,t[31]=A,t[32]=_,t[33]=v,t[34]=b,t[35]=N):N=t[35];let P;return t[36]!==n||t[37]!==m||t[38]!==N?(P=(0,$.jsx)(O,{open:n,onOpenChange:m,children:N}),t[36]=n,t[37]=m,t[38]=N,t[39]=P):P=t[39],P}function Me(e){return(0,$.jsx)(`li`,{children:e},e)}function Ne(e){return e.preventDefault()}function Pe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Fe=[`preparing_frpc`,`registering`,`starting_frpc`];function Ie(e){return e?e===`reconnecting_frpc`?Fe.indexOf(`starting_frpc`):Fe.indexOf(e):-1}function Le(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Fe.indexOf(e),i=Ie(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Re(e,t,n){let r=n.startProgress;return Le(t,n)===`active`?t===`preparing_frpc`&&n.frpcDownload?n.frpcDownload.phase===`extracting`?e.frpcExtracting:n.frpcDownload.percent==null?e.frpcDownloading:e.frpcDownloadingPercent.replace(`{{percent}}`,String(n.frpcDownload.percent)):t===`registering`&&r?.publicUrl?e.stepRegisterDetail:t===`starting_frpc`?r?.phase===`reconnecting_frpc`?e.stepReconnectDetail:e.stepFrpcDetail:null:null}function ze(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function Be(e){if(!e)return null;let t=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Ve(e){let t=(0,Z.c)(31),{status:n,t:r}=e,[,a]=(0,Q.useState)(0),o;t[0]!==a||t[1]!==n.state?(o=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>a(He),1e3);return()=>window.clearInterval(e)},t[0]=a,t[1]=n.state,t[2]=o):o=t[2];let s=n.startProgress?.startedAt,c;if(t[3]!==n.state||t[4]!==s?(c=[n.state,s],t[3]=n.state,t[4]=s,t[5]=c):c=t[5],(0,Q.useEffect)(o,c),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let l,u,d,f,p;if(t[6]!==n||t[7]!==r){let e=Be(n.startProgress?.startedAt);l=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,u=`mt-3 space-y-3 rounded-lg bg-surface-panel/80 px-3 py-3 shadow-surface`;let a;t[13]===r.startProgressTitle?a=t[14]:(a=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.startProgressTitle}),t[13]=r.startProgressTitle,t[14]=a);let o;t[15]===r.startProgressHint?o=t[16]:(o=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.startProgressHint}),t[15]=r.startProgressHint,t[16]=o),t[17]!==a||t[18]!==o?(d=(0,$.jsxs)(`div`,{children:[a,o]}),t[17]=a,t[18]=o,t[19]=d):d=t[19];let s=Fe.map(e=>{let t=Le(e,n),a=Re(r,e,n);return(0,$.jsxs)(`li`,{className:`flex gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-subtle`,"aria-hidden":!0,children:t===`done`?(0,$.jsx)(J,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(A,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(k,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:i(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:ze(r,e)}),a?(0,$.jsx)(`div`,{className:`mt-0.5 text-fg-muted`,children:a}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload&&n.frpcDownload.phase===`downloading`?(0,$.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-panel`,children:(0,$.jsx)(`div`,{className:i(`h-full rounded-full bg-accent transition-[width] duration-300`,n.frpcDownload.percent==null&&`w-1/3 animate-pulse`),style:n.frpcDownload.percent==null?void 0:{width:`${n.frpcDownload.percent}%`}})}),n.frpcDownload.bytesReceived!=null&&n.frpcDownload.totalBytes?(0,$.jsxs)(`p`,{className:`text-fg-subtle`,children:[Pe(n.frpcDownload.bytesReceived),` /`,` `,Pe(n.frpcDownload.totalBytes)]}):null]}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload?.url?(0,$.jsxs)(`p`,{className:`mt-2 text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`font-sans`,children:[r.frpcDownloadingUrlLabel,`: `]}),(0,$.jsx)(`a`,{href:n.frpcDownload.url,target:`_blank`,rel:`noopener noreferrer`,className:`break-all font-mono text-[11px] text-accent hover:underline`,children:n.frpcDownload.url})]}):null]})]},e)});t[20]===s?f=t[21]:(f=(0,$.jsx)(`ol`,{className:`space-y-2`,children:s}),t[20]=s,t[21]=f),p=e&&n.startProgress?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.startProgressElapsed.replace(`{{elapsed}}`,e)}):null,t[6]=n,t[7]=r,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p}else l=t[8],u=t[9],d=t[10],f=t[11],p=t[12];let m;t[22]!==l||t[23]!==r.publicUrlPendingNotice?(m=l?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=l,t[23]=r.publicUrlPendingNotice,t[24]=m):m=t[24];let h;return t[25]!==u||t[26]!==d||t[27]!==f||t[28]!==p||t[29]!==m?(h=(0,$.jsxs)(`div`,{className:u,children:[d,f,p,m]}),t[25]=u,t[26]=d,t[27]=f,t[28]=p,t[29]=m,t[30]=h):h=t[30],h}function He(e){return e+1}function Ue(e,t){return t.state===`connected`?e.statusConnected:t.state===`error`?e.statusError:t.startProgress?.phase===`reconnecting_frpc`?e.statusReconnecting:t.startProgress?.phase===`starting_frpc`?e.statusStartingFrpc:t.startProgress?.phase===`registering`?e.statusRegistering:t.startProgress?.phase===`preparing_frpc`||t.frpcDownload?e.statusPreparingFrpc:t.state===`connecting`||t.state===`reconnecting`?e.statusConnecting:e.statusOff}function We(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function Ge(e){switch(e){case`connected`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`progress`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;case`error`:return`bg-red-500/15 text-red-700 dark:text-red-400`;default:return`bg-surface-hover text-fg-muted`}}function Ke(e){if(!e)return`—`;let t=Date.now()-new Date(e).getTime();if(t<0)return`—`;let n=Math.floor(t/6e4);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function qe(e){let t=(0,Z.c)(61),{t:n,status:r,isLoading:a,statusErr:o,starting:s,stopping:c,showConsentExpired:l,copyLabels:u,startDisabled:d,startDisabledReason:f,stepLabel:p,onStart:m,onStop:h}=e,g=d===void 0?!1:d,v,y,b,S,C,w,T;t[0]!==r||t[1]!==s?(T=We(r),v=r.enabled||s,y=s||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(w=i(xe(),`space-y-4`),t[9]=w):w=t[9],C=`flex flex-wrap items-start justify-between gap-3`,S=`flex items-center gap-2`,b=i(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Ge(T)),t[0]=r,t[1]=s,t[2]=v,t[3]=y,t[4]=b,t[5]=S,t[6]=C,t[7]=w,t[8]=T):(v=t[2],y=t[3],b=t[4],S=t[5],C=t[6],w=t[7],T=t[8]);let E=T===`connected`&&`bg-emerald-500`,D=T===`progress`&&`bg-amber-500 animate-pulse`,O=T===`error`&&`bg-red-500`,k=T===`off`&&`bg-fg-subtle`,j;t[10]!==E||t[11]!==D||t[12]!==O||t[13]!==k?(j=i(`size-1.5 rounded-full`,E,D,O,k),t[10]=E,t[11]=D,t[12]=O,t[13]=k,t[14]=j):j=t[14];let M;t[15]===j?M=t[16]:(M=(0,$.jsx)(`span`,{className:j,"aria-hidden":!0}),t[15]=j,t[16]=M);let N;t[17]!==a||t[18]!==r||t[19]!==n?(N=a&&!r.enabled?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block h-3 w-16 animate-pulse rounded-full bg-surface-hover/70 motion-reduce:animate-none`}):Ue(n,r),t[17]=a,t[18]=r,t[19]=n,t[20]=N):N=t[20];let P;t[21]!==M||t[22]!==N||t[23]!==b?(P=(0,$.jsxs)(`span`,{className:b,children:[M,N]}),t[21]=M,t[22]=N,t[23]=b,t[24]=P):P=t[24];let F;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(F=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,Ke(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=F):F=t[28];let I;t[29]!==P||t[30]!==F||t[31]!==S?(I=(0,$.jsxs)(`div`,{className:S,children:[P,F]}),t[29]=P,t[30]=F,t[31]=S,t[32]=I):I=t[32];let L;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(K,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=L):L=t[33];let R;t[34]!==I||t[35]!==C?(R=(0,$.jsxs)(`div`,{className:C,children:[I,L]}),t[34]=I,t[35]=C,t[36]=R):R=t[36];let z;t[37]===o?z=t[38]:(z=o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o instanceof Error?o.message:String(o)}):null,t[37]=o,t[38]=z);let B;t[39]!==l||t[40]!==n.consentExpiredBanner?(B=l?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=l,t[40]=n.consentExpiredBanner,t[41]=B):B=t[41];let V;t[42]!==v||t[43]!==u||t[44]!==m||t[45]!==h||t[46]!==y||t[47]!==r||t[48]!==g||t[49]!==f||t[50]!==s||t[51]!==p||t[52]!==c||t[53]!==n?(V=v?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-3 shadow-surface`,children:(0,$.jsx)(ee,{label:n.publicUrlLabel,text:r.publicUrl,labels:u})}):null,y?(0,$.jsx)(Ve,{status:r,t:n}):null,r.lastError&&r.state===`error`?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:r.lastError}):null,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.enabled?(0,$.jsxs)(x,{type:`button`,variant:`secondary`,disabled:c,onClick:h,children:[c?(0,$.jsx)(A,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(x,{type:`button`,disabled:s,onClick:m,children:[s?(0,$.jsx)(A,{className:`size-4 animate-spin`}):(0,$.jsx)(pe,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:p}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.emptyStateTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.emptyStateBody})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(_,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),g&&f?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:f}):null,(0,$.jsxs)(x,{type:`button`,disabled:s||g,onClick:m,className:`w-full sm:w-auto`,children:[s?(0,$.jsx)(A,{className:`size-4 animate-spin`}):(0,$.jsx)(pe,{className:`size-4`}),n.start]})]}),t[42]=v,t[43]=u,t[44]=m,t[45]=h,t[46]=y,t[47]=r,t[48]=g,t[49]=f,t[50]=s,t[51]=p,t[52]=c,t[53]=n,t[54]=V):V=t[54];let H;return t[55]!==R||t[56]!==z||t[57]!==B||t[58]!==V||t[59]!==w?(H=(0,$.jsxs)(`section`,{className:w,children:[R,z,B,V]}),t[55]=R,t[56]=z,t[57]=B,t[58]=V,t[59]=w,t[60]=H):H=t[60],H}var Je=`https://console.xopc.ai/keys/tunnel`,Ye={reconfiguring:!1};function Xe(e){let t=(0,Z.c)(84),{t:n,brokerSecretFromEnv:r,brokerSecretMissing:a,brokerSecretConfiguredInConfig:o,brokerSecretMaskedValue:s,brokerSecretDraft:c,savingBrokerSecret:l,brokerSecretNotice:u,copyFailedLabel:d,onDraftChange:f,onSave:p,onClear:m,sectionRef:h}=e,g=(0,Q.useId)(),_=a&&!r,v=!_,[y,b]=(0,Q.useReducer)(C,Ye),{reconfiguring:S}=y,w;t[0]!==o||t[1]!==c||t[2]!==r||t[3]!==S?(w=o&&!r&&!S&&!c.trim(),t[0]=o,t[1]=c,t[2]=r,t[3]=S,t[4]=w):w=t[4];let T=w,E;t[5]!==n.copied||t[6]!==n.copyKey||t[7]!==n.hideKey||t[8]!==n.showKey?(E={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[5]=n.copied,t[6]=n.copyKey,t[7]=n.hideKey,t[8]=n.showKey,t[9]=E):E=t[9];let D=E,O;t[10]===c?O=t[11]:(O=c.trim().length>0&&!te(c.trim()),t[10]=c,t[11]=O);let k=O,j;t[12]===f?j=t[13]:(j=()=>{b({type:`patch`,patch:{reconfiguring:!1}}),f(``)},t[12]=f,t[13]=j);let M=j,N=_&&`ring-1 ring-amber-500/30`,P;t[14]===N?P=t[15]:(P=i(N),t[14]=N,t[15]=P);let F=v?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:_?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,I;t[16]===F?I=t[17]:(I=i(`flex size-9 shrink-0 items-center justify-center rounded-lg`,F),t[16]=F,t[17]=I);let L;t[18]===v?L=t[19]:(L=v?(0,$.jsx)(J,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(ie,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=v,t[19]=L);let R;t[20]!==I||t[21]!==L?(R=(0,$.jsx)(`span`,{className:I,children:L}),t[20]=I,t[21]=L,t[22]=R):R=t[22];let z=v?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,B;t[23]===z?B=t[24]:(B=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:z}),t[23]=z,t[24]=B);let ee=v?n.brokerSecretReadyHint:n.brokerSecretHint,V;t[25]===ee?V=t[26]:(V=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:ee}),t[25]=ee,t[26]=V);let H;t[27]!==_||t[28]!==n.brokerSecretMissingHint?(H=_?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[27]=_,t[28]=n.brokerSecretMissingHint,t[29]=H):H=t[29];let U;t[30]!==B||t[31]!==V||t[32]!==H?(U=(0,$.jsxs)(`div`,{children:[B,V,H]}),t[30]=B,t[31]=V,t[32]=H,t[33]=U):U=t[33];let W;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(ae,{className:`size-3`,"aria-hidden":!0}),t[34]=W):W=t[34];let G;t[35]===n.brokerSecretConsoleLink?G=t[36]:(G=(0,$.jsxs)(`a`,{href:Je,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n.brokerSecretConsoleLink,W]}),t[35]=n.brokerSecretConsoleLink,t[36]=G);let K;t[37]!==r||t[38]!==n.brokerSecretEnvHint?(K=r?(0,$.jsx)(`p`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 text-xs text-fg-muted shadow-surface`,children:n.brokerSecretEnvHint}):null,t[37]=r,t[38]=n.brokerSecretEnvHint,t[39]=K):K=t[39];let re;t[40]!==o||t[41]!==c||t[42]!==r||t[43]!==s||t[44]!==k||t[45]!==M||t[46]!==d||t[47]!==g||t[48]!==_||t[49]!==m||t[50]!==f||t[51]!==p||t[52]!==S||t[53]!==l||t[54]!==D||t[55]!==T||t[56]!==n.brokerSecretCancelReconfigure||t[57]!==n.brokerSecretClear||t[58]!==n.brokerSecretMaskedHelp||t[59]!==n.brokerSecretNotInConfigFile||t[60]!==n.brokerSecretPlaceholder||t[61]!==n.brokerSecretReconfigure||t[62]!==n.brokerSecretRevealFailed||t[63]!==n.brokerSecretSave||t[64]!==n.brokerSecretSaveAndContinue||t[65]!==n.brokerSecretTitle?(re=T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:g,children:n.brokerSecretTitle}),(0,$.jsx)(ne,{id:g,value:s,labels:D,reveal:Ze,loadFailedLabel:d||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(x,{type:`button`,variant:`secondary`,disabled:l,onClick:()=>{b({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(x,{type:`button`,variant:`ghost`,disabled:l,onClick:m,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:g,children:n.brokerSecretTitle}),(0,$.jsx)(ne,{id:g,value:c,onChange:f,placeholder:n.brokerSecretPlaceholder,labels:D,disabled:l}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(x,{type:`button`,disabled:l||!k,onClick:p,children:[l?(0,$.jsx)(A,{className:`size-4 animate-spin`}):null,_?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),o||r?(0,$.jsx)(x,{type:`button`,variant:`ghost`,disabled:l,onClick:m,children:n.brokerSecretClear}):null,S?(0,$.jsx)(x,{type:`button`,variant:`ghost`,disabled:l,onClick:M,children:n.brokerSecretCancelReconfigure}):null]})]}),t[40]=o,t[41]=c,t[42]=r,t[43]=s,t[44]=k,t[45]=M,t[46]=d,t[47]=g,t[48]=_,t[49]=m,t[50]=f,t[51]=p,t[52]=S,t[53]=l,t[54]=D,t[55]=T,t[56]=n.brokerSecretCancelReconfigure,t[57]=n.brokerSecretClear,t[58]=n.brokerSecretMaskedHelp,t[59]=n.brokerSecretNotInConfigFile,t[60]=n.brokerSecretPlaceholder,t[61]=n.brokerSecretReconfigure,t[62]=n.brokerSecretRevealFailed,t[63]=n.brokerSecretSave,t[64]=n.brokerSecretSaveAndContinue,t[65]=n.brokerSecretTitle,t[66]=re):re=t[66];let q;t[67]===u?q=t[68]:(q=u?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:u}):null,t[67]=u,t[68]=q);let Y;t[69]!==U||t[70]!==G||t[71]!==K||t[72]!==re||t[73]!==q?(Y=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[U,G,K,re,q]}),t[69]=U,t[70]=G,t[71]=K,t[72]=re,t[73]=q,t[74]=Y):Y=t[74];let X;t[75]!==R||t[76]!==Y?(X=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[R,Y]}),t[75]=R,t[76]=Y,t[77]=X):X=t[77];let oe;t[78]!==X||t[79]!==P?(oe=(0,$.jsx)(Se,{className:P,children:X}),t[78]=X,t[79]=P,t[80]=oe):oe=t[80];let se;return t[81]!==h||t[82]!==oe?(se=(0,$.jsx)(`div`,{ref:h,id:`tunnel-broker-secret-setup`,children:oe}),t[81]=h,t[82]=oe,t[83]=se):se=t[83],se}function Ze(){return X().then(Qe)}function Qe(e){return e.registrationSecret??null}function $e(e){let t=(0,Z.c)(10),{language:n,label:r,section:a,className:o}=e,s;t[0]!==n||t[1]!==a?(s=h(n,a),t[0]=n,t[1]=a,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=i(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,o),t[3]=o,t[4]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(ae,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=l):l=t[5];let u;return t[6]!==r||t[7]!==s||t[8]!==c?(u=(0,$.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:c,children:[r,l]}),t[6]=r,t[7]=s,t[8]=c,t[9]=u):u=t[9],u}var et=e(Ce(),1),tt={width:216,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function nt(e){return et.toDataURL(e,tt)}function rt(e){let t=e?.candidates??[],n=t.find(e=>e.kind===`lan`&&e.reachable),r=t.find(e=>e.kind===`lan`);return(n??r)?.url?.trim()??``}function it(e,t){let n=t.trim();return!n||!e?!1:e.candidates.some(e=>e.kind===`tunnel`&&e.url.trim()===n)}function at(e,t){return e?t?rt(e)||e.recommended.url?.trim()||``:e.recommended.url?.trim()||``:``}function ot(e,t){let n=t?.preferLan===!0,r=!!e,{mutate:i}=p(),a=(0,Q.useRef)(!1),{data:o}=m(r?`tunnel-status`:null,T,{refreshInterval:6e4}),{data:s,mutate:c}=m(r?`tunnel-pair-context`:null,de,{refreshInterval:6e4});(0,Q.useEffect)(()=>{let e=()=>{i(`tunnel-status`),i(`tunnel-qr`),i(`tunnel-pair`),i(`tunnel-pair-context`)};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[i]);let l=o?.state===`connected`&&!!o.publicUrl?.trim(),f=l&&!n,{data:h,mutate:g}=m(f&&r?`tunnel-qr`:null,I,{refreshInterval:4*6e4}),{data:_,mutate:v}=m(!f&&r&&s?.pairingReady?`tunnel-pair`:null,F,{refreshInterval:4*6e4}),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)({pairContext:void 0,preferLan:n});if(!a.current&&(s!==C.pairContext||n!==C.preferLan)){w({pairContext:s,preferLan:n});let e=at(s,n);y!==e&&b(e)}let E=(0,Q.useCallback)(e=>{a.current=!0,b(e)},[]),D=(0,Q.useCallback)(()=>{let e=at(s,n);e&&(a.current=!0,b(e))},[s,n]),O=(0,Q.useCallback)(e=>{let t=e.trim();t&&(a.current=!0,b(t))},[]),k=(0,Q.useCallback)(e=>{a.current=!1,b(e?.trim()||at(s,n))},[s,n]),A=y.trim(),j=(0,Q.useMemo)(()=>{try{let e=new URL(A);return e.protocol===`http:`||e.protocol===`https:`}catch{return!1}},[A]),M=j&&d(A),N=!f&&!!(s&&!s.pairingReady&&s.blockReason===`GATEWAY_LOOPBACK_ONLY`),P=!f&&j&&!M&&!!_?.pairingSecret&&(s?.pairingReady===!0||!N),L=(0,Q.useMemo)(()=>{let e=rt(s);return n?e||(A&&!it(s,A)?A:``):A},[s,n,A]),R=(0,Q.useMemo)(()=>{if(!e)return``;if(x.trim())return x.trim();if(f&&h?.qrPayload?.trim())return h.qrPayload.trim();if(!P||!_?.pairingSecret)return``;let t=s?.candidates.find(e=>e.kind===`tunnel`&&e.reachable),r=s?.candidates.find(e=>e.kind===`lan`&&e.reachable),i=n?L:t?.url??A;return i?u({baseUrl:i,pairingSecret:_.pairingSecret,lanUrl:n?null:t&&r?r.url:null}):``},[e,L,_?.pairingSecret,P,x,n,A,f,h?.qrPayload,s?.candidates]),z=he(()=>nt(R),[R],{enabled:!!R,initial:null,errorData:null}),B=R?z.data:null,ee=!!(R&&z.error!==null&&!z.loading);return{tunnelActive:l,tunnelStatus:o,tunnelQr:h,pairContext:s,pairBaseUrl:y,setPairBaseUrl:E,applySuggestedPairUrl:D,applyCandidateUrl:O,baseOk:j,localhostWarn:M,pairingBlocked:N,deepLink:R,qrPayload:R,qrDataUrl:B,qrGenFailed:ee,encoding:!!(R&&!B&&!ee),refreshQr:(0,Q.useCallback)(async e=>{if(e?.trim()){S(e.trim()),g({qrPayload:e.trim(),publicUrl:o?.publicUrl??``,lanUrl:h?.lanUrl??null},!1);return}S(``),await c(),f?await g():s?.pairingReady&&await v()},[v,c,g,s?.pairingReady,h?.lanUrl,o?.publicUrl,f]),resetPairBaseFromContext:k}}var st={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,brokerSecretNotice:null};function ct({embedded:e=!1}){let t=o(e=>e.language),n=a(t).tunnelSettings,r=s(e=>e.token),c=!!r,[l,u]=(0,Q.useReducer)(C,st),{actionError:d,starting:f,stopping:p,savingAutoStart:h,consentOpen:_,autoStartConfirmOpen:y,releaseConfirmOpen:b,releasing:w,brokerSecretDraft:E,savingBrokerSecret:D,brokerSecretNotice:O}=l,k=(0,Q.useRef)(null),j=ot(r??``),{data:M}=G(c),{data:N,error:F,isLoading:I,mutate:L}=m(c?`tunnel-status`:null,T,{refreshInterval:e=>f?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),R=(0,Q.useMemo)(()=>{let e=M?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)&&t.autoStart===!0)return!0}return N?.config?.autoStart===!0},[M,N?.config?.autoStart]),z=(0,Q.useMemo)(()=>{let e=M?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.registrationSecret;if(typeof e==`string`)return e}}return``},[M]),B=te(z),ee=N?.registrationSecret?.source===`env`,V=N?.registrationSecret?.source===`missing`,H=N?.registrationSecret?.configured===!0;(0,Q.useEffect)(()=>{let e=()=>{L()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[L]);let U=(0,Q.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),W=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{actionError:null}}),u({type:`patch`,patch:{starting:!0}});try{let e=await g();await L(),q(),await j.refreshQr(e.qrPayload)}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{starting:!1}})}},[L,j.refreshQr]),ne=(0,Q.useCallback)(()=>{if(!H){u({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),k.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(N?.consentRequired){u({type:`patch`,patch:{consentOpen:!0}});return}W()},[H,N?.consentRequired,W,n.brokerSecretRequiredBeforeStart]),re=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{consentOpen:!1}}),u({type:`patch`,patch:{actionError:null}});try{await P(),await Promise.all([L(),W()])}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[L,W]),ie=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{actionError:null}}),u({type:`patch`,patch:{stopping:!0}});try{await Y(),await Promise.all([j.refreshQr(),L()]),q()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{stopping:!1}})}},[L,j.refreshQr]),J=(0,Q.useCallback)(async e=>{u({type:`patch`,patch:{savingAutoStart:!0}}),u({type:`patch`,patch:{actionError:null}});try{await S({autoStart:e}),q()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingAutoStart:!1}})}},[]),ae=(0,Q.useCallback)(()=>{if(R){J(!1);return}if(N?.consentRequired){u({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!N?.canAutoStart){u({type:`patch`,patch:{actionError:n.autoStartHint}});return}u({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[J,N?.canAutoStart,N?.consentRequired,n,R]),X=(0,Q.useCallback)(async()=>{let e=E.trim();if(e){u({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await S({registrationSecret:e}),u({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),q(),await L(),u({type:`patch`,patch:{actionError:null}})}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[E,L,n.brokerSecretSaved]),oe=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await S({registrationSecret:null}),u({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),q(),await L()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingBrokerSecret:!1}})}},[L,n.brokerSecretCleared]),se=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await Y({release:!0}),await Promise.all([j.refreshQr(),L()]),q()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{releasing:!1}})}},[L,j.refreshQr]),ce=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:a(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!c)return(0,$.jsx)(`div`,{className:e?void 0:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let le=N??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:R,brokerUrl:`https://frp.xopc.ai/api`}},ue=N?.consentRequired&&(le.enabled||R||N?.consent?.acceptedAt),de=(0,$.jsx)(Xe,{t:n,brokerSecretFromEnv:ee,brokerSecretMissing:V,brokerSecretConfiguredInConfig:B,brokerSecretMaskedValue:B?z:``,brokerSecretDraft:E,savingBrokerSecret:D,brokerSecretNotice:O,copyFailedLabel:a(t).clipboard.copyFailed,onDraftChange:e=>u({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void X(),onClear:()=>void oe(),sectionRef:k}),fe=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(je,{open:_,title:n.consentTitle,intro:n.consentIntro,bullets:U,checkboxLabel:n.consentCheckbox,confirmLabel:ue?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void re(),onCancel:()=>u({type:`patch`,patch:{consentOpen:!1}})},_?`consent-open`:`consent-closed`),(0,$.jsx)(v,{open:y,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{u({type:`patch`,patch:{autoStartConfirmOpen:!1}}),J(!0)},onCancel:()=>u({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(v,{open:b,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void se(),onCancel:()=>u({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[d?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,de,(0,$.jsx)(qe,{t:n,status:le,isLoading:I,statusErr:F,starting:f,stopping:p,showConsentExpired:!!ue,copyLabels:ce,startDisabled:!H,startDisabledReason:H?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:ne,onStop:()=>void ie()}),(0,$.jsx)(De,{pairQr:j,gatewayToken:r??``,streamlined:!0,onRefreshQr:()=>void j.refreshQr()}),(0,$.jsxs)(ye,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:i(`flex items-center gap-3 text-sm text-fg`,!R&&!N?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:R,disabled:h||!R&&!N?.canAutoStart,onChange:ae}),n.autoStart]}),!N?.canAutoStart&&!R?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,le.subdomain||le.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(x,{type:`button`,variant:`secondary`,disabled:w||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>u({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[w?(0,$.jsx)(A,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(ye,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(K,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)($e,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),fe]}):(0,$.jsxs)(`div`,{className:e?`flex w-full flex-col gap-6`:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[e?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),d?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,de,(0,$.jsx)(qe,{t:n,status:le,isLoading:I,statusErr:F,starting:f,stopping:p,showConsentExpired:!!ue,copyLabels:ce,startDisabled:!H,startDisabledReason:H?void 0:n.brokerSecretRequiredBeforeStart,onStart:ne,onStop:()=>void ie()}),(0,$.jsx)(De,{pairQr:j,gatewayToken:r??``}),le.subdomain||le.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(x,{type:`button`,variant:`secondary`,disabled:w||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>u({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[w?(0,$.jsx)(A,{className:`size-4 animate-spin`}):null,n.release]})}):null,le.subdomain||le.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(Se,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:i(`flex items-center gap-3 text-sm text-fg`,!R&&!N?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:R,disabled:h||!R&&!N?.canAutoStart,onChange:ae}),n.autoStart]}),!N?.canAutoStart&&!R?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n.autoStartHint}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-panel/80 px-3 py-2 text-xs text-fg-subtle shadow-surface`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(K,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)($e,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),fe]})}async function lt(){let e=await l(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function ut(e=`serve`){let t=await l(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function dt(){let e=await l(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var ft=`https://tailscale.com/download`;function pt(e){let t=(0,Z.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`a`,{href:ft,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function mt({embedded:e=!1}){let t=o(e=>e.language),n=a(t).remoteAccess.tailscale,r=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:a(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!s(e=>e.token),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),{data:f,mutate:p,isLoading:h}=m(i?`exposure-status`:null,lt,{refreshInterval:3e4}),g=f?.tailscale.hostname,_=f?.tailscale.active===!0,v=f?.tailscale.cliAvailable!==!1,y=g?`https://${g}/`:null,b=(0,Q.useCallback)(async()=>{l(!0),d(null);try{await ut(`serve`),await p()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},[p]),S=(0,Q.useCallback)(async()=>{l(!0),d(null);try{await dt(),await p()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},[p]);if(!i)return null;let C=(0,$.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,$.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.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,$.jsxs)(`span`,{children:[n.stepInstallBefore,(0,$.jsx)(pt,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.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,$.jsx)(`span`,{children:n.stepEnable})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.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,$.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&f?.tailscale.cliAvailable===!1?(0,$.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,$.jsx)(pt,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,h&&!f?(0,$.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,$.jsx)(V,{className:`h-20 rounded-lg`}),(0,$.jsx)(V,{className:`h-20 rounded-lg`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Se,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:_?n.statusActive:n.statusOff}),y?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(ee,{text:y,labels:r})}):null,u?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:_?(0,$.jsxs)(x,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>void S(),children:[c?(0,$.jsx)(A,{className:`mr-1 h-4 w-4 animate-spin`}):null,n.disableServe]}):(0,$.jsxs)(x,{type:`button`,disabled:c||!v,onClick:()=>void b(),children:[c?(0,$.jsx)(A,{className:`mr-1 h-4 w-4 animate-spin`}):(0,$.jsx)(pe,{className:`mr-1 h-4 w-4`}),n.enableServe]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,$.jsx)($e,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?C:(0,$.jsxs)(Se,{children:[(0,$.jsx)(be,{icon:K,title:n.title,subtitle:n.subtitle}),C]})}function ht(){let e=(0,Z.c)(26),t=o(_t),n=s(gt),r;e[0]===t?r=e[1]:(r=a(t),e[0]=t,e[1]=r);let i=r.remoteAccess.lan,c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={preferLan:!0},e[2]=c):c=e[2];let l=ot(n??``,c),u;e[3]!==i.subtitle||e[4]!==i.title?(u=(0,$.jsx)(be,{icon:W,title:i.title,subtitle:i.subtitle}),e[3]=i.subtitle,e[4]=i.title,e[5]=u):u=e[5];let d;e[6]===i.body?d=e[7]:(d=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.body}),e[6]=i.body,e[7]=d);let f;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(ae,{className:`size-3.5`,"aria-hidden":!0}),e[8]=f):f=e[8];let p;e[9]===i.link?p=e[10]:(p=(0,$.jsxs)(y,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[i.link,f]}),e[9]=i.link,e[10]=p);let m;e[11]!==d||e[12]!==p?(m=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[d,p]}),e[11]=d,e[12]=p,e[13]=m):m=e[13];let h;e[14]!==u||e[15]!==m?(h=(0,$.jsxs)(Se,{children:[u,m]}),e[14]=u,e[15]=m,e[16]=h):h=e[16];let g=n??``,_;e[17]===l?_=e[18]:(_=()=>void l.refreshQr(),e[17]=l,e[18]=_);let v;e[19]!==l||e[20]!==g||e[21]!==_?(v=(0,$.jsx)(De,{pairQr:l,gatewayToken:g,lanOnly:!0,onRefreshQr:_}),e[19]=l,e[20]=g,e[21]=_,e[22]=v):v=e[22];let b;return e[23]!==v||e[24]!==h?(b=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h,v]}),e[23]=v,e[24]=h,e[25]=b):b=e[25],b}function gt(e){return e.token}function _t(e){return e.language}function vt(e){let t=(0,Z.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=o(yt),s;t[0]===i?s=t[1]:(s=a(i),t[0]=i,t[1]=s);let c=s.remoteAccess.ssh,[l,u]=(0,Q.useState)(!1),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=async()=>{await H(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(u(!0),setTimeout(()=>u(!1),2e3))},t[2]=d):d=t[2];let f=d,p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-edge bg-surface px-3 py-2 text-xs text-fg-muted`,children:`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`}),t[3]=p):p=t[3];let m,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>void f(),h=(0,$.jsx)(E,{className:`mr-1 h-4 w-4`}),t[4]=m,t[5]=h):(m=t[4],h=t[5]);let g=l?c.copied:c.copy,_;t[6]===g?_=t[7]:(_=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(x,{type:`button`,variant:`ghost`,onClick:m,children:[h,g]})}),t[6]=g,t[7]=_);let v;t[8]!==r||t[9]!==c.hint?(v=r?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:c.hint}):null,t[8]=r,t[9]=c.hint,t[10]=v):v=t[10];let y;t[11]!==_||t[12]!==v?(y=(0,$.jsxs)($.Fragment,{children:[p,_,v]}),t[11]=_,t[12]=v,t[13]=y):y=t[13];let b=y;if(r){let e;t[14]!==c.subtitle||t[15]!==c.title?(e=(0,$.jsx)(be,{icon:B,title:c.title,subtitle:c.subtitle}),t[14]=c.subtitle,t[15]=c.title,t[16]=e):e=t[16];let n;t[17]===b?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:b}),t[17]=b,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(Se,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let S;t[22]!==c.subtitle||t[23]!==c.title?(S=(0,$.jsx)(be,{icon:B,title:c.title,subtitle:c.subtitle}),t[22]=c.subtitle,t[23]=c.title,t[24]=S):S=t[24];let C;t[25]===b?C=t[26]:(C=(0,$.jsx)(`div`,{className:`mt-4`,children:b}),t[25]=b,t[26]=C);let w;return t[27]!==S||t[28]!==C?(w=(0,$.jsxs)(Se,{children:[S,C]}),t[27]=S,t[28]=C,t[29]=w):w=t[29],w}function yt(e){return e.language}function bt(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(vt,{embedded:!0}),e[0]=t):t=e[0],t}function xt(e){switch(e){case`active`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`connecting`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;default:return`bg-surface-hover text-fg-muted`}}function St(e){let t=(0,Z.c)(5),{label:n,kind:r}=e,a;t[0]===r?a=t[1]:(a=i(`rounded-full px-2 py-0.5 text-[11px] font-medium`,xt(r)),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==a?(o=(0,$.jsx)(`span`,{className:a,children:n}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o}function Ct(e){let t=(0,Z.c)(32),{onOpenTab:n}=e,r=o(Et),c;t[0]===r?c=t[1]:(c=a(r),t[0]=r,t[1]=c);let l=c.remoteAccess.guide,u=!!s(Tt),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:3e4},t[2]=d):d=t[2];let{data:f}=m(u?`exposure-status`:null,lt,d),p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p={refreshInterval:15e3},t[3]=p):p=t[3];let{data:h}=m(u?`tunnel-status`:null,T,p),g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g={refreshInterval:6e4},t[4]=g):g=t[4];let{data:_}=m(u?`tunnel-pair-context`:null,de,g);if(!u)return null;let v=f?.tailscale.active===!0,y=h?.state,b=h?.enabled&&y===`connected`,x=h?.enabled&&(y===`connecting`||y===`reconnecting`||!!h?.startProgress||!!h?.frpcDownload),S=(_?.candidates??[]).some(wt),C=v?`active`:`off`,w=v?l.statusActive:l.statusOff,E;t[5]!==l.tailscaleCardTitle||t[6]!==C||t[7]!==w?(E={tab:`tailscale`,icon:K,title:l.tailscaleCardTitle,kind:C,statusLabel:w},t[5]=l.tailscaleCardTitle,t[6]=C,t[7]=w,t[8]=E):E=t[8];let O=b?`active`:x?`connecting`:`off`,k=b?l.statusActive:x?l.statusConnecting:l.statusOff,A;t[9]!==l.publicCardTitle||t[10]!==O||t[11]!==k?(A={tab:`public`,icon:D,title:l.publicCardTitle,kind:O,statusLabel:k},t[9]=l.publicCardTitle,t[10]=O,t[11]=k,t[12]=A):A=t[12];let j=S?`active`:`off`,M=S?l.statusActive:l.statusOff,N;t[13]!==l.reverseProxyCardTitle||t[14]!==j||t[15]!==M?(N={tab:`reverse-proxy`,icon:se,title:l.reverseProxyCardTitle,kind:j,statusLabel:M},t[13]=l.reverseProxyCardTitle,t[14]=j,t[15]=M,t[16]=N):N=t[16];let P;t[17]!==l.sshCardStatus||t[18]!==l.sshCardTitle?(P={tab:`ssh`,icon:B,title:l.sshCardTitle,kind:`off`,statusLabel:l.sshCardStatus},t[17]=l.sshCardStatus,t[18]=l.sshCardTitle,t[19]=P):P=t[19];let F;t[20]!==l.lanCardStatus||t[21]!==l.lanCardTitle?(F={tab:`lan`,icon:W,title:l.lanCardTitle,kind:`off`,statusLabel:l.lanCardStatus},t[20]=l.lanCardStatus,t[21]=l.lanCardTitle,t[22]=F):F=t[22];let I;t[23]!==A||t[24]!==N||t[25]!==P||t[26]!==F||t[27]!==E?(I=[E,A,N,P,F],t[23]=A,t[24]=N,t[25]=P,t[26]=F,t[27]=E,t[28]=I):I=t[28];let L=I,R;return t[29]!==L||t[30]!==n?(R=(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:L.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:i(`flex items-start gap-3 rounded-xl bg-surface-base px-3 py-2.5 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(t,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(St,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[29]=L,t[30]=n,t[31]=R):R=t[31],R}function wt(e){return e.kind===`reverse-proxy`}function Tt(e){return e.token}function Et(e){return e.language}function Dt(e){let t=(0,Z.c)(26),{title:n,description:r,recommended:a,icon:o,onOpen:s,openLabel:c,recommendedLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`group flex w-full flex-col rounded-2xl bg-surface-base px-4 py-4 text-left transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=u):u=t[0];let d;t[1]===o?d=t[2]:(d=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=o,t[2]=d);let f;t[3]===n?f=t[4]:(f=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let p;t[5]!==a||t[6]!==l?(p=a&&l?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:l}):null,t[5]=a,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(le,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==g?(v=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,g,_]}),t[17]=d,t[18]=g,t[19]=v):v=t[19];let y;t[20]===c?y=t[21]:(y=(0,$.jsx)(`span`,{className:`mt-3 text-xs font-medium text-accent`,children:c}),t[20]=c,t[21]=y);let b;return t[22]!==s||t[23]!==y||t[24]!==v?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:u,children:[v,y]}),t[22]=s,t[23]=y,t[24]=v,t[25]=b):b=t[25],b}function Ot(e){let t=(0,Z.c)(83),{onOpenTab:n}=e,r=o(jt),i;t[0]===r?i=t[1]:(i=a(r),t[0]=r,t[1]=i);let c=i.remoteAccess,l=c.guide,u=!!s(At),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:3e4},t[2]=d):d=t[2];let{data:f}=m(u?`exposure-status`:null,lt,d),p;t[3]===f?.conflicts?p=t[4]:(p=f?.conflicts??[],t[3]=f?.conflicts,t[4]=p);let h=p;if(!u){let e;return t[5]===l.needToken?e=t[6]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.needToken}),t[5]=l.needToken,t[6]=e),e}let g;t[7]===n?g=t[8]:(g=(0,$.jsx)(Ct,{onOpenTab:n}),t[7]=n,t[8]=g);let _;t[9]!==h||t[10]!==l.conflictsHint||t[11]!==l.conflictsTitle?(_=h.length>0?(0,$.jsxs)(`div`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/5 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:l.conflictsTitle}),(0,$.jsx)(`p`,{className:`mt-1`,children:l.conflictsHint}),(0,$.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-xs`,children:h.map(kt)})]}):null,t[9]=h,t[10]=l.conflictsHint,t[11]=l.conflictsTitle,t[12]=_):_=t[12];let v;t[13]===l.pickMethod?v=t[14]:(v=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l.pickMethod}),t[13]=l.pickMethod,t[14]=v);let y;t[15]===n?y=t[16]:(y=()=>n(`tailscale`),t[15]=n,t[16]=y);let b;t[17]!==l.configure||t[18]!==l.recommended||t[19]!==l.tailscaleCardDesc||t[20]!==l.tailscaleCardTitle||t[21]!==y?(b=(0,$.jsx)(Dt,{icon:K,title:l.tailscaleCardTitle,description:l.tailscaleCardDesc,recommended:!0,recommendedLabel:l.recommended,openLabel:l.configure,onOpen:y}),t[17]=l.configure,t[18]=l.recommended,t[19]=l.tailscaleCardDesc,t[20]=l.tailscaleCardTitle,t[21]=y,t[22]=b):b=t[22];let x;t[23]===n?x=t[24]:(x=()=>n(`public`),t[23]=n,t[24]=x);let S;t[25]!==l.configure||t[26]!==l.publicCardDesc||t[27]!==l.publicCardTitle||t[28]!==x?(S=(0,$.jsx)(Dt,{icon:D,title:l.publicCardTitle,description:l.publicCardDesc,openLabel:l.configure,onOpen:x}),t[25]=l.configure,t[26]=l.publicCardDesc,t[27]=l.publicCardTitle,t[28]=x,t[29]=S):S=t[29];let C;t[30]===n?C=t[31]:(C=()=>n(`reverse-proxy`),t[30]=n,t[31]=C);let w;t[32]!==l.configure||t[33]!==l.reverseProxyCardDesc||t[34]!==l.reverseProxyCardTitle||t[35]!==C?(w=(0,$.jsx)(Dt,{icon:se,title:l.reverseProxyCardTitle,description:l.reverseProxyCardDesc,openLabel:l.configure,onOpen:C}),t[32]=l.configure,t[33]=l.reverseProxyCardDesc,t[34]=l.reverseProxyCardTitle,t[35]=C,t[36]=w):w=t[36];let T;t[37]===n?T=t[38]:(T=()=>n(`ssh`),t[37]=n,t[38]=T);let E;t[39]!==l.configure||t[40]!==l.sshCardDesc||t[41]!==l.sshCardTitle||t[42]!==T?(E=(0,$.jsx)(Dt,{icon:B,title:l.sshCardTitle,description:l.sshCardDesc,openLabel:l.configure,onOpen:T}),t[39]=l.configure,t[40]=l.sshCardDesc,t[41]=l.sshCardTitle,t[42]=T,t[43]=E):E=t[43];let O;t[44]===n?O=t[45]:(O=()=>n(`lan`),t[44]=n,t[45]=O);let k;t[46]!==l.configure||t[47]!==l.lanCardDesc||t[48]!==l.lanCardTitle||t[49]!==O?(k=(0,$.jsx)(Dt,{icon:W,title:l.lanCardTitle,description:l.lanCardDesc,openLabel:l.configure,onOpen:O}),t[46]=l.configure,t[47]=l.lanCardDesc,t[48]=l.lanCardTitle,t[49]=O,t[50]=k):k=t[50];let A;t[51]!==S||t[52]!==w||t[53]!==E||t[54]!==k||t[55]!==b?(A=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[b,S,w,E,k]}),t[51]=S,t[52]=w,t[53]=E,t[54]=k,t[55]=b,t[56]=A):A=t[56];let j;t[57]!==A||t[58]!==v?(j=(0,$.jsxs)(`div`,{children:[v,A]}),t[57]=A,t[58]=v,t[59]=j):j=t[59];let M;t[60]===l.oneAtATimeHint?M=t[61]:(M=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:l.oneAtATimeHint}),t[60]=l.oneAtATimeHint,t[61]=M);let N;t[62]===c.advanced.proxyTitle?N=t[63]:(N=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.advanced.proxyTitle}),t[62]=c.advanced.proxyTitle,t[63]=N);let P;t[64]===c.advanced.proxyBody?P=t[65]:(P=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.advanced.proxyBody}),t[64]=c.advanced.proxyBody,t[65]=P);let F;t[66]!==r||t[67]!==c.advanced.proxyDocs?(F=(0,$.jsx)($e,{language:r,label:c.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[66]=r,t[67]=c.advanced.proxyDocs,t[68]=F):F=t[68];let I;t[69]!==N||t[70]!==P||t[71]!==F?(I=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base px-4 py-3`,children:[N,P,F]}),t[69]=N,t[70]=P,t[71]=F,t[72]=I):I=t[72];let L;t[73]!==l.docsLink||t[74]!==r?(L=(0,$.jsx)($e,{language:r,label:l.docsLink}),t[73]=l.docsLink,t[74]=r,t[75]=L):L=t[75];let R;return t[76]!==j||t[77]!==M||t[78]!==I||t[79]!==L||t[80]!==g||t[81]!==_?(R=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[g,_,j,M,I,L]}),t[76]=j,t[77]=M,t[78]=I,t[79]=L,t[80]=g,t[81]=_,t[82]=R):R=t[82],R}function kt(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function At(e){return e.token}function jt(e){return e.language}async function Mt(e){let t=await l(f(`/api/tunnel/pair/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 Nt(e){await c(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function Pt(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 Ft(){return(0,Q.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`)||Pt(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function It(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,w,`dark:border-edge`)}function Lt(e){return(e?.candidates.find(e=>e.kind===`reverse-proxy`))?.url?.trim()||null}function Rt(e){return(e?.candidates.find(e=>e.kind===`lan`&&e.reachable))?.url?.trim()||null}function zt(){let e=o(e=>e.language),t=a(e).remoteAccess.reverseProxy,n=!!s(e=>e.token),r=Ft(),{mutate:c}=p(),{data:l,mutate:d}=m(n?`tunnel-pair-context`:null,de,{refreshInterval:6e4}),f=Lt(l),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)({busy:!1,result:null}),[y,b]=(0,Q.useState)({busy:!1,error:null});(0,Q.useEffect)(()=>{h||(f?g(f):r&&g(r))},[f,r,h]);let S=(0,Q.useMemo)(()=>h.trim()||(f??r??``),[f,r,h]),C=!f&&!!r&&S===r,w=Rt(l),{data:T,mutate:E}=m(n&&S?[`reverse-proxy-pair`,S]:null,()=>F(),{refreshInterval:4*6e4,revalidateOnFocus:!1}),D=(0,Q.useMemo)(()=>!S||!T?.pairingSecret?``:u({baseUrl:S,pairingSecret:T.pairingSecret,lanUrl:w}),[S,w,T?.pairingSecret]),O=he(()=>nt(D),[D],{enabled:!!D,initial:null,errorData:null}),k=(0,Q.useCallback)(async()=>{let e=h.trim()||S;if(e){v({busy:!0,result:null});try{v({busy:!1,result:await Mt(e)})}catch(e){v({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:e instanceof Error?e.message:String(e)}})}}},[h,S]),j=(0,Q.useCallback)(async()=>{let e=S.trim();if(e){b({busy:!0,error:null});try{await Nt(e),await d(),await c(`tunnel-pair-context`),b({busy:!1,error:null})}catch(e){b({busy:!1,error:e instanceof Error?e.message:String(e)})}}},[S,c,d]),M=(0,Q.useCallback)(async()=>{b({busy:!0,error:null});try{await Nt(null),await d(),await c(`tunnel-pair-context`),g(``),v({busy:!1,result:null}),b({busy:!1,error:null})}catch(e){b({busy:!1,error:e instanceof Error?e.message:String(e)})}},[c,d]),N=(0,Q.useCallback)(async()=>{await E()},[E]);return n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(Se,{children:[(0,$.jsx)(be,{icon:K,title:t.title,subtitle:t.subtitle}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:t.urlLabel}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[(0,$.jsx)(`input`,{id:`reverse-proxy-url`,className:i(It(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:t.urlPlaceholder,value:h,onChange:e=>{g(e.target.value),v({busy:!1,result:null})}}),(0,$.jsxs)(x,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:()=>void k(),disabled:_.busy||!h.trim(),children:[_.busy?(0,$.jsx)(A,{className:`size-3.5 animate-spin`}):null,_.busy?t.probing:t.probeButton]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.urlHint}),C&&r?(0,$.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,$.jsx)(`div`,{className:`font-medium`,children:t.autoDetectedTitle}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:r}),(0,$.jsx)(`p`,{className:`mt-1`,children:t.autoDetectedHint})]}):null,_.result?(0,$.jsx)(Bt,{result:_.result,labels:t.probeStatus}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[S&&f!==S?(0,$.jsxs)(x,{type:`button`,onClick:()=>void j(),disabled:y.busy,children:[y.busy?(0,$.jsx)(A,{className:`size-3.5 animate-spin`}):null,y.busy?t.saving:t.saveAsDefault]}):null,f?(0,$.jsx)(x,{type:`button`,variant:`ghost`,onClick:()=>void M(),disabled:y.busy,children:t.clear}):null]}),y.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:y.error}):null,(0,$.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:t.certWarning})]})]}),(0,$.jsxs)(Se,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:t.qrTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.qrSubtitle})]}),D?(0,$.jsxs)(x,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void N(),children:[(0,$.jsx)(re,{className:`size-4`}),t.refreshQr]}):null]}),S?T?.pairingSecret?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[(0,$.jsxs)(`div`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`baseUrl:`}),` `,S,w?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`br`,{}),(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`lanUrl:`}),` `,w]}):null]}),O.data?(0,$.jsx)(`img`,{src:O.data,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):O.loading?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.encoding}):null,(0,$.jsx)(ee,{text:D,labels:{copy:t.copyLink,copied:t.copied,copyFailed:a(e).clipboard.copyFailed}})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.mintingSecret}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUrlYet})]})]}):null}function Bt(e){let t=(0,Z.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,$.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,$.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.mobileReady||t[5]!==n.mobilePairing?(a=n.mobilePairing?(0,$.jsxs)($.Fragment,{children:[` · `,(0,$.jsx)(`span`,{children:r.mobileReady})]}):null,t[4]=r.mobileReady,t[5]=n.mobilePairing,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,$.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,$.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,$.jsxs)($.Fragment,{children:[` — `,(0,$.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,$.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}var Vt=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Ht(e){return e&&Vt.includes(e)?e:`guide`}function Ut(e,t){return e.tabs[t]}function Wt(e,t){return e.tabIntro[t]}function Gt(e){switch(e){case`tailscale`:return`tailscale-serve`;case`public`:return`public-tunnel`;case`reverse-proxy`:return`reverse-proxy`;case`ssh`:return`ssh-tunnel`;case`lan`:return`lan`;default:return}}function Kt(e){let t=(0,Z.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(Ot,{onOpenTab:r}),t[0]=r,t[1]=e),e}case`tailscale`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(mt,{embedded:!0}),t[2]=e):e=t[2],e}case`public`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ct,{embedded:!0}),t[3]=e):e=t[3],e}case`reverse-proxy`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zt,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(bt,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ht,{}),t[6]=e):e=t[6],e}}}function qt(){let e=(0,Z.c)(2),t=o(Yt),n=a(t).remoteAccess,r=!!s(Jt),[i,c]=N(),l=Ht(i.get(`tab`)),u;e[0]===c?u=e[1]:(u=e=>{c(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[0]=c,e[1]=u);let d=u,f=Wt(n,l),p=Vt.map(e=>({id:e,label:Ut(n,e)}));return(0,$.jsxs)(ve,{children:[(0,$.jsx)(ge,{title:n.pageTitle,subtitle:n.pageSubtitle,meta:(0,$.jsx)($e,{language:t,label:n.docsLink,section:Gt(l),className:`mt-1`})}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(we,{items:p,activeTab:l,onChange:d,ariaLabel:n.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(_e,{id:l,activeTab:l,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:Ut(n,l),hint:l===`public`?void 0:f,children:(0,$.jsx)(Kt,{tab:l,onOpenTab:d})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.guide.needToken})]})}function Jt(e){return e.token}function Yt(e){return e.language}export{qt as RemoteAccessHub};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-YzjnURPJ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{a as s,n as c}from"./fetch-BMjlW0g1.js";import{t as l}from"./url-DFGNSBNT.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Ai as d,Ba as f,Bs as p,Ci as m,Di as h,Do as g,Ds as ee,Dt as _,Ei as v,Eo as y,Es as b,Et as x,Ga as te,Gc as S,Gs as C,Ka as ne,Mc as w,Mi as T,Nc as E,Ni as re,Ol as D,Oo as O,Sc as k,Si as A,Ti as j,Tt as M,Ua as ie,Va as N,Vo as P,Wa as F,bl as I,bo as L,ec as R,ga as z,ha as B,io as V,ji as ae,ki as oe,ko as H,no as U,oo as W,os as G,pa as se,rc as ce,so as K,tc as le,us as ue,wi as de,xi as fe,xl as pe,xo as q}from"./index-C4k6QSXw.js";import{n as J,t as Y}from"./settings-form-section-DptSsbWd.js";import{t as X}from"./page-tabs-RnYYOIWO.js";import{n as me,r as he}from"./segmented-styles-BL8oLBEp.js";var Z=e(t(),1),ge=n(),Q=r();function _e(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function ve(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ye(e){let t=(0,ge.c)(105),{session:n,variant:r,labels:a,sessionAgentId:o,sessionAgentAvatar:s,onOpen:c,onAction:l}=e,u;t[0]!==a.unnamedSession||t[1]!==n.name?(u=n.name?.trim()||a.unnamedSession,t[0]=a.unnamedSession,t[1]=n.name,t[2]=u):u=t[2];let d=u,f;t[3]===n.name?f=t[4]:(f=n.name?.trim(),t[3]=n.name,t[4]=f);let m=!!f,h=n.status===`archived`,g=n.status===`pinned`,_=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,v;t[5]===_?v=t[6]:(v=i(`group flex min-w-0 w-full max-w-full cursor-pointer flex-col rounded-xl bg-surface-base text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover active:scale-[0.99]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,_),t[5]=_,t[6]=v);let y;t[7]===c?y=t[8]:(y=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=y);let x=r===`list`&&`sm:py-3`,te;t[9]===x?te=t[10]:(te=i(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,x),t[9]=x,t[10]=te);let S;t[11]===n.sourceChannel?S=t[12]:(S=(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Q.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.sourceChannel})}),t[11]=n.sourceChannel,t[12]=S);let C;t[13]===g?C=t[14]:(C=g?(0,Q.jsx)(ee,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=g,t[14]=C);let ne;t[15]===n.updatedAt?ne=t[16]:(ne=_e(n.updatedAt),t[15]=n.updatedAt,t[16]=ne);let T;t[17]===ne?T=t[18]:(T=(0,Q.jsx)(`span`,{children:ne}),t[17]=ne,t[18]=T);let E;t[19]!==T||t[20]!==C?(E=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[C,T]}),t[19]=T,t[20]=C,t[21]=E):E=t[21];let D;t[22]!==E||t[23]!==te||t[24]!==S?(D=(0,Q.jsxs)(`div`,{className:te,children:[S,E]}),t[22]=E,t[23]=te,t[24]=S,t[25]=D):D=t[25];let k=r===`list`&&`sm:py-3`,A;t[26]===k?A=t[27]:(A=i(`min-w-0 flex-1 px-3 py-2`,k),t[26]=k,t[27]=A);let j=r===`list`&&`sm:items-start`,M;t[28]===j?M=t[29]:(M=i(`flex gap-3`,j),t[28]=j,t[29]=M);let ie;t[30]!==s||t[31]!==o?(ie=(0,Q.jsx)(re,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=s,t[31]=o,t[32]=ie):ie=t[32];let N;t[33]===d?N=t[34]:(N=(0,Q.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:d,children:d}),t[33]=d,t[34]=N);let F;t[35]!==n.key||t[36]!==m?(F=m?(0,Q.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[35]=n.key,t[36]=m,t[37]=F):F=t[37];let R;t[38]!==N||t[39]!==F?(R=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[N,F]}),t[38]=N,t[39]=F,t[40]=R):R=t[40];let z;t[41]!==M||t[42]!==ie||t[43]!==R?(z=(0,Q.jsxs)(`div`,{className:M,children:[ie,R]}),t[41]=M,t[42]=ie,t[43]=R,t[44]=z):z=t[44];let B;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Q.jsx)(p,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=B):B=t[45];let V;t[46]===n.messageCount?V=t[47]:(V=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[B,n.messageCount]}),t[46]=n.messageCount,t[47]=V);let ae;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Q.jsx)(O,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=ae):ae=t[48];let oe;t[49]===n.estimatedTokens?oe=t[50]:(oe=ve(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=oe);let H;t[51]===oe?H=t[52]:(H=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[ae,oe]}),t[51]=oe,t[52]=H);let U;t[53]!==V||t[54]!==H?(U=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[V,H]}),t[53]=V,t[54]=H,t[55]=U):U=t[55];let W;t[56]===n.tags?W=t[57]:(W=n.tags.length>0?(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Se),n.tags.length>3?(0,Q.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=W);let G;t[58]!==A||t[59]!==z||t[60]!==U||t[61]!==W?(G=(0,Q.jsxs)(`div`,{className:A,children:[z,U,W]}),t[58]=A,t[59]=z,t[60]=U,t[61]=W,t[62]=G):G=t[62];let se;t[63]===l?se=t[64]:(se=()=>l(`continue`),t[63]=l,t[64]=se);let ce;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Q.jsx)(p,{className:`size-4`,strokeWidth:1.75}),t[65]=ce):ce=t[65];let K;t[66]!==a.continueChat||t[67]!==se?(K=(0,Q.jsx)(`button`,{type:`button`,className:L,title:a.continueChat,"aria-label":a.continueChat,onClick:se,children:ce}),t[66]=a.continueChat,t[67]=se,t[68]=K):K=t[68];let le;t[69]!==h||t[70]!==a.archive||t[71]!==a.unarchive||t[72]!==l?(le=h?(0,Q.jsx)(`button`,{type:`button`,className:L,title:a.unarchive,"aria-label":a.unarchive,onClick:()=>l(`unarchive`),children:(0,Q.jsx)(pe,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:L,title:a.archive,"aria-label":a.archive,onClick:()=>l(`archive`),children:(0,Q.jsx)(I,{className:`size-4`,strokeWidth:1.75})}),t[69]=h,t[70]=a.archive,t[71]=a.unarchive,t[72]=l,t[73]=le):le=t[73];let ue;t[74]!==g||t[75]!==a.pin||t[76]!==a.unpin||t[77]!==l?(ue=g?(0,Q.jsx)(`button`,{type:`button`,className:L,title:a.unpin,"aria-label":a.unpin,onClick:()=>l(`unpin`),children:(0,Q.jsx)(b,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:L,title:a.pin,"aria-label":a.pin,onClick:()=>l(`pin`),children:(0,Q.jsx)(ee,{className:`size-4`,strokeWidth:1.75})}),t[74]=g,t[75]=a.pin,t[76]=a.unpin,t[77]=l,t[78]=ue):ue=t[78];let de;t[79]===l?de=t[80]:(de=()=>l(`export`),t[79]=l,t[80]=de);let fe;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,Q.jsx)(w,{className:`size-4`,strokeWidth:1.75}),t[81]=fe):fe=t[81];let q;t[82]!==a.export||t[83]!==de?(q=(0,Q.jsx)(`button`,{type:`button`,className:L,title:a.export,"aria-label":a.export,onClick:de,children:fe}),t[82]=a.export,t[83]=de,t[84]=q):q=t[84];let J;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(J=i(L,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=J):J=t[85];let Y;t[86]===l?Y=t[87]:(Y=()=>l(`delete`),t[86]=l,t[87]=Y);let X;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Q.jsx)(P,{className:`size-4`,strokeWidth:1.75}),t[88]=X):X=t[88];let me;t[89]!==a.delete||t[90]!==Y?(me=(0,Q.jsx)(`button`,{type:`button`,className:J,title:a.delete,"aria-label":a.delete,onClick:Y,children:X}),t[89]=a.delete,t[90]=Y,t[91]=me):me=t[91];let he;t[92]!==K||t[93]!==le||t[94]!==ue||t[95]!==q||t[96]!==me?(he=(0,Q.jsxs)(`div`,{role:`group`,className:`flex flex-wrap items-center gap-0.5 border-t border-edge-subtle/80 bg-surface-hover/25 p-2 dark:border-edge-subtle`,onClick:xe,onKeyDown:be,children:[K,le,ue,q,me]}),t[92]=K,t[93]=le,t[94]=ue,t[95]=q,t[96]=me,t[97]=he):he=t[97];let Z;return t[98]!==c||t[99]!==D||t[100]!==G||t[101]!==v||t[102]!==he||t[103]!==y?(Z=(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,className:v,onClick:c,onKeyDown:y,children:[D,G,he]}),t[98]=c,t[99]=D,t[100]=G,t[101]=v,t[102]=he,t[103]=y,t[104]=Z):Z=t[104],Z}function be(e){return e.stopPropagation()}function xe(e){return e.stopPropagation()}function Se(e){return(0,Q.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ce(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function we(e){let t=$(e)?e:{},n=$(t.session)?t.session:{},r=$(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:Ce(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Te(e){await c(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),B()}function Ee(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,y,`dark:border-edge`)}var De=M();function Oe({hasToken:e}){let t=a(o(e=>e.language)).sessions.config,{data:n,isLoading:r}=z(e),i=(0,Z.useMemo)(()=>n?.payload?.config===void 0?null:we(n.payload.config),[n]),[s,c]=(0,Z.useReducer)(De,{form:null,baseline:null}),l=s.form,u=s.baseline,[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),h=(0,Z.useRef)(!1),ee=(0,Z.useRef)(null);x({enabled:e,parsed:i,dirty:h.current,trackedParsedRef:ee,dispatch:c,onResetDirty:()=>{h.current=!1}});let _=l&&u&&JSON.stringify(l)!==JSON.stringify(u),v=(0,Z.useCallback)(e=>{h.current=!0,c({type:`patch`,patch:e})},[]);return!e||!l?r?(0,Q.jsx)(Y,{children:(0,Q.jsx)(C,{className:`size-4 animate-spin text-fg-muted`})}):null:(0,Q.jsxs)(Y,{children:[(0,Q.jsx)(J,{icon:E,title:t.title,subtitle:t.hint}),(0,Q.jsxs)(`div`,{className:`mb-4 flex justify-end gap-2`,children:[(0,Q.jsx)(g,{type:`button`,variant:`secondary`,disabled:!_||d,onClick:()=>c({type:`discard`}),children:t.discard}),(0,Q.jsx)(g,{type:`button`,variant:`primary`,disabled:!_||d,onClick:()=>{(async()=>{f(!0),m(null);try{await Te(l),h.current=!1,c({type:`saved`,value:l})}catch(e){m(e instanceof Error?e.message:t.saveError)}finally{f(!1)}})()},children:d?t.saving:t.save})]}),p?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:p}):null,(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Q.jsxs)(U,{className:Ee(),value:l.dmScope,onChange:e=>v({dmScope:e.target.value}),children:[(0,Q.jsx)(V,{value:`main`,children:t.dmScopeMain}),(0,Q.jsx)(V,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Q.jsx)(V,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Q.jsx)(V,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Q.jsx)(`input`,{type:`number`,min:0,className:Ee(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();v({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Q.jsx)(`input`,{type:`number`,min:1,className:Ee(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();v({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function ke(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function Ae(e){let t=(0,ge.c)(60),{open:n,loading:r,session:a,sessionAgentId:o,sessionAgentAvatar:s,labels:c,onClose:l,onArchive:u,onUnarchive:d,onPin:p,onUnpin:m,onExport:h,onDelete:ee}=e,_=a?.status===`archived`,v=a?.status===`pinned`,y;t[0]===l?y=t[1]:(y=e=>!e&&l(),t[0]=l,t[1]=y);let b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(ie,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,K)}),t[2]=b):b=t[2];let x;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=i(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-panel shadow-popover outline-none`,W,`dark:border-edge`),t[3]=x):x=t[3];let S;t[4]!==a||t[5]!==s||t[6]!==o?(S=a&&o?(0,Q.jsx)(re,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=a,t[5]=s,t[6]=o,t[7]=S):S=t[7];let C;t[8]!==c.unnamedSession||t[9]!==a?.name?(C=a?.name?.trim()||c.unnamedSession,t[8]=c.unnamedSession,t[9]=a?.name,t[10]=C):C=t[10];let w;t[11]===C?w=t[12]:(w=(0,Q.jsx)(ne,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:C}),t[11]=C,t[12]=w);let T;t[13]!==S||t[14]!==w?(T=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[S,w]}),t[13]=S,t[14]=w,t[15]=T):T=t[15];let E;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Q.jsx)(H,{className:`size-5`,strokeWidth:1.75}),t[16]=E):E=t[16];let D;t[17]===c.close?D=t[18]:(D=(0,Q.jsx)(f,{asChild:!0,children:(0,Q.jsx)(g,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":c.close,children:E})}),t[17]=c.close,t[18]=D);let O;t[19]!==T||t[20]!==D?(O=(0,Q.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[T,D]}),t[19]=T,t[20]=D,t[21]=O):O=t[21];let k;t[22]!==c.detailLoading||t[23]!==c.detailMessages||t[24]!==r||t[25]!==a?(k=r?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.detailLoading}):a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Q.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:a.key})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Q.jsxs)(`span`,{children:[a.messageCount,` msgs · `,a.estimatedTokens,` tok`]})})]}),(0,Q.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:c.detailMessages}),(0,Q.jsx)(`ul`,{className:`space-y-3`,children:a.messages.map(je)})]}):null,t[22]=c.detailLoading,t[23]=c.detailMessages,t[24]=r,t[25]=a,t[26]=k):k=t[26];let A;t[27]===k?A=t[28]:(A=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:k}),t[27]=k,t[28]=A);let j;t[29]!==c.detailExport||t[30]!==h?(j=(0,Q.jsx)(g,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:c.detailExport}),t[29]=c.detailExport,t[30]=h,t[31]=j):j=t[31];let M;t[32]!==_||t[33]!==c.archive||t[34]!==c.unarchive||t[35]!==u||t[36]!==d?(M=_?(0,Q.jsx)(g,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:c.unarchive}):(0,Q.jsx)(g,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:c.archive}),t[32]=_,t[33]=c.archive,t[34]=c.unarchive,t[35]=u,t[36]=d,t[37]=M):M=t[37];let P;t[38]!==v||t[39]!==c.pin||t[40]!==c.unpin||t[41]!==p||t[42]!==m?(P=v?(0,Q.jsx)(g,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:c.unpin}):(0,Q.jsx)(g,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:c.pin}),t[38]=v,t[39]=c.pin,t[40]=c.unpin,t[41]=p,t[42]=m,t[43]=P):P=t[43];let I;t[44]!==c.delete||t[45]!==ee?(I=(0,Q.jsx)(g,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:ee,children:c.delete}),t[44]=c.delete,t[45]=ee,t[46]=I):I=t[46];let L;t[47]!==j||t[48]!==M||t[49]!==P||t[50]!==I?(L=(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[j,M,P,I]})}),t[47]=j,t[48]=M,t[49]=P,t[50]=I,t[51]=L):L=t[51];let R;t[52]!==O||t[53]!==A||t[54]!==L?(R=(0,Q.jsxs)(F,{children:[b,(0,Q.jsxs)(N,{className:x,"aria-describedby":void 0,children:[O,A,L]})]}),t[52]=O,t[53]=A,t[54]=L,t[55]=R):R=t[55];let z;return t[56]!==n||t[57]!==y||t[58]!==R?(z=(0,Q.jsx)(te,{open:n,onOpenChange:y,children:R}),t[56]=n,t[57]=y,t[58]=R,t[59]=z):z=t[59],z}function je(e){return(0,Q.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Q.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:ke(e.content)})]},`${e.timestamp??``}-${e.role}-${ke(e.content).slice(0,24)}`)}var Me=20;function Ne(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var Pe=new Set([`all`,`active`,`pinned`,`archived`]),Fe=new Set([`grid`,`list`]),Ie=[`sessions`,`settings`];function Le(e){return e&&Ie.includes(e)?e:`sessions`}function Re(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function ze(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function Be(e){let t=(0,ge.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Ie.map(e=>({id:e,label:Re(n,e),icon:e===`sessions`?ce:G})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Q.jsx)(X,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function Ve(e){let t=(0,ge.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a===void 0?!1:a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mb-5`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:Re(n,r)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:ze(n,r)})]}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Q.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function He(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:Pe.has(t)?t:`all`,viewMode:Fe.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function Ue(){let e=a(o(e=>e.language)),t=e.sessions,n=s(e=>e.token),r=!!n,{data:c,mutate:l}=u(r?[`gateway-chat-agents`,n]:null,se,{revalidateOnFocus:!1}),f=c?.defaultId??`main`,p=c?.items??[],[y,b]=D(),x=Le(y.get(`tab`)),C=(0,Z.useCallback)(e=>{let t=new URLSearchParams(y);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),b(t,{replace:!0})},[y,b]),[w,E]=(0,Z.useReducer)(_,y,He),{searchInput:re,debouncedSearch:O,statusFilter:M,viewMode:P,channelFilter:L,sessions:z,loading:B,error:V,hasMore:H,stats:U,detailOpen:G,detailLoading:pe,detailSession:J,confirmOpen:Y,confirmKey:X}=w;(0,Z.useEffect)(()=>{let e=setTimeout(()=>{let e=re.trim();O!==e&&E({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[re,O]);let ge=y.toString(),_e=(0,Z.useRef)(ge);if(_e.current!==ge){_e.current=ge;let e=y.get(`q`)??``,t=y.get(`status`),n=y.get(`view`),r=(y.get(`channel`)??``).trim(),i=Pe.has(t)?t:`all`,a=Fe.has(n)?n:`grid`,o=e.trim();E({type:`patch`,patch:{...re===e?{}:{searchInput:e},...O===o?{}:{debouncedSearch:o},...M===i?{}:{statusFilter:i},...P===a?{}:{viewMode:a},...L===r?{}:{channelFilter:r}}})}(0,Z.useEffect)(()=>{let e=new URLSearchParams(y),t=O.trim();t?e.set(`q`,t):e.delete(`q`),M===`all`?e.delete(`status`):e.set(`status`,M),P===`grid`?e.delete(`view`):e.set(`view`,P),L?e.set(`channel`,L):e.delete(`channel`),e.toString()!==y.toString()&&b(e,{replace:!0})},[O,y,b,M,P,L]),(0,Z.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=!1;return(async()=>{E({type:`patch`,patch:{loading:!0,error:null}});try{let t=await v({limit:Me,offset:0,...O?{search:O}:{},...M===`all`?{}:{status:M},...L?{channel:L}:{}});if(e)return;E({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||E({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||E({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,x,O,M,L,t.loadError]),(0,Z.useEffect)(()=>{!r||x!==`sessions`||j().then(e=>E({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,x]),(0,Z.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=()=>void l();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,x,l]),(0,Z.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||E({type:`patch`,patch:{sessions:z.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:J&&J.key===t.key?{...J,name:t.name}:J}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,x,z,J]);let ve=(0,Z.useCallback)(async()=>{if(!(!r||B||!H)){E({type:`patch`,patch:{loading:!0,error:null}});try{let e=await v({limit:Me,offset:z.length,...O?{search:O}:{},...M===`all`?{}:{status:M},...L?{channel:L}:{}});E({type:`patch`,patch:{sessions:[...z,...e.items],hasMore:e.hasMore}})}catch(e){E({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{E({type:`patch`,patch:{loading:!1}})}}},[r,B,H,z.length,O,M,L,t.loadError]),be=(0,Z.useCallback)((e,t)=>{E({type:`patch`,patch:{sessions:z.map(n=>n.key===e?{...n,status:t}:n),detailSession:J&&J.key===e?{...J,status:t}:J}})},[z,J]),xe=(0,Z.useCallback)(async e=>{E({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{E({type:`patch`,patch:{detailSession:await de(e)}})}catch{E({type:`patch`,patch:{detailOpen:!1}})}finally{E({type:`patch`,patch:{detailLoading:!1}})}},[]),Se=e=>{xe(e)},$=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){E({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await fe(e),be(e,`archived`);break;case`unarchive`:await oe(e),be(e,`active`);break;case`pin`:await h(e),be(e,`pinned`);break;case`unpin`:await d(e),be(e,`active`);break;case`export`:{let t=await m(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}j().then(e=>E({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ce=async e=>{try{await A(e),E({type:`patch`,patch:{sessions:z.filter(t=>t.key!==e),detailSession:J?.key===e?null:J,...J?.key===e?{detailOpen:!1}:{}}}),j().then(e=>E({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,unnamedSession:e.chat.newSession},Te={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},Ee=[{key:`all`,label:t.filterAll,icon:ce},{key:`active`,label:t.filterActive,icon:S},{key:`pinned`,label:t.filterPinned,icon:ee},{key:`archived`,label:t.filterArchived,icon:I}],De=(()=>{let e=Object.entries(U?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Q.jsx)(`header`,{className:`flex flex-col gap-2`,children:(0,Q.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title})}),(0,Q.jsx)(Be,{s:t,activeTab:x,onChange:C}),(0,Q.jsx)(Ve,{s:t,id:`settings`,activeTab:x,plain:!0,children:(0,Q.jsx)(Oe,{hasToken:r})}),(0,Q.jsxs)(Ve,{s:t,id:`sessions`,activeTab:x,plain:!0,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Ee.map(({key:e,label:t,icon:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":M===e,onClick:()=>E({type:`patch`,patch:{statusFilter:e}}),className:i(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,q.transition,q.focusRingPanel,M===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,Q.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Q.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Q.jsx)(ue,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,value:re,onChange:e=>E({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":O||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!L,onClick:()=>E({type:`patch`,patch:{channelFilter:``}}),className:i(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,q.transition,q.focusRingPanel,L?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),De.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":L===e,onClick:()=>E({type:`patch`,patch:{channelFilter:e}}),className:i(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,q.transition,q.focusRingPanel,L===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,U?.byChannel?.[e]==null?null:(0,Q.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:U.byChannel[e]})]},e))]}),U?(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[U.totalSessions,t.totalSessions],[U.activeSessions,t.activeSessions],[U.pinnedSessions,t.pinnedSessions],[U.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Q.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Q.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,V?(0,Q.jsx)(`div`,{className:`rounded-lg border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,children:V}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Ne(t.sessionCount,{count:z.length})}),(0,Q.jsxs)(`div`,{className:he,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Q.jsx)(g,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":P===`grid`,onClick:()=>E({type:`patch`,patch:{viewMode:`grid`}}),className:i(me,`size-7 p-0`,P===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,P===`grid`&&`text-accent-fg`),children:(0,Q.jsx)(le,{className:`size-3.5`,strokeWidth:1.5})}),(0,Q.jsx)(g,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":P===`list`,onClick:()=>E({type:`patch`,patch:{viewMode:`list`}}),className:i(me,`size-9 p-0`,P===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,P===`list`&&`text-accent-fg`),children:(0,Q.jsx)(R,{className:`size-3.5`,strokeWidth:1.5})})]})]}),B&&z.length===0?(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,Q.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):z.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,Q.jsx)(k,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Q.jsx)(g,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:i(`grid min-w-0 gap-3`,P===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":O||void 0,children:z.map(e=>{let t=T(e,f);return(0,Q.jsx)(ye,{session:e,variant:P,labels:we,sessionAgentId:t,sessionAgentAvatar:ae(t,p),onOpen:()=>Se(e.key),onAction:t=>void $(e.key,t)},e.key)})}),H?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(g,{type:`button`,variant:`secondary`,disabled:B,onClick:()=>void ve(),children:t.loadMore})}):null]})]})]}),(0,Q.jsx)(Ae,{open:G,loading:pe,session:J,sessionAgentId:J?T(J,f):void 0,sessionAgentAvatar:J?ae(T(J,f),p):void 0,labels:Te,onClose:()=>{E({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>J&&void $(J.key,`archive`),onUnarchive:()=>J&&void $(J.key,`unarchive`),onPin:()=>J&&void $(J.key,`pin`),onUnpin:()=>J&&void $(J.key,`unpin`),onExport:()=>J&&void $(J.key,`export`),onDelete:()=>J&&E({type:`patch`,patch:{confirmKey:J.key,confirmOpen:!0}})}),(0,Q.jsx)(te,{open:Y,onOpenChange:e=>E({type:`patch`,patch:{confirmOpen:e}}),children:(0,Q.jsxs)(F,{children:[(0,Q.jsx)(ie,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,K)}),(0,Q.jsxs)(N,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,W),children:[(0,Q.jsx)(ne,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:X?Ne(t.deleteSessionMessage,{name:z.find(e=>e.key===X)?.name?.trim()||e.chat.newSession}):``}),(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>E({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Q.jsx)(g,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{X&&Ce(X),E({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Q.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{Ue as SessionsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{hr as e}from"./index-C4k6QSXw.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-YzjnURPJ.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{Aa as o,Da as s,Dl as c,Ea as l,Fa as u,Ia as d,La as f,Ma as p,Na as m,Oa as h,Pa as g,Ra as _,Ta as v,ja as y,ka as b,wa as x,wl as S}from"./index-C4k6QSXw.js";var C=n(),w=e(t(),1),T=r(),E=[`overview`,`appearance`,`keyboard-shortcuts`,`user-profile`,`system`,`desktop-pet`,`desktop-app`,`credentials`,`capability-presets`,`gateway`,`heartbeat`,`remote-access`,`shares`,`goals`,`dreams`],D=(0,w.lazy)(()=>u().then(e=>({default:e.SetupStatusPanel}))),O=(0,w.lazy)(()=>v().then(e=>({default:e.AppearanceSettingsPanel}))),k=(0,w.lazy)(()=>p().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),A=(0,w.lazy)(()=>_().then(e=>({default:e.UserProfileSettingsPanel}))),j=(0,w.lazy)(()=>f().then(e=>({default:e.SystemSettingsPanel}))),M=(0,w.lazy)(()=>s().then(e=>({default:e.DesktopPetSettings}))),N=(0,w.lazy)(()=>x().then(e=>({default:e.AppManagementSettingsPanel}))),P=(0,w.lazy)(()=>m().then(e=>({default:e.ModelsHubPanel}))),F=(0,w.lazy)(()=>b().then(e=>({default:e.GatewaySettingsPanel}))),I=(0,w.lazy)(()=>y().then(e=>({default:e.HeartbeatSettingsPanel}))),L=(0,w.lazy)(()=>g().then(e=>({default:e.RemoteAccessHub}))),R=(0,w.lazy)(()=>d().then(e=>({default:e.SharesSettingsPanel}))),z=(0,w.lazy)(()=>h().then(e=>({default:e.DreamingSettingsPanel}))),B=(0,w.lazy)(()=>o().then(e=>({default:e.GoalsSettingsPanel}))),V=(0,w.lazy)(()=>l().then(e=>({default:e.CapabilityPresetsSettingsPanel})));function H(){let e=(0,C.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,T.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,T.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function U(e){return(0,T.jsx)(w.Suspense,{fallback:(0,T.jsx)(H,{}),children:(0,T.jsx)(e,{})})}function W(){let e=(0,C.c)(30),{section:t}=c(),n=a(G),r,o,s,l,u;if(e[0]!==n||e[1]!==t){u=Symbol.for(`react.early_return_sentinel`);bb0:{let a=i(n);if(!t||!E.includes(t)){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,T.jsx)(S,{to:`/settings/overview`,replace:!0}),e[7]=t):t=e[7],u=t;break bb0}let c=t;if(c===`overview`){let t;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(D),e[8]=t):t=e[8],u=t;break bb0}let d=a.settingsSections[c];if(c===`appearance`){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(O),e[9]=t):t=e[9],u=t;break bb0}if(c===`keyboard-shortcuts`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(k),e[10]=t):t=e[10],u=t;break bb0}if(c===`user-profile`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(A),e[11]=t):t=e[11],u=t;break bb0}if(c===`system`){let t;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(j),e[12]=t):t=e[12],u=t;break bb0}if(c===`desktop-pet`){let t;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(M),e[13]=t):t=e[13],u=t;break bb0}if(c===`desktop-app`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(N),e[14]=t):t=e[14],u=t;break bb0}if(c===`credentials`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(P),e[15]=t):t=e[15],u=t;break bb0}if(c===`capability-presets`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(V),e[16]=t):t=e[16],u=t;break bb0}if(c===`gateway`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(F),e[17]=t):t=e[17],u=t;break bb0}if(c===`heartbeat`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(I),e[18]=t):t=e[18],u=t;break bb0}if(c===`remote-access`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(L),e[19]=t):t=e[19],u=t;break bb0}if(c===`shares`){let t;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(R),e[20]=t):t=e[20],u=t;break bb0}if(c===`dreams`){let t;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(z),e[21]=t):t=e[21],u=t;break bb0}if(c===`goals`){let t;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(B),e[22]=t):t=e[22],u=t;break bb0}s=`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,l=(0,T.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:d}),r=`text-sm text-fg-muted`,o=a.settingsPage.comingSoon.replace(`{{title}}`,d)}e[0]=n,e[1]=t,e[2]=r,e[3]=o,e[4]=s,e[5]=l,e[6]=u}else r=e[2],o=e[3],s=e[4],l=e[5],u=e[6];if(u!==Symbol.for(`react.early_return_sentinel`))return u;let d;e[23]!==r||e[24]!==o?(d=(0,T.jsx)(`p`,{className:r,children:o}),e[23]=r,e[24]=o,e[25]=d):d=e[25];let f;return e[26]!==s||e[27]!==l||e[28]!==d?(f=(0,T.jsxs)(`div`,{className:s,children:[l,d]}),e[26]=s,e[27]=l,e[28]=d,e[29]=f):f=e[29],f}function G(e){return e.language}export{W as SettingsPage};
|