@xopcai/xopc 0.0.256 → 0.0.258
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BZJZvmYw.js → agent-avatar-dicebear-D7tpOS12.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DGHLpxj_.js +1 -0
- package/dist/gateway/static/root/assets/{agents-1vtaw07m.js → agents-DDiR9MCE.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-DG64SQsx.js → app-management-settings-panel-xtMKAVbv.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BRWQdIIy.js → appearance-settings-Cngeu2w8.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-D3ziBisx.js → apps-page-CXiCvD0B.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-D3FQ9VzV.js → archive-plugin-DXKFrMNm.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Cid3dBaW.js → attachment-load-DLYGTBVf.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BUTNaZtj.js → automations-page-BTp6bGo4.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-CuyEKO6M.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BSYMCuaB.js → binary-plugins-BcvVtSvZ.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-qDlC3t7b.js → block-editor-hZg3H6K-.js} +3 -3
- package/dist/gateway/static/root/assets/{browser-automations-page-Du1KVE01.js → browser-automations-page-COsWjB_N.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-D9CfpBLt.js +8 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CEOmYG_f.js +7 -0
- package/dist/gateway/static/root/assets/channels-settings-DS3vq4cr.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-CY-I_bCe.js → chat-terminal-dock-CmV1RMyj.js} +2 -2
- package/dist/gateway/static/root/assets/connectors-page-C51TR-Ov.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-z4WOWyBU.js → cron-expression-DsEb7fyV.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-vKUcJeQZ.js → date-picker-ChR8KQ7f.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-BpZ9A2gi.js → dependency-picker-DGz0raEu.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-ClrAMqgn.js → desktop-pet-_nHlkhRg.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DKNKGiEG.js → desktop-pet-settings-B_tVwGUL.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-C39hFkJm.js → extension-debug-page-DJttDDUz.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DkqVsWB7.js → extension-page-vv7-Kg1n.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-Be4lFw8f.js → extension-settings-page-BpsPHT1o.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-BrIcafAP.js +1 -0
- package/dist/gateway/static/root/assets/heartbeat-settings-BIqk_r9f.js +1 -0
- package/dist/gateway/static/root/assets/home-page-DQxTTwVp.js +1 -0
- package/dist/gateway/static/root/assets/index-B1zcAf8-.css +2 -0
- package/dist/gateway/static/root/assets/{index-BWdn9NaX.js → index-DfvY-SO6.js} +19 -19
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-ge76J038.js → keyboard-shortcuts-settings-CjUFDVZk.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-Cl4VINRc.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-gkw7VRL4.js → local-apps-page-DNK11iaj.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-HHtDMSUW.js → logs-page-Cqy0hmu5.js} +2 -2
- package/dist/gateway/static/root/assets/{management-settings-DOfCSojd.js → management-settings-LejmrKSf.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-D8wMcUtB.js → media-plugins-BFQxVZ03.js} +1 -1
- package/dist/gateway/static/root/assets/{mobile-pairing-wizard-B4Ewewwr.js → mobile-pairing-wizard-DfT_mH8L.js} +1 -1
- package/dist/gateway/static/root/assets/note-detail-panel-CvFzG1Bp.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-k297u-gH.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-DoxnT3X4.js → page-tabs-CMZs-2FR.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-D4oL1yua.js → preview-open-alternatives-BUprGPfS.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CXcG3Su-.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BaOV7aDd.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-WY2alRLt.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CrOpchy5.js → runtime-tools-settings-panel-BIrnrKec.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-Dk52v4cQ.js → schema-form-CjQ582_7.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-CUIrWSsD.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BOdZicC_.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-dvGi1APN.js → settings-form-section-d1SWWFyj.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-CEYjEm2D.js → settings-page-CeSoibS9.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DfUt3_r7.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DP4Qgsv6.js → share-preview-page-D7MJNTsV.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-BS2kgw-8.js +1 -0
- package/dist/gateway/static/root/assets/{skill-reload-api-BicZK04u.js → skill-reload-api-BrEpq0C1.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-Dlr1Ue1w.js → skills-page-DTFxG_j4.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-I1wcnceD.js → skills-page.utils-Co0GHVOk.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-DIaFAHT0.js → system-settings-panel-Cu9GTXm7.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-Dg3NARt6.js +1 -0
- package/dist/gateway/static/root/assets/{tunnel-api-DAXx1rHF.js → tunnel-api-cyxe_LpB.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-BwEFbveP.js → use-autosave-YQ_35Glb.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-BZMPfbEY.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-C-WbC2fM.js → voice-api-key-field-1e1_bhD3.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-DiGw5KKj.js → work-discovery-overlay-Ur-4XdYe.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BIU2wg99.js → workflow-run-setup-panel-Bn8Y5Xq4.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-DCh0jiOu.js +6 -0
- package/dist/gateway/static/root/index.html +2 -2
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/notifications.js +8 -1
- package/dist/src/agent/agent-manager.js +4 -4
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
- package/dist/src/agent/service.js +2 -2
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +3 -3
- package/dist/src/ai-assist/text-assist.js +1 -1
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/oauth/xopc-cloud.js +1 -1
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +2 -2
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/config/index.js +4 -4
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/connectors/connected-source-understanding.js +1 -4
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/user-model.js +39 -8
- package/dist/src/gateway/hono/routes/workflows.js +2 -2
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service.js +4 -4
- package/dist/src/notifications/planner.js +35 -0
- package/dist/src/notifications/service.js +2 -0
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +2 -2
- package/dist/src/user-model/index.js +2 -2
- package/dist/src/user-model/repository.d.ts +8 -0
- package/dist/src/user-model/repository.js +89 -1
- package/dist/src/work-discovery/service.js +2 -5
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +4 -4
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Bq7GNF1L.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-D4NJSE8l.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-WZ0Jt5Hp.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-D1AYoRx4.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-CZnlYu2L.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-CkH3gaqs.js +0 -2
- package/dist/gateway/static/root/assets/gateway-settings-HIHGY-0Y.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-DiYjWa1F.js +0 -1
- package/dist/gateway/static/root/assets/home-page-BLZNEVmk.js +0 -1
- package/dist/gateway/static/root/assets/index-50Kr6L6C.css +0 -2
- package/dist/gateway/static/root/assets/local-app-workbench-page-E47xrPDI.js +0 -2
- package/dist/gateway/static/root/assets/note-detail-panel-DPd5L2A9.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-CE_De-iQ.js +0 -8
- package/dist/gateway/static/root/assets/project-detail-page-DXhBJzJy.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-CcqhmZoX.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-ulmJT_Ac.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-RM0kAsNa.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BfLbu67w.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BZ4i0CYX.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-B5yHTrGO.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-4_5g-V8B.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-CQnXw4ba.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-D3Z7JVHH.js +0 -6
|
@@ -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{h as i}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{a,n as o,o as s,r as c,s as l,t as u}from"./dist-CpzYSoz7.js";import{n as d,r as f}from"./popover-select-CKBYnT3c.js";import{t as p}from"./download-Dk-ZjtO6.js";import{t as m}from"./plus-Q2yW6OE7.js";import{t as h}from"./x-B_N4OPjy.js";import{t as g}from"./messages-BeIiRpmk.js";import{a as _,n as v,r as y,s as b}from"./locale-store-DJPCr2mb.js";import{t as x}from"./cn-JdwAhgNB.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{t as C}from"./button-CtTvuElV.js";import{n as w,r as T}from"./gateway-config-swr-DEKSw3d-.js";import{t as E}from"./skeleton-BwbyijEw.js";import{i as ee,o as D}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as O,t as k}from"./registry-api-Dalzf2w0.js";import{As as A,Au as j,Bc as M,Gi as N,Hc as P,Hi as F,Hs as I,Ki as L,Lt as R,Oa as z,Oc as B,Ol as V,P as te,Rt as H,Ui as U,Vi as W,Vl as G,Wi as ne,Xi as re,Yi as ie,Zr as ae,al as oe,ba as se,cl as ce,eu as le,ho as ue,is as K,ju as q,kc as de,lc as fe,ol as pe,pc as me,qi as he,rs as J,va as Y,ya as X}from"./index-BWdn9NaX.js";import{n as ge,t as _e}from"./settings-form-section-dvGi1APN.js";import{n as ve,t as ye}from"./use-autosave-BwEFbveP.js";import{t as be}from"./page-tabs-DoxnT3X4.js";import{t as xe}from"./settings-advanced-gate-BfLbu67w.js";var Z=e(t(),1),Se=n(),Q=r();function Ce(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 we(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Te(e){let t=(0,Se.c)(105),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:s,onAction:c}=e,l;t[0]!==i.unnamedSession||t[1]!==n.name?(l=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=l):l=t[2];let u=l,d;t[3]===n.name?d=t[4]:(d=n.name?.trim(),t[3]=n.name,t[4]=d);let f=!!d,m=n.status===`archived`,h=n.status===`pinned`,g=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,_;t[5]===g?_=t[6]:(_=x(`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`,g),t[5]=g,t[6]=_);let v;t[7]===s?v=t[8]:(v=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},t[7]=s,t[8]=v);let y=r===`list`&&`sm:py-3`,b;t[9]===y?b=t[10]:(b=x(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,y),t[9]=y,t[10]=b);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]===h?C=t[14]:(C=h?(0,Q.jsx)(de,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=h,t[14]=C);let w;t[15]===n.updatedAt?w=t[16]:(w=Ce(n.updatedAt),t[15]=n.updatedAt,t[16]=w);let T;t[17]===w?T=t[18]:(T=(0,Q.jsx)(`span`,{children:w}),t[17]=w,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 ee;t[22]!==E||t[23]!==b||t[24]!==S?(ee=(0,Q.jsxs)(`div`,{className:b,children:[S,E]}),t[22]=E,t[23]=b,t[24]=S,t[25]=ee):ee=t[25];let D=r===`list`&&`sm:py-3`,O;t[26]===D?O=t[27]:(O=x(`min-w-0 flex-1 px-3 py-2`,D),t[26]=D,t[27]=O);let k=r===`list`&&`sm:items-start`,M;t[28]===k?M=t[29]:(M=x(`flex gap-3`,k),t[28]=k,t[29]=M);let N;t[30]!==o||t[31]!==a?(N=(0,Q.jsx)(te,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=o,t[31]=a,t[32]=N):N=t[32];let F;t[33]===u?F=t[34]:(F=(0,Q.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:u,children:u}),t[33]=u,t[34]=F);let L;t[35]!==n.key||t[36]!==f?(L=f?(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]=f,t[37]=L):L=t[37];let R;t[38]!==F||t[39]!==L?(R=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[F,L]}),t[38]=F,t[39]=L,t[40]=R):R=t[40];let z;t[41]!==M||t[42]!==N||t[43]!==R?(z=(0,Q.jsxs)(`div`,{className:M,children:[N,R]}),t[41]=M,t[42]=N,t[43]=R,t[44]=z):z=t[44];let V;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Q.jsx)(P,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=V):V=t[45];let H;t[46]===n.messageCount?H=t[47]:(H=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[V,n.messageCount]}),t[46]=n.messageCount,t[47]=H);let U;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Q.jsx)(A,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=U):U=t[48];let W;t[49]===n.estimatedTokens?W=t[50]:(W=we(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=W);let G;t[51]===W?G=t[52]:(G=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[U,W]}),t[51]=W,t[52]=G);let ne;t[53]!==H||t[54]!==G?(ne=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[H,G]}),t[53]=H,t[54]=G,t[55]=ne):ne=t[55];let re;t[56]===n.tags?re=t[57]:(re=n.tags.length>0?(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Oe),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]=re);let ie;t[58]!==O||t[59]!==z||t[60]!==ne||t[61]!==re?(ie=(0,Q.jsxs)(`div`,{className:O,children:[z,ne,re]}),t[58]=O,t[59]=z,t[60]=ne,t[61]=re,t[62]=ie):ie=t[62];let ae;t[63]===c?ae=t[64]:(ae=()=>c(`continue`),t[63]=c,t[64]=ae);let oe;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Q.jsx)(P,{className:`size-4`,strokeWidth:1.75}),t[65]=oe):oe=t[65];let se;t[66]!==i.continueChat||t[67]!==ae?(se=(0,Q.jsx)(`button`,{type:`button`,className:J,title:i.continueChat,"aria-label":i.continueChat,onClick:ae,children:oe}),t[66]=i.continueChat,t[67]=ae,t[68]=se):se=t[68];let ce;t[69]!==m||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==c?(ce=m?(0,Q.jsx)(`button`,{type:`button`,className:J,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>c(`unarchive`),children:(0,Q.jsx)(q,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:J,title:i.archive,"aria-label":i.archive,onClick:()=>c(`archive`),children:(0,Q.jsx)(j,{className:`size-4`,strokeWidth:1.75})}),t[69]=m,t[70]=i.archive,t[71]=i.unarchive,t[72]=c,t[73]=ce):ce=t[73];let le;t[74]!==h||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==c?(le=h?(0,Q.jsx)(`button`,{type:`button`,className:J,title:i.unpin,"aria-label":i.unpin,onClick:()=>c(`unpin`),children:(0,Q.jsx)(B,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:J,title:i.pin,"aria-label":i.pin,onClick:()=>c(`pin`),children:(0,Q.jsx)(de,{className:`size-4`,strokeWidth:1.75})}),t[74]=h,t[75]=i.pin,t[76]=i.unpin,t[77]=c,t[78]=le):le=t[78];let ue;t[79]===c?ue=t[80]:(ue=()=>c(`export`),t[79]=c,t[80]=ue);let K;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Q.jsx)(p,{className:`size-4`,strokeWidth:1.75}),t[81]=K):K=t[81];let fe;t[82]!==i.export||t[83]!==ue?(fe=(0,Q.jsx)(`button`,{type:`button`,className:J,title:i.export,"aria-label":i.export,onClick:ue,children:K}),t[82]=i.export,t[83]=ue,t[84]=fe):fe=t[84];let pe;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(pe=x(J,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=pe):pe=t[85];let me;t[86]===c?me=t[87]:(me=()=>c(`delete`),t[86]=c,t[87]=me);let he;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,Q.jsx)(I,{className:`size-4`,strokeWidth:1.75}),t[88]=he):he=t[88];let Y;t[89]!==i.delete||t[90]!==me?(Y=(0,Q.jsx)(`button`,{type:`button`,className:pe,title:i.delete,"aria-label":i.delete,onClick:me,children:he}),t[89]=i.delete,t[90]=me,t[91]=Y):Y=t[91];let X;t[92]!==se||t[93]!==ce||t[94]!==le||t[95]!==fe||t[96]!==Y?(X=(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:De,onKeyDown:Ee,children:[se,ce,le,fe,Y]}),t[92]=se,t[93]=ce,t[94]=le,t[95]=fe,t[96]=Y,t[97]=X):X=t[97];let ge;return t[98]!==s||t[99]!==ee||t[100]!==ie||t[101]!==_||t[102]!==X||t[103]!==v?(ge=(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,className:_,onClick:s,onKeyDown:v,children:[ee,ie,X]}),t[98]=s,t[99]=ee,t[100]=ie,t[101]=_,t[102]=X,t[103]=v,t[104]=ge):ge=t[104],ge}function Ee(e){return e.stopPropagation()}function De(e){return e.stopPropagation()}function Oe(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 ke(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function Ae(e,t){return t.find(t=>t.id===e)?.avatar}var je={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:2e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Me(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ne(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Pe(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function Fe(e){let t=Me(e)?e:{},n=Me(t.userContext)?t.userContext:{},r=Me(n.contextPlanning)?n.contextPlanning:{},i=Me(r.compaction)?r.compaction:{},a=je,o=typeof i.model==`string`&&i.model.trim()?i.model.trim():void 0,s=Array.isArray(i.postCompactionSections)&&i.postCompactionSections.length<=12&&i.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(i.postCompactionSections.map(e=>e.trim()))]:[...a.postCompactionSections];return{enabled:typeof i.enabled==`boolean`?i.enabled:a.enabled,triggerThreshold:Ne(i.triggerThreshold,a.triggerThreshold,.1,.98),reserveTokens:Pe(i.reserveTokens,a.reserveTokens,1024),minMessagesBeforeCompact:Pe(i.minMessagesBeforeCompact,a.minMessagesBeforeCompact,2),keepRecentTokens:Pe(i.keepRecentTokens,a.keepRecentTokens,1e3),recentTurnsPreserve:Pe(i.recentTurnsPreserve,a.recentTurnsPreserve,1,12),summaryMaxTokens:Pe(i.summaryMaxTokens,a.summaryMaxTokens,256),summaryChunkTokens:Pe(i.summaryChunkTokens,a.summaryChunkTokens,1e3),summaryTimeoutMs:Pe(i.summaryTimeoutMs,a.summaryTimeoutMs,1e3,6e5),summaryRetries:Pe(i.summaryRetries,a.summaryRetries,0,5),qualityGuard:typeof i.qualityGuard==`boolean`?i.qualityGuard:a.qualityGuard,gapAudit:typeof i.gapAudit==`boolean`?i.gapAudit:a.gapAudit,...o?{model:o}:{},minToolResultKeepChars:Pe(i.minToolResultKeepChars,a.minToolResultKeepChars,200),maxActiveTranscriptBytes:Pe(i.maxActiveTranscriptBytes,a.maxActiveTranscriptBytes,64e3),postCompactionSections:s}}function Ie(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function Le(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{contextPlanning:{compaction:t}}}}async function Re(e){await _(y(`/api/config`),{method:`PATCH`,body:JSON.stringify(Le(e))}),await w()}var ze=128e3,Be={balanced:je,preserve:{...je,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...je,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Ve=Y();function He(){return x(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,ue,`dark:border-edge`)}function Ue(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function We(e){let t=Ue(e);for(let[e,n]of Object.entries(Be))if(t===Ue(n))return e;return`custom`}function Ge(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,Se.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=He(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,Q.jsx)(`input`,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Q.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Ke(e){let t=(0,Se.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=x(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let u;t[4]!==i||t[5]!==a||t[6]!==l?(u=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=u):u=t[7];let d;t[8]===n?d=t[9]:(d=(0,Q.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=d);let f;t[10]===r?f=t[11]:(f=(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Q.jsxs)(`span`,{children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==c||t[16]!==u||t[17]!==p?(m=(0,Q.jsxs)(`label`,{className:c,children:[u,p]}),t[15]=c,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}function qe({hasToken:e}){let t=g(v(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=T(e),{data:i=[],isLoading:a}=S(e?k:null,O,{revalidateOnFocus:!1}),o=(0,Z.useMemo)(()=>n?.payload?.config===void 0?null:Fe(n.payload.config),[n]),[s,c]=(0,Z.useReducer)(Ve,{form:null,baseline:null}),[l,u]=(0,Z.useState)(``),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(s.form);f.current=s.form;let p=(0,Z.useRef)(null);X({enabled:e,parsed:o,dirty:d.current,trackedParsedRef:p,dispatch:c,onResetDirty:()=>{d.current=!1}});let _=s.form,y=s.baseline,b=!!(_&&y&&JSON.stringify(_)!==JSON.stringify(y)),w=(0,Z.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),ee=(0,Z.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),D=ye({value:_,dirty:b,onSave:(0,Z.useCallback)(async e=>{try{await Re(e),c({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ie(e);return n?t.invalidValue.replace(`{{field}}`,ee(n)):null}});if(!e||!_)return r?(0,Q.jsx)(_e,{children:(0,Q.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Q.jsx)(E,{className:`h-5 w-48`}),(0,Q.jsx)(E,{className:`h-20 w-full rounded-xl`}),(0,Q.jsx)(E,{className:`h-36 w-full rounded-xl`})]})}):null;let A=We(_),j=Math.max(0,ze-_.reserveTokens),N=Math.min(Math.floor(ze*_.triggerThreshold),j),P=Math.min(100,N/ze*100),F=Math.min(100,j/ze*100),I=_.model?i.find(e=>e.id===_.model):void 0,L=I?.contextWindow&&_.summaryChunkTokens+_.summaryMaxTokens+4096>I.contextWindow,R=_.keepRecentTokens+_.reserveTokens>N,z=Math.round(_.summaryTimeoutMs*(_.summaryRetries+1)/1e3),B=e=>{let t=Be[e];w({...t,..._.model?{model:_.model}:{model:void 0},postCompactionSections:_.postCompactionSections})},V={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},te=()=>{let e=l.trim();!e||_.postCompactionSections.includes(e)||_.postCompactionSections.length>=12||(w({postCompactionSections:[..._.postCompactionSections,e]}),u(``))};return(0,Q.jsxs)(_e,{onBlurCapture:D.onBlurCapture,children:[(0,Q.jsx)(ge,{icon:M,title:t.title,subtitle:t.hint,trailing:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(ve,{status:D.status,error:D.error}),(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:_.enabled,onChange:e=>w({enabled:e.target.checked})}),_.enabled?t.enabled:t.disabled]})]})}),D.error?(0,Q.jsx)(`p`,{className:`mb-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:D.error}):null,_.enabled?null:(0,Q.jsx)(`p`,{className:`mb-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Q.jsxs)(`fieldset`,{disabled:!_.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),A===`custom`?(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Q.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":A===e,className:x(`rounded-xl border px-3 py-3 text-left`,K.transition,K.focusRingPanel,A===e?`border-accent/50 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg hover:bg-surface-hover`),onClick:()=>B(e),children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium`,children:V[e].title}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:V[e].hint})]},e))})]}),(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-hover/35 p-4 dark:border-edge`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Q.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:t.compactionTrigger}),(0,Q.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(N)})]}),(0,Q.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${P}%`}})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:t.hardInputLimit}),(0,Q.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(j)})]}),(0,Q.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${F}%`}})})]})]}),(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((_.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>w({triggerThreshold:e/100})}),(0,Q.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ge(_.reserveTokens)),value:_.reserveTokens,min:1024,step:1024,onChange:e=>w({reserveTokens:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:_.recentTurnsPreserve,min:1,max:12,onChange:e=>w({recentTurnsPreserve:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ge(_.keepRecentTokens)),value:_.keepRecentTokens,min:1e3,step:1e3,onChange:e=>w({keepRecentTokens:Math.floor(e)})})]}),R?(0,Q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Q.jsx)(ae,{value:_.model??``,disabled:!_.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>w({model:e})}),_.model?(0,Q.jsx)(C,{type:`button`,variant:`secondary`,onClick:()=>w({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Q.jsx)(Ke,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:_.qualityGuard,onChange:e=>w({qualityGuard:e})}),(0,Q.jsx)(Ke,{label:t.gapAudit,hint:t.gapAuditHint,checked:_.gapAudit,onChange:e=>w({gapAudit:e})})]}),_.qualityGuard?null:(0,Q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,Q.jsx)(xe,{children:(0,Q.jsxs)(`div`,{className:`space-y-5 border-t border-edge pt-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:_.minMessagesBeforeCompact,min:2,onChange:e=>w({minMessagesBeforeCompact:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((_.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>w({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Q.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:_.summaryMaxTokens,min:256,step:256,onChange:e=>w({summaryMaxTokens:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:_.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>w({summaryChunkTokens:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(z)),value:_.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>w({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Q.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:_.summaryRetries,min:0,max:5,onChange:e=>w({summaryRetries:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:_.minToolResultKeepChars,min:200,step:100,onChange:e=>w({minToolResultKeepChars:Math.floor(e)})})]}),L?(0,Q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Q.jsxs)(`div`,{className:`border-t border-edge pt-5`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),_.postCompactionSections.length>0?(0,Q.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:_.postCompactionSections.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Q.jsx)(`button`,{type:`button`,className:x(`text-fg-muted hover:text-fg`,K.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>w({postCompactionSections:_.postCompactionSections.filter(t=>t!==e)}),children:(0,Q.jsx)(h,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Q.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Q.jsx)(`input`,{className:He(),value:l,maxLength:120,disabled:_.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),te())}}),(0,Q.jsxs)(C,{type:`button`,variant:`secondary`,disabled:!l.trim()||_.postCompactionSections.length>=12,onClick:te,children:[(0,Q.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function Je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ye(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function Xe(e){let t=Je(e)?e:{},n=Je(t.session)?t.session:{},r=Je(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:Ye(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Ze(e){await _(y(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),w()}function Qe(){return x(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,ue,`dark:border-edge`)}var $e=Y();function et({hasToken:e}){let t=g(v(e=>e.language)).sessions.config,{data:n,isLoading:r}=T(e),i=(0,Z.useMemo)(()=>n?.payload?.config===void 0?null:Xe(n.payload.config),[n]),[a,o]=(0,Z.useReducer)($e,{form:null,baseline:null}),s=a.form,c=a.baseline,l=(0,Z.useRef)(!1),u=(0,Z.useRef)(s);u.current=s;let p=(0,Z.useRef)(null);X({enabled:e,parsed:i,dirty:l.current,trackedParsedRef:p,dispatch:o,onResetDirty:()=>{l.current=!1}});let m=!!(s&&c&&JSON.stringify(s)!==JSON.stringify(c)),h=(0,Z.useCallback)(e=>{l.current=!0,o({type:`patch`,patch:e})},[]),_=ye({value:s,dirty:m,onSave:(0,Z.useCallback)(async e=>{try{await Ze(e),o({type:`saved`,value:e}),l.current=!!(u.current&&JSON.stringify(u.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!s?r?(0,Q.jsx)(_e,{children:(0,Q.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Q.jsx)(E,{className:`h-5 w-40`}),(0,Q.jsx)(E,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Q.jsxs)(_e,{onBlurCapture:_.onBlurCapture,children:[(0,Q.jsx)(ge,{icon:G,title:t.title,subtitle:t.hint,trailing:(0,Q.jsx)(ve,{status:_.status,error:_.error})}),(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)(d,{className:Qe(),value:s.dmScope,onChange:e=>h({dmScope:e.target.value}),children:[(0,Q.jsx)(f,{value:`main`,children:t.dmScopeMain}),(0,Q.jsx)(f,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Q.jsx)(f,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Q.jsx)(f,{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:Qe(),value:s.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({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:Qe(),value:s.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function tt(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function nt(e){let t=(0,Se.c)(60),{open:n,loading:r,session:i,sessionAgentId:d,sessionAgentAvatar:f,labels:p,onClose:m,onArchive:g,onUnarchive:_,onPin:v,onUnpin:y,onExport:b,onDelete:S}=e,w=i?.status===`archived`,T=i?.status===`pinned`,E;t[0]===m?E=t[1]:(E=e=>!e&&m(),t[0]=m,t[1]=E);let O;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Q.jsx)(a,{className:x(`xopc-dialog-overlay fixed inset-0 bg-scrim`,D)}),t[2]=O):O=t[2];let k;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(k=x(`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`,ee,`dark:border-edge`),t[3]=k):k=t[3];let A;t[4]!==i||t[5]!==f||t[6]!==d?(A=i&&d?(0,Q.jsx)(te,{agentId:d,avatar:f,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=f,t[6]=d,t[7]=A):A=t[7];let j;t[8]!==p.unnamedSession||t[9]!==i?.name?(j=i?.name?.trim()||p.unnamedSession,t[8]=p.unnamedSession,t[9]=i?.name,t[10]=j):j=t[10];let M;t[11]===j?M=t[12]:(M=(0,Q.jsx)(l,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:j}),t[11]=j,t[12]=M);let N;t[13]!==A||t[14]!==M?(N=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[A,M]}),t[13]=A,t[14]=M,t[15]=N):N=t[15];let P;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Q.jsx)(h,{className:`size-5`,strokeWidth:1.75}),t[16]=P):P=t[16];let F;t[17]===p.close?F=t[18]:(F=(0,Q.jsx)(o,{asChild:!0,children:(0,Q.jsx)(C,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":p.close,children:P})}),t[17]=p.close,t[18]=F);let I;t[19]!==N||t[20]!==F?(I=(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:[N,F]}),t[19]=N,t[20]=F,t[21]=I):I=t[21];let L;t[22]!==p.detailLoading||t[23]!==p.detailMessages||t[24]!==r||t[25]!==i?(L=r?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p.detailLoading}):i?(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:i.key})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Q.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Q.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:p.detailMessages}),(0,Q.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(rt)})]}):null,t[22]=p.detailLoading,t[23]=p.detailMessages,t[24]=r,t[25]=i,t[26]=L):L=t[26];let R;t[27]===L?R=t[28]:(R=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:L}),t[27]=L,t[28]=R);let z;t[29]!==p.detailExport||t[30]!==b?(z=(0,Q.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:b,children:p.detailExport}),t[29]=p.detailExport,t[30]=b,t[31]=z):z=t[31];let B;t[32]!==w||t[33]!==p.archive||t[34]!==p.unarchive||t[35]!==g||t[36]!==_?(B=w?(0,Q.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:_,children:p.unarchive}):(0,Q.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:g,children:p.archive}),t[32]=w,t[33]=p.archive,t[34]=p.unarchive,t[35]=g,t[36]=_,t[37]=B):B=t[37];let V;t[38]!==T||t[39]!==p.pin||t[40]!==p.unpin||t[41]!==v||t[42]!==y?(V=T?(0,Q.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:y,children:p.unpin}):(0,Q.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:v,children:p.pin}),t[38]=T,t[39]=p.pin,t[40]=p.unpin,t[41]=v,t[42]=y,t[43]=V):V=t[43];let H;t[44]!==p.delete||t[45]!==S?(H=(0,Q.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:S,children:p.delete}),t[44]=p.delete,t[45]=S,t[46]=H):H=t[46];let U;t[47]!==z||t[48]!==B||t[49]!==V||t[50]!==H?(U=(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:[z,B,V,H]})}),t[47]=z,t[48]=B,t[49]=V,t[50]=H,t[51]=U):U=t[51];let W;t[52]!==I||t[53]!==R||t[54]!==U?(W=(0,Q.jsxs)(s,{children:[O,(0,Q.jsxs)(c,{className:k,"aria-describedby":void 0,children:[I,R,U]})]}),t[52]=I,t[53]=R,t[54]=U,t[55]=W):W=t[55];let G;return t[56]!==n||t[57]!==E||t[58]!==W?(G=(0,Q.jsx)(u,{open:n,onOpenChange:E,children:W}),t[56]=n,t[57]=E,t[58]=W,t[59]=G):G=t[59],G}function rt(e){return(0,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:tt(e.content)})]},`${e.timestamp??``}-${e.role}-${tt(e.content).slice(0,24)}`)}var it=20;function at(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ot=new Set([`all`,`active`,`pinned`,`archived`]),st=new Set([`grid`,`list`]),ct=[`sessions`,`settings`];function lt(e){return e&&ct.includes(e)?e:`sessions`}function ut(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function dt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function ft(e){let t=(0,Se.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=ct.map(e=>({id:e,label:ut(n,e),icon:e===`sessions`?ce:fe})),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)(be,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function pt(e){let t=(0,Se.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:ut(n,r)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:dt(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 mt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ot.has(t)?t:`all`,viewMode:st.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function ht(){let e=g(v(e=>e.language)),t=e.sessions,n=b(e=>e.token),r=!!n,{data:o,mutate:d}=S(r?[`gateway-chat-agents`,n]:null,z,{revalidateOnFocus:!1}),f=o?.defaultId??`main`,p=o?.items??[],[m,h]=i(),_=lt(m.get(`tab`)),y=(0,Z.useCallback)(e=>{let t=new URLSearchParams(m);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),h(t,{replace:!0})},[m,h]),[w,T]=(0,Z.useReducer)(se,m,mt),{searchInput:E,debouncedSearch:O,statusFilter:k,viewMode:A,channelFilter:M,sessions:P,loading:I,error:B,hasMore:te,stats:G,detailOpen:ae,detailLoading:ue,detailSession:q,confirmOpen:fe,confirmKey:J}=w;(0,Z.useEffect)(()=>{let e=setTimeout(()=>{let e=E.trim();O!==e&&T({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[E,O]);let Y=m.toString(),X=(0,Z.useRef)(Y);if(X.current!==Y){X.current=Y;let e=m.get(`q`)??``,t=m.get(`status`),n=m.get(`view`),r=(m.get(`channel`)??``).trim(),i=ot.has(t)?t:`all`,a=st.has(n)?n:`grid`,o=e.trim();T({type:`patch`,patch:{...E===e?{}:{searchInput:e},...O===o?{}:{debouncedSearch:o},...k===i?{}:{statusFilter:i},...A===a?{}:{viewMode:a},...M===r?{}:{channelFilter:r}}})}(0,Z.useEffect)(()=>{let e=new URLSearchParams(m),t=O.trim();t?e.set(`q`,t):e.delete(`q`),k===`all`?e.delete(`status`):e.set(`status`,k),A===`grid`?e.delete(`view`):e.set(`view`,A),M?e.set(`channel`,M):e.delete(`channel`),e.toString()!==m.toString()&&h(e,{replace:!0})},[O,m,h,k,A,M]),(0,Z.useEffect)(()=>{if(!r||_!==`sessions`)return;let e=!1;return(async()=>{T({type:`patch`,patch:{loading:!0,error:null}});try{let t=await L({limit:it,offset:0,...O?{search:O}:{},...k===`all`?{}:{status:k},...M?{channel:M}:{}});if(e)return;T({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||T({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||T({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,_,O,k,M,t.loadError]),(0,Z.useEffect)(()=>{!r||_!==`sessions`||N().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,_]),(0,Z.useEffect)(()=>{if(!r||_!==`sessions`)return;let e=()=>void d();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,_,d]),(0,Z.useEffect)(()=>{if(!r||_!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||T({type:`patch`,patch:{sessions:P.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:q&&q.key===t.key?{...q,name:t.name}:q}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,_,P,q]);let ge=(0,Z.useCallback)(async()=>{if(!(!r||I||!te)){T({type:`patch`,patch:{loading:!0,error:null}});try{let e=await L({limit:it,offset:P.length,...O?{search:O}:{},...k===`all`?{}:{status:k},...M?{channel:M}:{}});T({type:`patch`,patch:{sessions:[...P,...e.items],hasMore:e.hasMore}})}catch(e){T({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{T({type:`patch`,patch:{loading:!1}})}}},[r,I,te,P.length,O,k,M,t.loadError]),_e=(0,Z.useCallback)((e,t)=>{T({type:`patch`,patch:{sessions:P.map(n=>n.key===e?{...n,status:t}:n),detailSession:q&&q.key===e?{...q,status:t}:q}})},[P,q]),ve=(0,Z.useCallback)(async e=>{T({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{T({type:`patch`,patch:{detailSession:await ne(e)}})}catch{T({type:`patch`,patch:{detailOpen:!1}})}finally{T({type:`patch`,patch:{detailLoading:!1}})}},[]),ye=e=>{ve(e)},be=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){T({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await W(e),_e(e,`archived`);break;case`unarchive`:await ie(e),_e(e,`active`);break;case`pin`:await he(e),_e(e,`pinned`);break;case`unpin`:await re(e),_e(e,`active`);break;case`export`:{let t=await U(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}N().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},xe=async e=>{try{await F(e),T({type:`patch`,patch:{sessions:P.filter(t=>t.key!==e),detailSession:q?.key===e?null:q,...q?.key===e?{detailOpen:!1}:{}}}),N().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Se={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},Ce={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},we=[{key:`all`,label:t.filterAll,icon:ce},{key:`active`,label:t.filterActive,icon:le},{key:`pinned`,label:t.filterPinned,icon:de},{key:`archived`,label:t.filterArchived,icon:j}],Ee=(()=>{let e=Object.entries(G?.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)(ft,{s:t,activeTab:_,onChange:y}),(0,Q.jsx)(pt,{s:t,id:`settings`,activeTab:_,plain:!0,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(qe,{hasToken:r}),(0,Q.jsx)(et,{hasToken:r})]})}),(0,Q.jsxs)(pt,{s:t,id:`sessions`,activeTab:_,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:we.map(({key:e,label:t,icon:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":k===e,onClick:()=>T({type:`patch`,patch:{statusFilter:e}}),className:x(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,K.transition,K.focusRingPanel,k===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)(me,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,value:E,onChange:e=>T({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":!M,onClick:()=>T({type:`patch`,patch:{channelFilter:``}}),className:x(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,K.transition,K.focusRingPanel,M?`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}),Ee.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":M===e,onClick:()=>T({type:`patch`,patch:{channelFilter:e}}),className:x(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,K.transition,K.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:[e,G?.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:G.byChannel[e]})]},e))]}),G?(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[G.totalSessions,t.totalSessions],[G.activeSessions,t.activeSessions],[G.pinnedSessions,t.pinnedSessions],[G.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,B?(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:B}):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:at(t.sessionCount,{count:P.length})}),(0,Q.jsxs)(`div`,{className:H,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Q.jsx)(C,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":A===`grid`,onClick:()=>T({type:`patch`,patch:{viewMode:`grid`}}),className:x(R,`size-7 p-0`,A===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,A===`grid`&&`text-accent-fg`),children:(0,Q.jsx)(pe,{className:`size-3.5`,strokeWidth:1.5})}),(0,Q.jsx)(C,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":A===`list`,onClick:()=>T({type:`patch`,patch:{viewMode:`list`}}),className:x(R,`size-9 p-0`,A===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,A===`list`&&`text-accent-fg`),children:(0,Q.jsx)(oe,{className:`size-3.5`,strokeWidth:1.5})})]})]}),I&&P.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))}):P.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)(V,{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)(C,{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:x(`grid min-w-0 gap-3`,A===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":O||void 0,children:P.map(e=>{let t=ke(e,f);return(0,Q.jsx)(Te,{session:e,variant:A,labels:Se,sessionAgentId:t,sessionAgentAvatar:Ae(t,p),onOpen:()=>ye(e.key),onAction:t=>void be(e.key,t)},e.key)})}),te?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(C,{type:`button`,variant:`secondary`,disabled:I,onClick:()=>void ge(),children:t.loadMore})}):null]})]})]}),(0,Q.jsx)(nt,{open:ae,loading:ue,session:q,sessionAgentId:q?ke(q,f):void 0,sessionAgentAvatar:q?Ae(ke(q,f),p):void 0,labels:Ce,onClose:()=>{T({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>q&&void be(q.key,`archive`),onUnarchive:()=>q&&void be(q.key,`unarchive`),onPin:()=>q&&void be(q.key,`pin`),onUnpin:()=>q&&void be(q.key,`unpin`),onExport:()=>q&&void be(q.key,`export`),onDelete:()=>q&&T({type:`patch`,patch:{confirmKey:q.key,confirmOpen:!0}})}),(0,Q.jsx)(u,{open:fe,onOpenChange:e=>T({type:`patch`,patch:{confirmOpen:e}}),children:(0,Q.jsxs)(s,{children:[(0,Q.jsx)(a,{className:x(`xopc-dialog-overlay fixed inset-0 bg-scrim`,D)}),(0,Q.jsxs)(c,{className:x(`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`,ee),children:[(0,Q.jsx)(l,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:J?at(t.deleteSessionMessage,{name:P.find(e=>e.key===J)?.name?.trim()||e.chat.newSession}):``}),(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(C,{type:`button`,variant:`secondary`,onClick:()=>T({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Q.jsx)(C,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{J&&xe(J),T({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{ht as SessionsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{cn as e}from"./index-BWdn9NaX.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./messages-BeIiRpmk.js";import{a as c,n as l,r as u,s as d}from"./locale-store-DJPCr2mb.js";import{t as f}from"./cn-JdwAhgNB.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{r as m}from"./gateway-config-swr-DEKSw3d-.js";import{n as h,t as g}from"./registry-api-Dalzf2w0.js";import{Et as _,La as v,Mu as y,Vs as b,Xs as x,an as S,cu as C,eu as w,fl as T,is as E,tu as D,uo as O,vc as k}from"./index-BWdn9NaX.js";import{n as A,r as j}from"./settings-page-layout-BRQNel6r.js";import{n as M}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as N,t as P}from"./settings-form-section-dvGi1APN.js";var F=e(t(),1),I=n();function L(e){if(!e||typeof e!=`object`)return 0;let t=e.providers;return!t||typeof t!=`object`||Array.isArray(t)?0:Object.values(t).filter(e=>typeof e==`string`&&O(e)).length}function R(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaults,r=n&&typeof n==`object`&&!Array.isArray(n)?n.models:void 0;if(!r||typeof r!=`object`||Array.isArray(r))return``;let i=r.chat;if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.primary;return typeof a==`string`?a.trim():``}function z(e){if(!e||typeof e!=`object`)return!1;let t=e.channels;return!t||typeof t!=`object`||Array.isArray(t)?!1:Object.values(t).some(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(`configured`in t||`config`in t||`schema`in t||`uiHints`in t){if(t.configured===!0)return!0;let e=t.config;if(!e||typeof e!=`object`||Array.isArray(e))return!1;let n=e;return n.enabled===!0||Object.keys(n).length>0}return t.enabled===!0||Object.keys(t).length>0})}function B(e){if(!e||typeof e!=`object`)return{enabled:!1,driverKind:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,driverKind:`extension`};let n=t,r=n.driver&&typeof n.driver==`object`&&!Array.isArray(n.driver)?n.driver:void 0;return{enabled:n.enabled===!0,driverKind:typeof r?.kind==`string`&&r.kind.trim()?r.kind.trim():`extension`}}function V(e){return e?`pass`:`fail`}function H(e){if(e===`provider-auth`)return`/settings/capabilities/models`;if(e===`config-health`)return`/settings/gateway`;if(e===`state-integrity`||e===`workspace-status`)return`/agents`;if(e===`database-schema`||e===`session-integrity`)return`/settings/sessions`;if(e===`channel-config`||e===`channel-pairing-pending`||e.startsWith(`channel:`))return`/channels`;if(e===`security-audit`||e===`gateway-service`||e===`gateway-health`)return`/settings/gateway`;if(e===`version-check`)return`/settings/desktop-app`}function U(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function ee(e){return e.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>({id:e.id,label:e.label,status:e.status,message:e.message,hints:e.hints,path:H(e.id),source:`doctor`})).toSorted((e,t)=>U(t.status)-U(e.status)||e.label.localeCompare(t.label))}function W(e){let t=new Map(e.doctorChecks.map(e=>[e.id,e])),n=[];for(let e of[`security-audit`,`channel-config`,`channel-pairing-pending`,`gateway-health`]){let r=t.get(e);r&&n.push({id:r.id,label:r.label,status:r.status,message:r.message,path:H(r.id)})}if(e.logsHealth){let t=e.logsHealth.stats?.errorsLast24h??0;n.push({id:`logs-health`,label:`Logs`,status:e.logsHealth.shuttingDown||t>0?`warn`:`pass`,message:e.logsHealth.shuttingDown?`Logger is shutting down.`:t>0?`${t} error(s) in the last 24 hours.`:`Log system is healthy.`,path:`/settings/logs`})}for(let t of e.browserDiagnostics??[])n.push(t);return n}function te(e){let t=L(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=R(e.config),o=a.length>0,s=e.hasToken&&e.realtimeConnected,c=z(e.config),l=e.skillCount>0,u=e.doctorChecks??[],d=ee(u),f=[{id:`gateway`,done:s,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline},{id:`provider`,done:i,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing},{id:`defaultModel`,done:o,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing},{id:`channel`,done:c,optional:!0,detail:c?e.labels.channelConfigured:e.labels.channelMissing},{id:`skill`,done:l,optional:!0,detail:l?e.labels.skillsConfigured(e.skillCount):e.labels.skillsMissing}],p=f.filter(e=>!e.optional).every(e=>e.done),m=f.every(e=>e.done),h=[{id:`gateway`,status:V(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:V(i),title:`Model provider`,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing,path:`/settings/capabilities/models`},{id:`defaultModel`,status:V(o),title:`Default model`,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing,path:`/settings/capabilities/models`},{id:`ready`,status:p?`pass`:`fail`,title:`Chat readiness`,detail:p?e.labels.readyToChat:e.labels.modelMissing,path:`/chat`}],g=d.some(e=>e.status===`fail`),_=d.some(e=>e.status===`warn`),v=g?`blocked`:_?`attention`:p?`ready`:`setup`,y=W({doctorChecks:u,logsHealth:e.logsHealth,browserDiagnostics:e.browserDiagnostics});return{gatewayConnected:s,providerConfigured:i,providerCount:t,providerMetaConfigured:n,providerMetaTotal:r,defaultModel:a,defaultModelConfigured:o,channelConfigured:c,skillInstalled:l,skillCount:e.skillCount,checklist:f,readiness:h,issues:d,healthTier:v,diagnosticSignals:y,requiredComplete:p,allComplete:m}}function ne(e){return B(e)}function G(e){return!e.id||!e.label||!e.status||!e.message||![`pass`,`warn`,`fail`,`skip`].includes(e.status)?null:{id:e.id,label:e.label,status:e.status,message:e.message,hints:Array.isArray(e.hints)?e.hints.filter(e=>typeof e==`string`):[],fixed:e.fixed===!0,findings:Array.isArray(e.findings)?e.findings:void 0}}function re(){return u(`/api/doctor`)}async function ie(){return((await c(re())).checks??[]).map(G).filter(e=>e!==null)}function ae(){return u(`/api/logs/health`)}async function oe(){return c(ae())}function K(e){return e?`pass`:`warn`}function se(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function ce(e){if(!e.enabled)return[];if(e.driverKind===`playwright`){let e=await c(u(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:K(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:`/settings/agent-browser`}]}if(e.driverKind===`extension`){let e=await c(u(`/api/browser/extension-status?probe=true`)),t=e.artifacts?.installed===!0,n=e.connected===!0,r=e.artifacts?.needsRefresh===!0||e.artifacts?.needsChromeReload===!0;return[{id:`browser-extension`,label:`Browser: Chrome extension`,status:n?`pass`:`warn`,message:n?`Chrome extension bridge is connected.`:t?r?`Chrome extension needs refresh.`:`Chrome extension is installed but not connected.`:`Chrome extension is not installed.`,path:`/settings/agent-browser`}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser driver "${e.driverKind}" is configured.`,path:`/settings/agent-browser`}]}function q(){let e=(0,I.c)(57),t=d(me),n=l(pe),r;e[0]===n?r=e[1]:(r=s(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,o=v(fe),{data:c,error:u,isLoading:f,mutate:y}=m(!!t),b;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(b={revalidateOnFocus:!1},e[2]=b):b=e[2];let{data:x,error:S,isLoading:C,mutate:w}=p(t?`setup-checklist-skills`:null,de,b),T;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(T={revalidateOnFocus:!1},e[3]=T):T=e[3];let{data:E,error:D,isLoading:O,mutate:k}=p(t?`setup-checklist-provider-meta`:null,_,T),A;e[4]===t?A=e[5]:(A=t?re():null,e[4]=t,e[5]=A);let j;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(j={revalidateOnFocus:!1},e[6]=j):j=e[6];let{data:M,error:N,isLoading:P,mutate:F}=p(A,ie,j),L;e[7]===t?L=e[8]:(L=t?ae():null,e[7]=t,e[8]=L);let R;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(R={revalidateOnFocus:!1},e[9]=R):R=e[9];let{data:z,isLoading:B,mutate:V}=p(L,oe,R);c?.payload?.config;let H=c?.payload?.config,U;e[10]===H?U=e[11]:(U=ne(H),e[10]=H,e[11]=U);let ee=t?U:null,W;e[12]===ee?W=e[13]:(W=se(ee),e[12]=ee,e[13]=W);let G;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(G={revalidateOnFocus:!1},e[14]=G):G=e[14];let{data:K,isLoading:ce,mutate:q}=p(W,ue,G),J;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(J={revalidateOnFocus:!1},e[15]=J):J=e[15],p(t?g:null,h,J);let Y=!t||!f&&!C&&!O&&!P&&!B&&!ce,X=!!(u||S||D||N),Z;bb0:{if(!t||!Y){Z=null;break bb0}let n=x?.catalog?.length??0,r;if(e[16]!==K||e[17]!==c?.payload?.config||e[18]!==M||e[19]!==a.channelConfigured||e[20]!==a.channelMissing||e[21]!==a.gatewayOffline||e[22]!==a.gatewayOnline||e[23]!==a.modelConfigured||e[24]!==a.modelMissing||e[25]!==a.providersConfigured||e[26]!==a.providersMetaReady||e[27]!==a.providersMissing||e[28]!==a.skillsConfigured||e[29]!==a.skillsMissing||e[30]!==z||e[31]!==i.setupStatus.requiredCompleteMessage||e[32]!==E||e[33]!==o||e[34]!==n||e[35]!==t){let s=E?.filter(le).length??0,l=E?.length??0,u;e[37]===a.providersConfigured?u=e[38]:(u=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[37]=a.providersConfigured,e[38]=u);let d;e[39]===a.providersMetaReady?d=e[40]:(d=(e,t)=>a.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[39]=a.providersMetaReady,e[40]=d);let f;e[41]===a.modelConfigured?f=e[42]:(f=e=>a.modelConfigured.replace(`{{model}}`,e),e[41]=a.modelConfigured,e[42]=f);let p;e[43]===a.skillsConfigured?p=e[44]:(p=e=>a.skillsConfigured.replace(`{{count}}`,String(e)),e[43]=a.skillsConfigured,e[44]=p),r=te({hasToken:!!t,realtimeConnected:o,config:c?.payload?.config,skillCount:n,providerMeta:l>0?{configured:s,total:l}:null,doctorChecks:M,logsHealth:z,browserDiagnostics:K,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:u,providersMetaReady:d,providersMissing:a.providersMissing,modelConfigured:f,modelMissing:a.modelMissing,channelConfigured:a.channelConfigured,channelMissing:a.channelMissing,skillsConfigured:p,skillsMissing:a.skillsMissing,readyToChat:i.setupStatus.requiredCompleteMessage}}),e[16]=K,e[17]=c?.payload?.config,e[18]=M,e[19]=a.channelConfigured,e[20]=a.channelMissing,e[21]=a.gatewayOffline,e[22]=a.gatewayOnline,e[23]=a.modelConfigured,e[24]=a.modelMissing,e[25]=a.providersConfigured,e[26]=a.providersMetaReady,e[27]=a.providersMissing,e[28]=a.skillsConfigured,e[29]=a.skillsMissing,e[30]=z,e[31]=i.setupStatus.requiredCompleteMessage,e[32]=E,e[33]=o,e[34]=n,e[35]=t,e[36]=r}else r=e[36];Z=r}let he=Z,Q;e[45]!==q||e[46]!==y||e[47]!==F||e[48]!==V||e[49]!==k||e[50]!==w?(Q=async()=>{await Promise.all([y(),w(),k(),F(),V(),q()])},e[45]=q,e[46]=y,e[47]=F,e[48]=V,e[49]=k,e[50]=w,e[51]=Q):Q=e[51];let ge=Q,$;return e[52]!==X||e[53]!==Y||e[54]!==ge||e[55]!==he?($={ready:Y,error:X,snapshot:he,refresh:ge},e[52]=X,e[53]=Y,e[54]=ge,e[55]=he,e[56]=$):$=e[56],$}function le(e){return e.configured}function ue(e){let[,t]=e;return ce(t)}function de(){return S()}function fe(e){return e.connectionState===`connected`}function pe(e){return e.language}function me(e){return e.token}var J=r();function Y(e){return e===`pass`?`border-success/30 bg-success-soft text-success`:e===`warn`?`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`fail`?`border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300`:`border-edge bg-surface-hover text-fg-muted`}function X(e){return e===`pass`?a:e===`warn`?b:e===`fail`?D:T}function Z(e,t){return e===`blocked`?{icon:D,className:`bg-red-500/10 text-red-950 dark:text-red-100`,title:t.health.blockedTitle,body:t.health.blockedBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`attention`?{icon:b,className:`bg-amber-500/10 text-amber-950 dark:text-amber-100`,title:t.health.attentionTitle,body:t.health.attentionBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`setup`?{icon:w,className:`bg-surface-base text-fg shadow-surface`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:a,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function he(e){let t=(0,I.c)(48),{tier:n,issueCount:r,onRunDoctor:a,ready:c,doctorRunning:u,doctorRunState:d}=e,p=l(Q),m,h,g,_,v,y,b,x,S,w,T;if(t[0]!==r||t[1]!==p||t[2]!==n){h=s(p).setupStatus;let e=Z(n,h),a=e.icon,o=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,c=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;m=o?(0,J.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(o)?.scrollIntoView({block:`start`,behavior:`smooth`}),className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,J.jsx)(C,{className:`size-4`,"aria-hidden":!0})]}):(0,J.jsxs)(i,{to:c,className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,J.jsx)(C,{className:`size-4`,"aria-hidden":!0})]}),T=f(`rounded-xl p-4`,e.className),w=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,x=`flex min-w-0 gap-3`,S=(0,J.jsx)(a,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),v=`min-w-0`,y=(0,J.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),b=(0,J.jsx)(`p`,{className:`mt-1 text-sm opacity-85`,children:e.body}),g=`mt-2 text-xs opacity-75`,_=h.health.issueCount.replace(`{{count}}`,String(r)),t[0]=r,t[1]=p,t[2]=n,t[3]=m,t[4]=h,t[5]=g,t[6]=_,t[7]=v,t[8]=y,t[9]=b,t[10]=x,t[11]=S,t[12]=w,t[13]=T}else m=t[3],h=t[4],g=t[5],_=t[6],v=t[7],y=t[8],b=t[9],x=t[10],S=t[11],w=t[12],T=t[13];let D;t[14]!==g||t[15]!==_?(D=(0,J.jsx)(`p`,{className:g,children:_}),t[14]=g,t[15]=_,t[16]=D):D=t[16];let O;t[17]!==D||t[18]!==v||t[19]!==y||t[20]!==b?(O=(0,J.jsxs)(`div`,{className:v,children:[y,b,D]}),t[17]=D,t[18]=v,t[19]=y,t[20]=b,t[21]=O):O=t[21];let A;t[22]!==O||t[23]!==x||t[24]!==S?(A=(0,J.jsxs)(`div`,{className:x,children:[S,O]}),t[22]=O,t[23]=x,t[24]=S,t[25]=A):A=t[25];let j;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(j=f(`inline-flex items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,E.press),t[26]=j):j=t[26];let M=!c||u,N;t[27]===u?N=t[28]:(N=u?(0,J.jsx)(o,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,J.jsx)(k,{className:`size-4`,"aria-hidden":!0}),t[27]=u,t[28]=N);let P=u?h.health.runDoctorRunning:h.health.runDoctor,F;t[29]!==u||t[30]!==a||t[31]!==M||t[32]!==N||t[33]!==P?(F=(0,J.jsxs)(`button`,{type:`button`,className:j,onClick:a,disabled:M,"aria-busy":u,children:[N,P]}),t[29]=u,t[30]=a,t[31]=M,t[32]=N,t[33]=P,t[34]=F):F=t[34];let L;t[35]!==m||t[36]!==F?(L=(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[m,F]}),t[35]=m,t[36]=F,t[37]=L):L=t[37];let R;t[38]!==A||t[39]!==L||t[40]!==w?(R=(0,J.jsxs)(`div`,{className:w,children:[A,L]}),t[38]=A,t[39]=L,t[40]=w,t[41]=R):R=t[41];let z=u?h.health.doctorRunningMessage:d===`success`?h.health.doctorCompleteMessage:d===`error`?h.health.doctorFailedMessage:h.health.doctorIdleMessage,B;t[42]===z?B=t[43]:(B=(0,J.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:z}),t[42]=z,t[43]=B);let V;return t[44]!==R||t[45]!==B||t[46]!==T?(V=(0,J.jsxs)(`section`,{className:T,children:[R,B]}),t[44]=R,t[45]=B,t[46]=T,t[47]=V):V=t[47],V}function Q(e){return e.language}function ge(e){let t=(0,I.c)(34),{issue:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=X(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,J.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,J.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.status?l=t[7]:(l=f(`rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,Y(n.status)),t[6]=n.status,t[7]=l);let u;t[8]!==n.status||t[9]!==l?(u=(0,J.jsx)(`span`,{className:l,children:n.status}),t[8]=n.status,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==c||t[12]!==u?(d=(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[c,u]}),t[11]=c,t[12]=u,t[13]=d):d=t[13];let p;t[14]===n.message?p=t[15]:(p=(0,J.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[14]=n.message,t[15]=p);let m;t[16]===n.hints[0]?m=t[17]:(m=n.hints[0]?(0,J.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[16]=n.hints[0],t[17]=m);let h;t[18]!==d||t[19]!==p||t[20]!==m?(h=(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[d,p,m]}),t[18]=d,t[19]=p,t[20]=m,t[21]=h):h=t[21];let g;t[22]!==r||t[23]!==n.path?(g=n.path?(0,J.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,J.jsx)(C,{className:`size-4`,"aria-hidden":!0})]}):null,t[22]=r,t[23]=n.path,t[24]=g):g=t[24];let _;t[25]!==g||t[26]!==s||t[27]!==h?(_=(0,J.jsxs)(J.Fragment,{children:[s,h,g]}),t[25]=g,t[26]=s,t[27]=h,t[28]=_):_=t[28];let v=_;if(n.path){let e;return t[29]!==v||t[30]!==n.path?(e=(0,J.jsx)(i,{to:n.path,className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:v}),t[29]=v,t[30]=n.path,t[31]=e):e=t[31],e}let y;return t[32]===v?y=t[33]:(y=(0,J.jsx)(`div`,{className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`,children:v}),t[32]=v,t[33]=y),y}function $(e){let t=(0,I.c)(27),{item:n,labels:r}=e,a;t[0]===n.status?a=t[1]:(a=X(n.status),t[0]=n.status,t[1]=a);let o=a,s=r[n.id]??n.title,c;t[2]===n.status?c=t[3]:(c=f(`flex size-7 shrink-0 items-center justify-center rounded-full border`,Y(n.status)),t[2]=n.status,t[3]=c);let l;t[4]===o?l=t[5]:(l=(0,J.jsx)(o,{className:`size-4`,"aria-hidden":!0}),t[4]=o,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,J.jsx)(`span`,{className:c,children:l}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]===s?d=t[10]:(d=(0,J.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:s}),t[9]=s,t[10]=d);let p;t[11]===n.detail?p=t[12]:(p=(0,J.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.detail}),t[11]=n.detail,t[12]=p);let m;t[13]!==d||t[14]!==p?(m=(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[d,p]}),t[13]=d,t[14]=p,t[15]=m):m=t[15];let h;t[16]===n.path?h=t[17]:(h=n.path?(0,J.jsx)(C,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=h);let g;t[18]!==u||t[19]!==m||t[20]!==h?(g=(0,J.jsxs)(J.Fragment,{children:[u,m,h]}),t[18]=u,t[19]=m,t[20]=h,t[21]=g):g=t[21];let _=g;if(n.path){let e;return t[22]!==_||t[23]!==n.path?(e=(0,J.jsx)(i,{to:n.path,className:`flex items-center gap-3 rounded-lg p-3 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:_}),t[22]=_,t[23]=n.path,t[24]=e):e=t[24],e}let v;return t[25]===_?v=t[26]:(v=(0,J.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:_}),t[25]=_,t[26]=v),v}function _e(e){let t=(0,I.c)(29),{signal:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=X(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,J.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,J.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,J.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]===n.status?d=t[12]:(d=f(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,Y(n.status)),t[11]=n.status,t[12]=d);let p;t[13]!==n.status||t[14]!==d?(p=(0,J.jsx)(`span`,{className:d,children:n.status}),t[13]=n.status,t[14]=d,t[15]=p):p=t[15];let m;t[16]!==r||t[17]!==n.path?(m=n.path?(0,J.jsx)(`span`,{className:`sr-only`,children:r}):null,t[16]=r,t[17]=n.path,t[18]=m):m=t[18];let h;t[19]!==s||t[20]!==u||t[21]!==p||t[22]!==m?(h=(0,J.jsxs)(J.Fragment,{children:[s,u,p,m]}),t[19]=s,t[20]=u,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g=h;if(n.path){let e;return t[24]!==g||t[25]!==n.path?(e=(0,J.jsx)(i,{to:n.path,className:`flex min-w-0 items-start gap-2 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:g}),t[24]=g,t[25]=n.path,t[26]=e):e=t[26],e}let _;return t[27]===g?_=t[28]:(_=(0,J.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:g}),t[27]=g,t[28]=_),_}function ve(){let e=s(l(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=q(),[a,o]=(0,F.useState)(!1),[c,u]=(0,F.useState)(`idle`),d=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],p=async()=>{if(!(a||!t)){o(!0),u(`idle`);try{await i(),u(`success`)}catch{u(`error`)}finally{o(!1)}}};return(0,J.jsxs)(j,{gap:`gap-6`,children:[(0,J.jsx)(A,{title:e.title,subtitle:e.subtitle,actions:(0,J.jsxs)(`button`,{type:`button`,className:f(`inline-flex shrink-0 items-center gap-2 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,E.press),onClick:()=>void p(),disabled:!t||a,"aria-busy":a,children:[(0,J.jsx)(k,{className:f(`size-4`,(!t||a)&&`animate-spin`),"aria-hidden":!0}),a?e.health.runDoctorRunning:e.refresh]})}),n?(0,J.jsx)(`p`,{className:`rounded-xl border border-red-300/40 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:e.loadError}):null,!t||!r?(0,J.jsx)(M,{sections:2}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(he,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void p(),doctorRunning:a,doctorRunState:c}),(0,J.jsxs)(P,{id:`next-steps`,children:[(0,J.jsx)(N,{icon:r.issues.length?b:y,title:e.nextStepsTitle,subtitle:r.issues.length?e.nextStepsIssuesSubtitle:e.nextStepsReadySubtitle}),r.issues.length?(0,J.jsx)(`div`,{className:`mt-4 flex flex-col gap-2`,children:r.issues.slice(0,8).map(t=>(0,J.jsx)(ge,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,J.jsx)(`div`,{className:`mt-4 rounded-lg bg-surface-panel/80 shadow-surface`,children:r.readiness.map(t=>(0,J.jsx)($,{item:t,labels:e.readinessLabels},t.id))})]}),(0,J.jsxs)(P,{children:[(0,J.jsx)(N,{icon:x,title:e.diagnosticsTitle,subtitle:e.diagnosticsSubtitle}),d.length?(0,J.jsx)(`div`,{className:`mt-4 grid gap-2 md:grid-cols-2`,children:d.map(t=>(0,J.jsx)(_e,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,J.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-panel/80 p-3 text-sm text-fg-muted shadow-surface`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})]})]})}export{ve as SetupStatusPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{h as i}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{a,n as o,o as s,r as c,s as l,t as u}from"./dist-CpzYSoz7.js";import{t as d}from"./check-DUBLcKHA.js";import{n as f,r as p}from"./popover-select-CKBYnT3c.js";import{t as m}from"./copy-Dv6d4Dvw.js";import{t as h}from"./loader-circle-CifKLtgG.js";import{t as g}from"./plus-Q2yW6OE7.js";import{t as _}from"./x-B_N4OPjy.js";import{t as v}from"./copy-to-clipboard-HOJ79TWv.js";import{t as y}from"./messages-BeIiRpmk.js";import{a as b,n as x,r as S,s as C}from"./locale-store-DJPCr2mb.js";import{t as w}from"./cn-JdwAhgNB.js";import{i as ee}from"./vendor-swr-BIWyz7Rc.js";import{t as T}from"./button-CtTvuElV.js";import{n as E,r as D}from"./gateway-config-swr-DEKSw3d-.js";import{t as O}from"./skeleton-BwbyijEw.js";import{$t as te,Bi as k,Ci as A,Hc as j,Hs as M,Jl as N,Nl as P,Ol as F,Ri as I,Si as L,Yl as R,Ys as z,_i as B,ba as V,bi as H,ci as U,di as W,gi as G,ho as K,ii as ne,li as re,mi as ie,nn as ae,oi as oe,pi as se,ui as ce,uu as le,vc as ue,vi as de,vl as fe,vt as pe,xi as me,yi as he}from"./index-BWdn9NaX.js";import{n as ge,r as _e,t as ve}from"./settings-page-layout-BRQNel6r.js";import{t as ye}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as q}from"./settings-form-section-dvGi1APN.js";import{t as be}from"./page-tabs-DoxnT3X4.js";var J=e(t(),1),xe=n(),Y={enabled:!0,defaultTtlHours:24,maxTtlDays:30,maxActiveShares:500,maxFileSizeMb:500,directoryMaxFolderSizeMb:2048,directoryMaxFileCount:1e4,inlinePreviewMimes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`application/pdf`,`text/html`,`text/markdown`,`text/plain`,`application/json`],noteEnabled:!0,noteMaxTotalSizeMb:250,noteMaxAttachmentCount:50,siteEnabled:!0,siteDefaultTtlHours:24,siteMaxTtlDays:30,maxActiveSites:50,siteMaxRootDirSizeMb:1024,siteMaxFileCount:2e4};function Se(){return structuredClone(Y)}var X=36e5,Z=864e5,Q=1048576;function Ce(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function we(e,t=32){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function Te(e){let t=Ce(e)?e:{},n=Ce(t.gateway)?t.gateway:{},r=Ce(n.share)?n.share:{},i=Ce(r.directory)?r.directory:{},a=Ce(r.note)?r.note:{},o=Ce(n.siteShare)?n.siteShare:{},s=Ce(o.static)?o.static:{},c=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):Y.defaultTtlHours*X,l=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):Y.maxTtlDays*Z,u=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):Y.maxFileSizeMb*Q,d=typeof i.maxFolderSize==`number`&&Number.isFinite(i.maxFolderSize)?Math.floor(i.maxFolderSize):Y.directoryMaxFolderSizeMb*Q,f=typeof o.defaultTtlMs==`number`&&Number.isFinite(o.defaultTtlMs)?Math.floor(o.defaultTtlMs):Y.siteDefaultTtlHours*X,p=typeof o.maxTtlMs==`number`&&Number.isFinite(o.maxTtlMs)?Math.floor(o.maxTtlMs):Y.siteMaxTtlDays*Z,m=typeof s.maxRootDirSize==`number`&&Number.isFinite(s.maxRootDirSize)?Math.floor(s.maxRootDirSize):Y.siteMaxRootDirSizeMb*Q,h=typeof a.maxTotalSize==`number`&&Number.isFinite(a.maxTotalSize)?Math.floor(a.maxTotalSize):Y.noteMaxTotalSizeMb*Q;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(c/X)),maxTtlDays:Math.max(1,Math.round(l/Z)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):Y.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(u/Q)),directoryMaxFolderSizeMb:Math.max(1,Math.round(d/Q)),directoryMaxFileCount:typeof i.maxFileCount==`number`&&Number.isFinite(i.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(i.maxFileCount))):Y.directoryMaxFileCount,inlinePreviewMimes:we(r.inlinePreviewMimes,32).length?we(r.inlinePreviewMimes,32):[...Y.inlinePreviewMimes],noteEnabled:a.enabled!==!1,noteMaxTotalSizeMb:Math.max(1,Math.round(h/Q)),noteMaxAttachmentCount:typeof a.maxAttachmentCount==`number`&&Number.isFinite(a.maxAttachmentCount)?Math.max(0,Math.min(500,Math.floor(a.maxAttachmentCount))):Y.noteMaxAttachmentCount,siteEnabled:o.enabled!==!1,siteDefaultTtlHours:Math.max(1,Math.round(f/X)),siteMaxTtlDays:Math.max(1,Math.round(p/Z)),maxActiveSites:typeof o.maxActiveSites==`number`&&Number.isFinite(o.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(o.maxActiveSites))):Y.maxActiveSites,siteMaxRootDirSizeMb:Math.max(1,Math.round(m/Q)),siteMaxFileCount:typeof s.maxFileCount==`number`&&Number.isFinite(s.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(s.maxFileCount))):Y.siteMaxFileCount}}function Ee(e){let t=e.defaultTtlHours*X,n=e.maxTtlDays*Z,r=e.siteDefaultTtlHours*X,i=e.siteMaxTtlDays*Z;return t<6e4||t>6048e5?`Default share TTL must be between 1 minute and 7 days.`:n<6e4||n>2592e6?`Maximum share TTL must be between 1 minute and 30 days.`:t>n?`Default TTL cannot exceed maximum TTL.`:e.maxActiveShares<1||e.maxActiveShares>1e4?`Maximum active shares must be between 1 and 10,000.`:e.maxActiveSites<1||e.maxActiveSites>1e3?`Maximum active site shares must be between 1 and 1,000.`:e.maxFileSizeMb<1||e.maxFileSizeMb>10240?`Maximum file size must be between 1 MB and 10 GB.`:e.directoryMaxFolderSizeMb<1||e.directoryMaxFolderSizeMb>10240?`Maximum folder size must be between 1 MB and 10 GB.`:e.directoryMaxFileCount<1||e.directoryMaxFileCount>1e5?`Maximum directory file count must be between 1 and 100,000.`:e.noteMaxTotalSizeMb<1||e.noteMaxTotalSizeMb>2048?`Maximum Note snapshot size must be between 1 MB and 2 GB.`:e.noteMaxAttachmentCount<0||e.noteMaxAttachmentCount>500?`Maximum Note attachment count must be between 0 and 500.`:r<6e4||r>6048e5?`Default site share TTL must be between 1 minute and 7 days.`:i<6e4||i>2592e6?`Maximum site share TTL must be between 1 minute and 30 days.`:r>i?`Default site TTL cannot exceed maximum site TTL.`:e.siteMaxRootDirSizeMb<1||e.siteMaxRootDirSizeMb>10240?`Maximum static site size must be between 1 MB and 10 GB.`:e.siteMaxFileCount<1||e.siteMaxFileCount>1e5?`Maximum static site file count must be between 1 and 100,000.`:null}async function De(e){let t=Ee(e);if(t)throw Error(t);await b(S(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*X,maxTtlMs:e.maxTtlDays*Z,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*Q,inlinePreviewMimes:e.inlinePreviewMimes,directory:{maxFolderSize:e.directoryMaxFolderSizeMb*Q,maxFileCount:e.directoryMaxFileCount},note:{enabled:e.noteEnabled,maxTotalSize:e.noteMaxTotalSizeMb*Q,maxAttachmentCount:e.noteMaxAttachmentCount}},siteShare:{enabled:e.siteEnabled,defaultTtlMs:e.siteDefaultTtlHours*X,maxTtlMs:e.siteMaxTtlDays*Z,maxActiveSites:e.maxActiveSites,static:{maxRootDirSize:e.siteMaxRootDirSizeMb*Q,maxFileCount:e.siteMaxFileCount}}}})}),E()}var $=r();function Oe(){return w(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,K,`dark:border-edge`)}function ke({hasToken:e}){let t=y(x(e=>e.language)).sharesSettings,{data:n,isLoading:r}=D(e),i=(0,J.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(Te(n.payload.config)),[n]),a=(0,J.useRef)(!1),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(!1),m=o??i,h=i,g=(0,J.useMemo)(()=>!m||!h?!1:JSON.stringify(m)!==JSON.stringify(h),[m,h]),_=(0,J.useCallback)(e=>{a.current=!0,s(t=>{let n=t??h;return n?{...n,...e}:null})},[h]),v=(0,J.useCallback)(async()=>{if(!(!m||c)){l(!0),d(null),p(!1);try{await De(m),a.current=!1,s(null),p(!0),window.setTimeout(()=>p(!1),2500)}catch(e){d(e instanceof Error?e.message:t.policySaveError)}finally{l(!1)}}},[m,c,t.policySaveError]),b=(0,J.useCallback)(()=>{a.current=!1,s(null),d(null),p(!1)},[]);return!e||!m?r?(0,$.jsx)(q,{children:(0,$.jsx)(ye,{rows:2})}):null:(0,$.jsxs)(q,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[f?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,$.jsx)(T,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>_(Se()),children:t.policyUseRecommended}),(0,$.jsx)(T,{type:`button`,variant:`secondary`,disabled:!g||c,onClick:b,children:t.policyDiscard}),(0,$.jsx)(T,{type:`button`,variant:`primary`,disabled:!g||c,onClick:()=>void v(),children:c?t.policySaving:t.policySave})]})]}),g?(0,$.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,u?(0,$.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,$.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,$.jsx)(Ae,{t,form:m,onChange:_})]})}function Ae(e){let t=(0,xe.c)(189),{t:n,form:r,onChange:i}=e,a;t[0]===n.policyFileSection?a=t[1]:(a=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyFileSection}),t[0]=n.policyFileSection,t[1]=a);let o;t[2]===n.policyFileSectionHint?o=t[3]:(o=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyFileSectionHint}),t[2]=n.policyFileSectionHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,$.jsxs)(`div`,{className:`mb-4`,children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.policyEnabled||t[13]!==l?(u=(0,$.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.policyEnabled]}),t[12]=n.policyEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({defaultTtlHours:e}),t[15]=i,t[16]=f);let p;t[17]!==r.defaultTtlHours||t[18]!==n.policyDefaultTtlHint||t[19]!==n.policyDefaultTtlHours||t[20]!==d||t[21]!==f?(p=(0,$.jsx)(je,{id:`share-default-ttl-hours`,label:n.policyDefaultTtlHours,hint:n.policyDefaultTtlHint,value:r.defaultTtlHours,min:1,max:168,disabled:d,onChange:f}),t[17]=r.defaultTtlHours,t[18]=n.policyDefaultTtlHint,t[19]=n.policyDefaultTtlHours,t[20]=d,t[21]=f,t[22]=p):p=t[22];let m=!r.enabled,h;t[23]===i?h=t[24]:(h=e=>i({maxTtlDays:e}),t[23]=i,t[24]=h);let g;t[25]!==r.maxTtlDays||t[26]!==n.policyMaxTtlDays||t[27]!==n.policyMaxTtlHint||t[28]!==m||t[29]!==h?(g=(0,$.jsx)(je,{id:`share-max-ttl-days`,label:n.policyMaxTtlDays,hint:n.policyMaxTtlHint,value:r.maxTtlDays,min:1,max:30,disabled:m,onChange:h}),t[25]=r.maxTtlDays,t[26]=n.policyMaxTtlDays,t[27]=n.policyMaxTtlHint,t[28]=m,t[29]=h,t[30]=g):g=t[30];let _=!r.enabled,v;t[31]===i?v=t[32]:(v=e=>i({maxActiveShares:e}),t[31]=i,t[32]=v);let y;t[33]!==r.maxActiveShares||t[34]!==n.policyMaxActiveShares||t[35]!==n.policyMaxActiveSharesHint||t[36]!==_||t[37]!==v?(y=(0,$.jsx)(je,{id:`share-max-active`,label:n.policyMaxActiveShares,hint:n.policyMaxActiveSharesHint,value:r.maxActiveShares,min:1,max:1e4,disabled:_,onChange:v}),t[33]=r.maxActiveShares,t[34]=n.policyMaxActiveShares,t[35]=n.policyMaxActiveSharesHint,t[36]=_,t[37]=v,t[38]=y):y=t[38];let b=!r.enabled,x;t[39]===i?x=t[40]:(x=e=>i({maxFileSizeMb:e}),t[39]=i,t[40]=x);let S;t[41]!==r.maxFileSizeMb||t[42]!==n.policyMaxFileSizeHint||t[43]!==n.policyMaxFileSizeMb||t[44]!==b||t[45]!==x?(S=(0,$.jsx)(je,{id:`share-max-file-mb`,label:n.policyMaxFileSizeMb,hint:n.policyMaxFileSizeHint,value:r.maxFileSizeMb,min:1,max:10240,disabled:b,onChange:x}),t[41]=r.maxFileSizeMb,t[42]=n.policyMaxFileSizeHint,t[43]=n.policyMaxFileSizeMb,t[44]=b,t[45]=x,t[46]=S):S=t[46];let C=!r.enabled,w;t[47]===i?w=t[48]:(w=e=>i({directoryMaxFolderSizeMb:e}),t[47]=i,t[48]=w);let ee;t[49]!==r.directoryMaxFolderSizeMb||t[50]!==n.policyDirectoryMaxFolderSizeHint||t[51]!==n.policyDirectoryMaxFolderSizeMb||t[52]!==C||t[53]!==w?(ee=(0,$.jsx)(je,{id:`share-directory-max-size-mb`,label:n.policyDirectoryMaxFolderSizeMb,hint:n.policyDirectoryMaxFolderSizeHint,value:r.directoryMaxFolderSizeMb,min:1,max:10240,disabled:C,onChange:w}),t[49]=r.directoryMaxFolderSizeMb,t[50]=n.policyDirectoryMaxFolderSizeHint,t[51]=n.policyDirectoryMaxFolderSizeMb,t[52]=C,t[53]=w,t[54]=ee):ee=t[54];let T=!r.enabled,E;t[55]===i?E=t[56]:(E=e=>i({directoryMaxFileCount:e}),t[55]=i,t[56]=E);let D;t[57]!==r.directoryMaxFileCount||t[58]!==n.policyDirectoryMaxFileCount||t[59]!==n.policyDirectoryMaxFileCountHint||t[60]!==T||t[61]!==E?(D=(0,$.jsx)(je,{id:`share-directory-max-files`,label:n.policyDirectoryMaxFileCount,hint:n.policyDirectoryMaxFileCountHint,value:r.directoryMaxFileCount,min:1,max:1e5,disabled:T,onChange:E}),t[57]=r.directoryMaxFileCount,t[58]=n.policyDirectoryMaxFileCount,t[59]=n.policyDirectoryMaxFileCountHint,t[60]=T,t[61]=E,t[62]=D):D=t[62];let O;t[63]!==g||t[64]!==y||t[65]!==S||t[66]!==ee||t[67]!==D||t[68]!==p?(O=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[p,g,y,S,ee,D]}),t[63]=g,t[64]=y,t[65]=S,t[66]=ee,t[67]=D,t[68]=p,t[69]=O):O=t[69];let te=!r.enabled,k;t[70]===i?k=t[71]:(k=e=>i({inlinePreviewMimes:e}),t[70]=i,t[71]=k);let A;t[72]!==r.inlinePreviewMimes||t[73]!==n||t[74]!==te||t[75]!==k?(A=(0,$.jsx)(Me,{t:n,values:r.inlinePreviewMimes,disabled:te,onChange:k}),t[72]=r.inlinePreviewMimes,t[73]=n,t[74]=te,t[75]=k,t[76]=A):A=t[76];let j;t[77]!==O||t[78]!==A||t[79]!==s||t[80]!==u?(j=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[s,u,O,A]}),t[77]=O,t[78]=A,t[79]=s,t[80]=u,t[81]=j):j=t[81];let M;t[82]===n.policyNoteSection?M=t[83]:(M=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyNoteSection}),t[82]=n.policyNoteSection,t[83]=M);let N;t[84]===n.policyNoteSectionHint?N=t[85]:(N=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyNoteSectionHint}),t[84]=n.policyNoteSectionHint,t[85]=N);let P;t[86]!==M||t[87]!==N?(P=(0,$.jsxs)(`div`,{className:`mb-4`,children:[M,N]}),t[86]=M,t[87]=N,t[88]=P):P=t[88];let F;t[89]===i?F=t[90]:(F=e=>i({noteEnabled:e.target.checked}),t[89]=i,t[90]=F);let I;t[91]!==r.noteEnabled||t[92]!==F?(I=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.noteEnabled,onChange:F}),t[91]=r.noteEnabled,t[92]=F,t[93]=I):I=t[93];let L;t[94]!==n.policyNoteEnabled||t[95]!==I?(L=(0,$.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[I,n.policyNoteEnabled]}),t[94]=n.policyNoteEnabled,t[95]=I,t[96]=L):L=t[96];let R=!r.enabled||!r.noteEnabled,z;t[97]===i?z=t[98]:(z=e=>i({noteMaxTotalSizeMb:e}),t[97]=i,t[98]=z);let B;t[99]!==r.noteMaxTotalSizeMb||t[100]!==n.policyNoteMaxTotalSizeHint||t[101]!==n.policyNoteMaxTotalSizeMb||t[102]!==R||t[103]!==z?(B=(0,$.jsx)(je,{id:`share-note-max-size-mb`,label:n.policyNoteMaxTotalSizeMb,hint:n.policyNoteMaxTotalSizeHint,value:r.noteMaxTotalSizeMb,min:1,max:2048,disabled:R,onChange:z}),t[99]=r.noteMaxTotalSizeMb,t[100]=n.policyNoteMaxTotalSizeHint,t[101]=n.policyNoteMaxTotalSizeMb,t[102]=R,t[103]=z,t[104]=B):B=t[104];let V=!r.enabled||!r.noteEnabled,H;t[105]===i?H=t[106]:(H=e=>i({noteMaxAttachmentCount:e}),t[105]=i,t[106]=H);let U;t[107]!==r.noteMaxAttachmentCount||t[108]!==n.policyNoteMaxAttachmentCount||t[109]!==n.policyNoteMaxAttachmentCountHint||t[110]!==V||t[111]!==H?(U=(0,$.jsx)(je,{id:`share-note-max-attachments`,label:n.policyNoteMaxAttachmentCount,hint:n.policyNoteMaxAttachmentCountHint,value:r.noteMaxAttachmentCount,min:0,max:500,disabled:V,onChange:H}),t[107]=r.noteMaxAttachmentCount,t[108]=n.policyNoteMaxAttachmentCount,t[109]=n.policyNoteMaxAttachmentCountHint,t[110]=V,t[111]=H,t[112]=U):U=t[112];let W;t[113]!==B||t[114]!==U?(W=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[B,U]}),t[113]=B,t[114]=U,t[115]=W):W=t[115];let G;t[116]!==P||t[117]!==L||t[118]!==W?(G=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[P,L,W]}),t[116]=P,t[117]=L,t[118]=W,t[119]=G):G=t[119];let K;t[120]===n.policySiteSection?K=t[121]:(K=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policySiteSection}),t[120]=n.policySiteSection,t[121]=K);let ne;t[122]===n.policySiteSectionHint?ne=t[123]:(ne=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policySiteSectionHint}),t[122]=n.policySiteSectionHint,t[123]=ne);let re;t[124]!==K||t[125]!==ne?(re=(0,$.jsxs)(`div`,{className:`mb-4`,children:[K,ne]}),t[124]=K,t[125]=ne,t[126]=re):re=t[126];let ie;t[127]===i?ie=t[128]:(ie=e=>i({siteEnabled:e.target.checked}),t[127]=i,t[128]=ie);let ae;t[129]!==r.siteEnabled||t[130]!==ie?(ae=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.siteEnabled,onChange:ie}),t[129]=r.siteEnabled,t[130]=ie,t[131]=ae):ae=t[131];let oe;t[132]!==n.policySiteEnabled||t[133]!==ae?(oe=(0,$.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[ae,n.policySiteEnabled]}),t[132]=n.policySiteEnabled,t[133]=ae,t[134]=oe):oe=t[134];let se=!r.siteEnabled,ce;t[135]===i?ce=t[136]:(ce=e=>i({siteDefaultTtlHours:e}),t[135]=i,t[136]=ce);let le;t[137]!==r.siteDefaultTtlHours||t[138]!==n.policySiteDefaultTtlHint||t[139]!==n.policySiteDefaultTtlHours||t[140]!==se||t[141]!==ce?(le=(0,$.jsx)(je,{id:`site-share-default-ttl-hours`,label:n.policySiteDefaultTtlHours,hint:n.policySiteDefaultTtlHint,value:r.siteDefaultTtlHours,min:1,max:168,disabled:se,onChange:ce}),t[137]=r.siteDefaultTtlHours,t[138]=n.policySiteDefaultTtlHint,t[139]=n.policySiteDefaultTtlHours,t[140]=se,t[141]=ce,t[142]=le):le=t[142];let ue=!r.siteEnabled,de;t[143]===i?de=t[144]:(de=e=>i({siteMaxTtlDays:e}),t[143]=i,t[144]=de);let fe;t[145]!==r.siteMaxTtlDays||t[146]!==n.policySiteMaxTtlDays||t[147]!==n.policySiteMaxTtlHint||t[148]!==ue||t[149]!==de?(fe=(0,$.jsx)(je,{id:`site-share-max-ttl-days`,label:n.policySiteMaxTtlDays,hint:n.policySiteMaxTtlHint,value:r.siteMaxTtlDays,min:1,max:30,disabled:ue,onChange:de}),t[145]=r.siteMaxTtlDays,t[146]=n.policySiteMaxTtlDays,t[147]=n.policySiteMaxTtlHint,t[148]=ue,t[149]=de,t[150]=fe):fe=t[150];let pe=!r.siteEnabled,me;t[151]===i?me=t[152]:(me=e=>i({maxActiveSites:e}),t[151]=i,t[152]=me);let he;t[153]!==r.maxActiveSites||t[154]!==n.policyMaxActiveSites||t[155]!==n.policyMaxActiveSitesHint||t[156]!==pe||t[157]!==me?(he=(0,$.jsx)(je,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,disabled:pe,onChange:me}),t[153]=r.maxActiveSites,t[154]=n.policyMaxActiveSites,t[155]=n.policyMaxActiveSitesHint,t[156]=pe,t[157]=me,t[158]=he):he=t[158];let ge=!r.siteEnabled,_e;t[159]===i?_e=t[160]:(_e=e=>i({siteMaxRootDirSizeMb:e}),t[159]=i,t[160]=_e);let ve;t[161]!==r.siteMaxRootDirSizeMb||t[162]!==n.policySiteMaxRootDirSizeHint||t[163]!==n.policySiteMaxRootDirSizeMb||t[164]!==ge||t[165]!==_e?(ve=(0,$.jsx)(je,{id:`site-share-max-root-size-mb`,label:n.policySiteMaxRootDirSizeMb,hint:n.policySiteMaxRootDirSizeHint,value:r.siteMaxRootDirSizeMb,min:1,max:10240,disabled:ge,onChange:_e}),t[161]=r.siteMaxRootDirSizeMb,t[162]=n.policySiteMaxRootDirSizeHint,t[163]=n.policySiteMaxRootDirSizeMb,t[164]=ge,t[165]=_e,t[166]=ve):ve=t[166];let ye=!r.siteEnabled,q;t[167]===i?q=t[168]:(q=e=>i({siteMaxFileCount:e}),t[167]=i,t[168]=q);let be;t[169]!==r.siteMaxFileCount||t[170]!==n.policySiteMaxFileCount||t[171]!==n.policySiteMaxFileCountHint||t[172]!==ye||t[173]!==q?(be=(0,$.jsx)(je,{id:`site-share-max-files`,label:n.policySiteMaxFileCount,hint:n.policySiteMaxFileCountHint,value:r.siteMaxFileCount,min:1,max:1e5,disabled:ye,onChange:q}),t[169]=r.siteMaxFileCount,t[170]=n.policySiteMaxFileCount,t[171]=n.policySiteMaxFileCountHint,t[172]=ye,t[173]=q,t[174]=be):be=t[174];let J;t[175]!==le||t[176]!==fe||t[177]!==he||t[178]!==ve||t[179]!==be?(J=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[le,fe,he,ve,be]}),t[175]=le,t[176]=fe,t[177]=he,t[178]=ve,t[179]=be,t[180]=J):J=t[180];let Y;t[181]!==re||t[182]!==oe||t[183]!==J?(Y=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[re,oe,J]}),t[181]=re,t[182]=oe,t[183]=J,t[184]=Y):Y=t[184];let Se;return t[185]!==j||t[186]!==G||t[187]!==Y?(Se=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[j,G,Y]}),t[185]=j,t[186]=G,t[187]=Y,t[188]=Se):Se=t[188],Se}function je(e){let t=(0,xe.c)(21),{id:n,label:r,hint:i,value:a,min:o,max:s,disabled:c,onChange:l}=e,u;t[0]!==n||t[1]!==r?(u=(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=u):u=t[2];let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=w(Oe(),`max-w-xs font-mono text-xs`),t[3]=d):d=t[3];let f;t[4]!==s||t[5]!==o||t[6]!==l?(f=e=>{let t=Number(e.target.value);Number.isFinite(t)&&l(Math.max(o,Math.min(s,Math.floor(t))))},t[4]=s,t[5]=o,t[6]=l,t[7]=f):f=t[7];let p;t[8]!==c||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==f||t[13]!==a?(p=(0,$.jsx)(`input`,{id:n,type:`number`,min:o,max:s,disabled:c,className:d,value:a,onChange:f}),t[8]=c,t[9]=n,t[10]=s,t[11]=o,t[12]=f,t[13]=a,t[14]=p):p=t[14];let m;t[15]===i?m=t[16]:(m=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=m);let h;return t[17]!==u||t[18]!==p||t[19]!==m?(h=(0,$.jsxs)(`div`,{children:[u,p,m]}),t[17]=u,t[18]=p,t[19]=m,t[20]=h):h=t[20],h}function Me(e){let t=(0,xe.c)(25),{t:n,values:r,disabled:i,onChange:a}=e,o;t[0]!==a||t[1]!==r?(o=e=>{let t=e.trim();!t||r.includes(t)||r.length>=32||a([...r,t])},t[0]=a,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===n.policyInlinePreviewMimes?c=t[4]:(c=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.policyInlinePreviewMimes}),t[3]=n.policyInlinePreviewMimes,t[4]=c);let l;t[5]===n.policyInlinePreviewMimesHint?l=t[6]:(l=(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.policyInlinePreviewMimesHint}),t[5]=n.policyInlinePreviewMimesHint,t[6]=l);let u;t[7]!==i||t[8]!==a||t[9]!==r?(u=r.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,i?null:(0,$.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,"aria-label":`Remove ${e}`,onClick:()=>a(r.filter(t=>t!==e)),children:`×`})]},e)),t[7]=i,t[8]=a,t[9]=r,t[10]=u):u=t[10];let d;t[11]===u?d=t[12]:(d=(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u}),t[11]=u,t[12]=d);let f;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(f=w(Oe(),`font-mono text-xs`),t[13]=f):f=t[13];let p=i||r.length>=32,m;t[14]===s?m=t[15]:(m=e=>{e.key===`Enter`&&(e.preventDefault(),s(e.target.value),e.target.value=``)},t[14]=s,t[15]=m);let h;t[16]!==n.policyMimePlaceholder||t[17]!==p||t[18]!==m?(h=(0,$.jsx)(`input`,{className:f,placeholder:n.policyMimePlaceholder,disabled:p,onKeyDown:m}),t[16]=n.policyMimePlaceholder,t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;return t[20]!==c||t[21]!==l||t[22]!==d||t[23]!==h?(g=(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[c,l,d,h]}),t[20]=c,t[21]=l,t[22]=d,t[23]=h,t[24]=g):g=t[24],g}function Ne(e){let t=(0,xe.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:d,selectKind:m,sessionKey:g,agentId:v}=e,b=m===void 0?`any`:m,S=y(x(Ie)),E=S.workspace,D=S.sharesSettings,O=ne(Fe),{data:k}=ee(C(Pe)?`picker-agents-list`:null,ae),A;bb0:{let e;t[0]===v?e=t[1]:(e=v?.trim(),t[0]=v,t[1]=e);let n=e;if(n){A=n;break bb0}let r;t[2]===O?r=t[3]:(r=O.trim(),t[2]=O,t[3]=r);let i=r;if(i){A=i;break bb0}if(k?.defaultId){A=k.defaultId;break bb0}if(k?.agents?.[0]?.id){A=k.agents[0].id;break bb0}A=``}let j=A,[M,N]=(0,J.useState)(j),P,L;t[4]===j?(P=t[5],L=t[6]):(P=()=>{N(j)},L=[j],t[4]=j,t[5]=P,t[6]=L),(0,J.useEffect)(P,L);let{tree:R,loading:z,error:B,loadRoot:V,loadChildren:H,reset:U}=oe(M,g??null),W;t[7]===d?W=t[8]:(W=d?{path:d,isDirectory:!1}:null,t[7]=d,t[8]=W);let[G,K]=(0,J.useState)(W),re;t[9]!==d||t[10]!==V||t[11]!==n||t[12]!==U||t[13]!==K?(re=()=>{if(!n){U(),K(d?{path:d,isDirectory:!1}:null);return}V()},t[9]=d,t[10]=V,t[11]=n,t[12]=U,t[13]=K,t[14]=re):re=t[14];let ie;t[15]!==d||t[16]!==V||t[17]!==n||t[18]!==M||t[19]!==U||t[20]!==g?(ie=[n,M,g,V,U,d],t[15]=d,t[16]=V,t[17]=n,t[18]=M,t[19]=U,t[20]=g,t[21]=ie):ie=t[21],(0,J.useEffect)(re,ie);let se;t[22]===H?se=t[23]:(se=e=>{H(e)},t[22]=H,t[23]=se);let ce=se,le=G!==null&&(b===`any`||b===`file`&&!G.isDirectory||b===`directory`&&G.isDirectory),de;bb1:{if(!G){de=D.pickerHintNone;break bb1}if(b===`file`&&G.isDirectory){de=D.pickerHintNeedsFile;break bb1}if(b===`directory`&&!G.isDirectory){de=D.pickerHintNeedsDirectory;break bb1}de=`${G.isDirectory?`📁`:`📄`} ${G.path}`}let fe=de,pe=k?.agents??[],me;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,$.jsx)(a,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=me):me=t[24];let he;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(he=w(`fixed left-1/2 top-1/2 z-[71] w-[min(34rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2`,`flex h-[min(28rem,calc(100vh-3rem))] flex-col overflow-hidden rounded-lg border border-edge bg-surface-panel shadow-popover outline-none`),t[25]=he):he=t[25];let ge;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(F,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=ge):ge=t[26];let _e=S.cron.refresh,ve=S.cron.refresh,ye;t[27]===V?ye=t[28]:(ye=()=>void V(),t[27]=V,t[28]=ye);let q=z&&`animate-spin`,be;t[29]===q?be=t[30]:(be=w(`size-4`,q),t[29]=q,t[30]=be);let Y;t[31]===be?Y=t[32]:(Y=(0,$.jsx)(ue,{className:be,"aria-hidden":!0}),t[31]=be,t[32]=Y);let Se;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,$.jsx)(_,{className:`size-4`}),t[33]=Se):Se=t[33];let X;t[34]!==B||t[35]!==E.loadError?(X=B?(0,$.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[E.loadError,`: `,B]}):null,t[34]=B,t[35]=E.loadError,t[36]=X):X=t[36];let Z;t[37]!==ce||t[38]!==z||t[39]!==G?.path||t[40]!==K||t[41]!==E.emptyDir||t[42]!==E.title||t[43]!==R?(Z=z&&R.length===0?(0,$.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(h,{className:`size-4 animate-spin`}),E.title,`…`]}):(0,$.jsx)(I,{tree:R,selectedPath:G?.path??null,onSelectFile:e=>K({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>K({path:e,isDirectory:t}),onExpandDir:ce,onAction:void 0,emptyHint:E.emptyDir}),t[37]=ce,t[38]=z,t[39]=G?.path,t[40]=K,t[41]=E.emptyDir,t[42]=E.title,t[43]=R,t[44]=Z):Z=t[44];let Q;t[45]!==X||t[46]!==Z?(Q=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[X,Z]}),t[45]=X,t[46]=Z,t[47]=Q):Q=t[47];let Ce;t[48]===fe?Ce=t[49]:(Ce=(0,$.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:fe}),t[48]=fe,t[49]=Ce);let we;t[50]===r?we=t[51]:(we=()=>r(!1),t[50]=r,t[51]=we);let Te;t[52]!==D.cancel||t[53]!==we?(Te=(0,$.jsx)(T,{type:`button`,variant:`ghost`,onClick:we,children:D.cancel}),t[52]=D.cancel,t[53]=we,t[54]=Te):Te=t[54];let Ee=!le,De;t[55]!==i||t[56]!==r||t[57]!==M||t[58]!==G?(De=()=>{G&&(i({...G,agentId:M}),r(!1))},t[55]=i,t[56]=r,t[57]=M,t[58]=G,t[59]=De):De=t[59];let Oe;t[60]!==D.pickerConfirm||t[61]!==Ee||t[62]!==De?(Oe=(0,$.jsx)(T,{type:`button`,disabled:Ee,onClick:De,children:D.pickerConfirm}),t[60]=D.pickerConfirm,t[61]=Ee,t[62]=De,t[63]=Oe):Oe=t[63];let ke;t[64]!==Te||t[65]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Te,Oe]}),t[64]=Te,t[65]=Oe,t[66]=ke):ke=t[66];let Ae;return t[67]!==Ce||t[68]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[Ce,ke]}),t[67]=Ce,t[68]=ke,t[69]=Ae):Ae=t[69],(0,$.jsx)(u,{open:n,onOpenChange:r,children:(0,$.jsxs)(s,{children:[me,(0,$.jsxs)(c,{className:he,children:[(0,$.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[ge,(0,$.jsx)(l,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:D.pickerTitle}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:_e,"aria-label":ve,disabled:z,onClick:ye,children:Y}),(0,$.jsx)(o,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":E.close,children:Se})})]}),pe.length>0?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,$.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:D.pickerAgentLabel}),(0,$.jsx)(f,{id:`picker-agent-select`,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:M,onChange:e=>{N(e.target.value),K(null)},children:pe.map(e=>(0,$.jsxs)(p,{value:e.id,children:[te(e,S.agentsSettings),e.id===k?.defaultId?` ★`:``]},e.id))})]}):null,Q,Ae]})]})})}function Pe(e){return e.token}function Fe(e){return e.agentId}function Ie(e){return e.language}var Le=[`shares`,`policy`];function Re(e){let t=(e??``).trim();return Le.includes(t)?t:`shares`}function ze(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function Be(e,t){let n=new Date(e).getTime()-Date.now(),r=Math.abs(n),i=n<0;if(r<6e4)return t===`zh`?`刚刚`:`just now`;let a=Math.floor(r/6e4);if(a<60){let e=t===`zh`?`${a} 分钟`:`${a}m`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let o=Math.floor(a/60);if(o<24){let e=t===`zh`?`${o} 小时`:`${o}h`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let s=Math.floor(o/24),c=t===`zh`?`${s} 天`:`${s}d`;return i?t===`zh`?`${c}前`:`${c} ago`:c}var Ve=[{value:36e5,key:`1h`},{value:216e5,key:`6h`},{value:864e5,key:`24h`},{value:2592e5,key:`3d`},{value:6048e5,key:`7d`},{value:2592e6,key:`30d`}];function He(){let e=(0,xe.c)(24),t=x(We),n=y(t).sharesSettings,r=!!C(Ue),[a,o]=i(),s;e[0]===a?s=e[1]:(s=Re(a.get(`tab`)),e[0]=a,e[1]=s);let c=s,l;e[2]===o?l=e[3]:(l=e=>{o(t=>{let n=new URLSearchParams(t);return e===`shares`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[2]=o,e[3]=l);let u=l;if(!r)return(0,$.jsx)(_e,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let d={shares:n.tabShares,policy:n.tabPolicy},f=Le.map(e=>({id:e,label:d[e]})),p;e[4]!==n.subtitle||e[5]!==n.title?(p=(0,$.jsx)(ge,{title:n.title,subtitle:n.subtitle}),e[4]=n.subtitle,e[5]=n.title,e[6]=p):p=e[6];let m;e[7]!==c||e[8]!==u||e[9]!==n.tabsAria||e[10]!==f?(m=(0,$.jsx)(be,{items:f,activeTab:c,onChange:u,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[7]=c,e[8]=u,e[9]=n.tabsAria,e[10]=f,e[11]=m):m=e[11];let h;e[12]!==c||e[13]!==r||e[14]!==t||e[15]!==n?(h=c===`shares`?(0,$.jsx)(Ge,{t:n,language:t}):(0,$.jsx)(ke,{hasToken:r}),e[12]=c,e[13]=r,e[14]=t,e[15]=n,e[16]=h):h=e[16];let g;e[17]!==c||e[18]!==h?(g=(0,$.jsx)(ve,{id:c,activeTab:c,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:h}),e[17]=c,e[18]=h,e[19]=g):g=e[19];let _;return e[20]!==p||e[21]!==m||e[22]!==g?(_=(0,$.jsxs)(_e,{children:[p,m,g]}),e[20]=p,e[21]=m,e[22]=g,e[23]=_):_=e[23],_}function Ue(e){return e.token}function We(e){return e.language}function Ge(e){let t=(0,xe.c)(79),{t:n,language:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:3e4},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,mutate:c}=ee(`shares-list`,G,i),l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:3e4},t[1]=l):l=t[1];let u=ee(`hosted-publications-list`,ie,l),d;t[2]===a?.payload?.shares?d=t[3]:(d=a?.payload?.shares??[],t[2]=a?.payload?.shares,t[3]=d);let f=d,[p,m]=(0,J.useState)(!1),h;bb0:{if(p){h=f;break bb0}let e;t[4]===f?e=t[5]:(e=f.filter(Xe),t[4]=f,t[5]=e),h=e}let g=h,_;t[6]===f?_=t[7]:(_=f.filter(Ye),t[6]=f,t[7]=_);let v=_.length,y;t[8]===f?y=t[9]:(y=f.filter(Je),t[8]=f,t[9]=y);let b=y.length,x;t[10]===c?x=t[11]:(x=()=>void c(),t[10]=c,t[11]=x);let S;t[12]!==n||t[13]!==x?(S=(0,$.jsx)(nt,{t:n,onCreated:x}),t[12]=n,t[13]=x,t[14]=S):S=t[14];let C=u.data?.connected===!0,E=u.data?.publishingAllowed===!0,D;t[15]===u?D=t[16]:(D=()=>void u.mutate(),t[15]=u,t[16]=D);let O;t[17]!==r||t[18]!==E||t[19]!==D||t[20]!==C?(O=(0,$.jsx)(Ze,{language:r,connected:C,publishingAllowed:E,onCreated:D}),t[17]=r,t[18]=E,t[19]=D,t[20]=C,t[21]=O):O=t[21];let te=p?n.allSharesTitle:n.listTitle,k;t[22]===v?k=t[23]:(k=v>0&&(0,$.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,v,`)`]}),t[22]=v,t[23]=k);let A;t[24]!==te||t[25]!==k?(A=(0,$.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[te,k]}),t[24]=te,t[25]=k,t[26]=A):A=t[26];let j;t[27]===c?j=t[28]:(j=()=>void c(),t[27]=c,t[28]=j);let M=s&&`animate-spin`,N;t[29]===M?N=t[30]:(N=w(`size-3.5`,M),t[29]=M,t[30]=N);let P;t[31]===N?P=t[32]:(P=(0,$.jsx)(ue,{className:N}),t[31]=N,t[32]=P);let F;t[33]!==s||t[34]!==j||t[35]!==P?(F=(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:j,disabled:s,children:P}),t[33]=s,t[34]=j,t[35]=P,t[36]=F):F=t[36];let I;t[37]!==b||t[38]!==p||t[39]!==n.hideExpired||t[40]!==n.showExpired?(I=b>0&&(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>m(qe),children:p?n.hideExpired:n.showExpired}),t[37]=b,t[38]=p,t[39]=n.hideExpired,t[40]=n.showExpired,t[41]=I):I=t[41];let L;t[42]!==F||t[43]!==I?(L=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[F,I]}),t[42]=F,t[43]=I,t[44]=L):L=t[44];let R;t[45]!==A||t[46]!==L?(R=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[A,L]}),t[45]=A,t[46]=L,t[47]=R):R=t[47];let z;t[48]!==a||t[49]!==o||t[50]!==g||t[51]!==s||t[52]!==r||t[53]!==c||t[54]!==n?(z=s&&!a?(0,$.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(Ke)}):o?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,$.jsx)(`span`,{children:n.error}),(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void c(),children:n.retry})]}):g.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map(e=>(0,$.jsx)(it,{share:e,t:n,language:r,onRevoked:()=>void c(),onExtended:()=>void c()},e.id))}),t[48]=a,t[49]=o,t[50]=g,t[51]=s,t[52]=r,t[53]=c,t[54]=n,t[55]=z):z=t[55];let B;t[56]!==b||t[57]!==c||t[58]!==p||t[59]!==n?(B=b>0&&p&&(0,$.jsx)(at,{t:n,onCleaned:()=>void c()}),t[56]=b,t[57]=c,t[58]=p,t[59]=n,t[60]=B):B=t[60];let V;t[61]!==R||t[62]!==z||t[63]!==B?(V=(0,$.jsxs)(q,{children:[R,z,B]}),t[61]=R,t[62]=z,t[63]=B,t[64]=V):V=t[64];let H;t[65]===u?H=t[66]:(H=()=>void u.mutate(),t[65]=u,t[66]=H);let U;t[67]!==u.data||t[68]!==u.error||t[69]!==u.isLoading||t[70]!==r||t[71]!==n||t[72]!==H?(U=(0,$.jsx)(Qe,{data:u.data,error:u.error,isLoading:u.isLoading,language:r,t:n,onChanged:H}),t[67]=u.data,t[68]=u.error,t[69]=u.isLoading,t[70]=r,t[71]=n,t[72]=H,t[73]=U):U=t[73];let W;return t[74]!==O||t[75]!==V||t[76]!==U||t[77]!==S?(W=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[S,O,V,U]}),t[74]=O,t[75]=V,t[76]=U,t[77]=S,t[78]=W):W=t[78],W}function Ke(e,t){return(0,$.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(O,{className:`h-4 w-2/3`}),(0,$.jsx)(O,{className:`mt-2 h-3 w-1/2`})]}),(0,$.jsx)(O,{className:`h-7 w-20 rounded-md`})]})},t)}function qe(e){return!e}function Je(e){return e.expired||e.revoked}function Ye(e){return!e.expired&&!e.revoked}function Xe(e){return!e.expired&&!e.revoked}function Ze({language:e,connected:t,publishingAllowed:n,onCreated:r}){let i=e===`zh`,[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(!1),[d,m]=(0,J.useState)(!1),[g,_]=(0,J.useState)(``),[y,b]=(0,J.useState)(6048e5),[x,S]=(0,J.useState)(!1),[C,w]=(0,J.useState)(null),[ee,E]=(0,J.useState)(null),D=async()=>{if(a.trim()){S(!0),E(null);try{w(await re({path:a.trim(),title:g.trim()||void 0,ttlMs:y,spaFallback:!0,...s?{agentId:s}:{}})),r()}catch(e){E(e instanceof Error?e.message:String(e))}finally{S(!1)}}};return(0,$.jsxs)(q,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(N,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:i?`发布静态网站`:`Publish static website`}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:i?`把工作区内的 HTML 文件,或包含 index.html 的网站目录,发布到隔离的托管域名。`:`Publish an HTML file or a website directory containing index.html to the isolated hosted origin.`}),t&&!n?(0,$.jsx)(`p`,{className:`mt-3 rounded-md border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning`,children:i?`管理员已暂停你的公网分享能力。已有远端链接当前不可访问;你仍可在下方撤销它们。`:`An administrator has paused public sharing for your account. Existing hosted links are unavailable, but you can still revoke them below.`}):null,(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-[1fr_12rem]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`input`,{value:a,onChange:e=>{o(e.target.value),u(!1),w(null)},placeholder:i?`选择 HTML 文件或网站目录`:`Select an HTML file or website directory`,className:`h-9 min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent`}),(0,$.jsxs)(T,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>m(!0),children:[a&&!l?(0,$.jsx)(P,{className:`size-4`}):(0,$.jsx)(F,{className:`size-4`}),a?i?`更换`:`Change`:i?`选择`:`Browse`]})]}),(0,$.jsxs)(f,{value:String(y),onChange:e=>b(Number(e.target.value)),children:[(0,$.jsx)(p,{value:`86400000`,children:i?`24 小时`:`24 hours`}),(0,$.jsx)(p,{value:`604800000`,children:i?`7 天`:`7 days`}),(0,$.jsx)(p,{value:`2592000000`,children:i?`30 天`:`30 days`})]}),(0,$.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),placeholder:i?`网站标题(可选)`:`Site title (optional)`,className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent sm:col-span-2`})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,$.jsxs)(T,{type:`button`,onClick:()=>void D(),disabled:!a.trim()||x||!t||!n,children:[x?(0,$.jsx)(h,{className:`size-4 animate-spin`}):(0,$.jsx)(N,{className:`size-4`}),x?i?`发布中…`:`Publishing…`:i?`发布网站`:`Publish site`]}),C?(0,$.jsxs)(`button`,{type:`button`,className:`min-w-0 truncate text-xs text-accent hover:underline`,onClick:()=>void v(C.shareUrl),children:[C.shareUrl,` · `,C.fileCount,` `,i?`个文件`:`files`,` · `,ze(C.totalBytes)]}):null]}),ee?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-danger`,children:ee}):null]})]}),(0,$.jsx)(Ne,{open:d,onOpenChange:m,initialPath:a||void 0,agentId:s||void 0,selectKind:`any`,onConfirm:e=>{o(e.path),c(e.agentId),u(e.isDirectory),w(null),E(null)}})]})}function Qe(e){let t=(0,xe.c)(18),{data:n,error:r,isLoading:i,language:a,t:o,onChanged:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(N,{className:`size-4 text-accent`,"aria-hidden":!0}),t[0]=c):c=t[0];let l;t[1]===o.hostedTitle?l=t[2]:(l=(0,$.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[c,o.hostedTitle]}),t[1]=o.hostedTitle,t[2]=l);let u;t[3]===o.hostedHint?u=t[4]:(u=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.hostedHint}),t[3]=o.hostedHint,t[4]=u);let d;t[5]!==l||t[6]!==u?(d=(0,$.jsx)(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:(0,$.jsxs)(`div`,{children:[l,u]})}),t[5]=l,t[6]=u,t[7]=d):d=t[7];let f;t[8]!==n||t[9]!==r||t[10]!==i||t[11]!==a||t[12]!==s||t[13]!==o?(f=i&&!n?(0,$.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:2}).map($e)}):r?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o.error}):n?.connected?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[n.publishingAllowed?null:(0,$.jsx)(`p`,{className:`rounded-md border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning`,children:a===`zh`?`管理员已暂停公网分享。已有托管链接当前不可访问,也不能更新;撤销操作仍然可用。`:`An administrator has paused public sharing. Existing hosted links are unavailable and cannot be updated; revocation remains available.`}),n.publications.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hostedEmpty}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:n.publications.map(e=>(0,$.jsx)(et,{publication:e,language:a,t:o,publishingAllowed:n.publishingAllowed,onChanged:s},e.id))})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hostedDisconnected}),(0,$.jsx)(pe,{providerId:`xopc-share`,displayName:`XOPC Hosted Share`,connected:!1,onConnected:s})]}),t[8]=n,t[9]=r,t[10]=i,t[11]=a,t[12]=s,t[13]=o,t[14]=f):f=t[14];let p;return t[15]!==d||t[16]!==f?(p=(0,$.jsxs)(q,{children:[d,f]}),t[15]=d,t[16]=f,t[17]=p):p=t[17],p}function $e(e,t){return(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsx)(O,{className:`h-4 w-2/3`}),(0,$.jsx)(O,{className:`mt-2 h-3 w-1/2`})]},t)}function et({publication:e,language:t,t:n,publishingAllowed:r,onChanged:i}){let[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(!1),[f,p]=(0,J.useState)(!1),[g,_]=(0,J.useState)(!1),y=Date.now()>=new Date(e.expiresAt).getTime(),b=e.status===`active`&&!y,x=e.status===`revoked`?n.statusRevoked:y?n.statusExpired:e.status===`staging`?t===`zh`?`准备中`:`Staging`:n.statusActive,S=e.kind===`note_document`?z:e.kind===`static_site`?N:j,C=e.kind===`note_document`?t===`zh`?`笔记文档`:`Note document`:e.kind===`static_site`?t===`zh`?`静态网站`:`Static website`:t===`zh`?`会话快照`:`Conversation snapshot`,ee=(0,J.useCallback)(async()=>{e.shareUrl&&await v(e.shareUrl)&&(u(!0),window.setTimeout(()=>u(!1),2e3))},[e.shareUrl]),E=(0,J.useCallback)(async()=>{o(!1),c(!0);try{await de(e.id),i()}catch{}finally{c(!1)}},[e.id,i]),D=(0,J.useCallback)(async()=>{if(!(!e.revision||e.revision<=1)){p(!0);try{let t=(await se(e.id)).find(t=>t.revision<e.revision);if(!t)return;await H(e.id,e.revision,t.revision),i()}catch{}finally{p(!1)}}},[e.id,e.revision,i]),O=(0,J.useCallback)(async()=>{_(!0);try{await B(e.id),i()}catch{}finally{_(!1)}},[e.id,i]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-panel/80 px-3 py-2.5`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(S,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(`span`,{className:w(`text-xs font-medium`,b?`text-emerald-600 dark:text-emerald-400`:`text-fg-subtle`),children:x})]}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[C,` · `,n.hostedRevision,` `,e.revision??`—`,` · `,e.managedFromThisDevice?n.hostedThisDevice:n.hostedOtherDevice]}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,$.jsxs)(`span`,{children:[t===`zh`?`浏览`:`Views`,`: `,e.viewCount,e.maxViews===null?``:` / ${e.maxViews}`]}),(0,$.jsx)(`span`,{children:y?n.statusExpired:Be(e.expiresAt,t)}),e.description?(0,$.jsx)(`span`,{className:`italic`,children:e.description}):null]})]}),b?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.shareUrl?(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:!r,title:n.copyUrl,onClick:()=>void ee(),children:l?(0,$.jsx)(d,{className:`size-3.5 text-emerald-500`}):(0,$.jsx)(m,{className:`size-3.5`})}):null,(e.revision??0)>1?(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:f||!r,onClick:()=>void D(),title:t===`zh`?`回滚上一版本`:`Roll back one revision`,children:f?(0,$.jsx)(h,{className:`size-3.5 animate-spin`}):(0,$.jsx)(fe,{className:`size-3.5`})}):null,e.kind===`static_site`&&e.managedFromThisDevice?(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:g||!r,onClick:()=>void O(),title:t===`zh`?`发布工作区中的最新版本`:`Publish latest workspace version`,children:(0,$.jsx)(ue,{className:w(`size-3.5`,g&&`animate-spin`)})}):null,(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,disabled:s,onClick:()=>o(!0),children:s?(0,$.jsx)(h,{className:`size-3.5 animate-spin`}):(0,$.jsx)(M,{className:`size-3.5`})})]}):null]})}),(0,$.jsx)(k,{open:a,title:n.revokeConfirmTitle,description:n.revokeConfirmBody,confirmLabel:n.revokeConfirmLabel,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void E(),onCancel:()=>o(!1)})]})}var tt={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function nt({t:e,onCreated:t}){let[n,r]=(0,J.useReducer)(V,tt),{expanded:i,path:a,isDirectory:o,agentId:s,ttlMs:c,maxViews:l,description:u,directoryMode:d,creating:m,result:_,errorMsg:v,resultDialogOpen:y,pickerOpen:b}=n,x=(0,J.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await ce({path:a.trim(),ttlMs:c,maxViews:l,description:u.trim()||void 0,...s?{agentId:s}:{},...o?{kind:`directory`,directoryMode:d}:{}})).payload,resultDialogOpen:!0}}),t()}catch(e){r({type:`patch`,patch:{errorMsg:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{creating:!1}})}}},[a,o,s,c,l,u,d,t]),S=(0,J.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,$.jsxs)(q,{children:[(0,$.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,$.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:w(`flex min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm`,a?`text-fg`:`text-fg-subtle`),children:a?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:o?`📁`:`📄`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:a})]}):(0,$.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,$.jsxs)(T,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,$.jsx)(P,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),o?(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,$.jsxs)(f,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:d,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,$.jsx)(p,{value:`browse`,children:e.directoryModeBrowse}),(0,$.jsx)(p,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,$.jsx)(f,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:c,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:Ve.map(t=>(0,$.jsx)(p,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,$.jsxs)(f,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:l??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,$.jsx)(p,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,$.jsx)(p,{value:`1`,children:`1`}),(0,$.jsx)(p,{value:`5`,children:`5`}),(0,$.jsx)(p,{value:`10`,children:`10`}),(0,$.jsx)(p,{value:`50`,children:`50`}),(0,$.jsx)(p,{value:`100`,children:`100`})]})]})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,$.jsx)(`input`,{type:`text`,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:outline-none focus:ring-2 focus:ring-accent`,placeholder:e.descriptionPlaceholder,value:u,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,$.jsxs)(T,{type:`button`,disabled:m||!a.trim(),onClick:()=>void x(),children:[m?(0,$.jsx)(h,{className:`size-4 animate-spin`}):(0,$.jsx)(g,{className:`size-4`}),m?e.creating:e.createButton]}),(0,$.jsx)(T,{type:`button`,variant:`ghost`,onClick:()=>{S(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),v&&(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:v})]}),(0,$.jsx)(L,{open:y,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:_}),(0,$.jsx)(Ne,{open:b,onOpenChange:e=>r({type:`patch`,patch:{pickerOpen:e}}),initialPath:a||void 0,selectKind:`any`,onConfirm:e=>r({type:`patch`,patch:{path:e.path,isDirectory:e.isDirectory,agentId:e.agentId,directoryMode:`browse`}})})]}):(0,$.jsxs)(T,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,$.jsx)(g,{className:`size-4`}),e.createTitle]})}var rt={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function it({share:e,t,language:n,onRevoked:r,onExtended:i}){let[a,o]=(0,J.useReducer)(V,rt),{revokeOpen:s,revoking:c,linksOpen:l,urlCopied:u,copyFailed:f,extending:p}=a,g=!e.expired&&!e.revoked,_=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,y=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,b=(0,J.useCallback)(async()=>{o({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await he(e.id),r()}catch{}finally{o({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),x=(0,J.useCallback)(async()=>{if(o({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await v(e.shareUrl)){o({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>o({type:`patch`,patch:{copyFailed:!1}}),2500);return}o({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>o({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),S=(0,J.useCallback)(async()=>{o({type:`patch`,patch:{extending:!0}});try{await W(e.id,864e5),i()}catch{}finally{o({type:`patch`,patch:{extending:!1}})}},[e.id,i]),C=`share-links-${e.id}`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,className:w(`flex min-w-0 flex-1 items-start gap-3 rounded-md text-left`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),"aria-expanded":l,"aria-controls":C,onClick:()=>o({type:`patch`,patch:{linksOpen:!l}}),children:[(0,$.jsx)(le,{className:w(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,l?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),e.kind===`note`?(0,$.jsx)(z,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):e.kind===`session`?(0,$.jsx)(j,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(P,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,$.jsx)(`span`,{className:w(`text-xs font-medium`,y),children:_})]}),(0,$.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.kind===`note`?n===`zh`?`笔记快照 · 版本 ${e.snapshotRevision??1}`:`Note snapshot · revision ${e.snapshotRevision??1}`:e.kind===`session`?n===`zh`?`会话快照 · ${e.messageCount??0} 条消息 · 版本 ${e.snapshotRevision??1}`:`Conversation snapshot · ${e.messageCount??0} messages · revision ${e.snapshotRevision??1}`:e.workspaceRelativePath}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{children:ze(e.fileSize)}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(R,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:Be(e.expiresAt,n)]}),(0,$.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,$.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:g&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void x(),children:u?(0,$.jsx)(d,{className:`size-3.5 text-emerald-500`}):(0,$.jsx)(m,{className:`size-3.5`})}),(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void S(),disabled:p,title:t.extend,children:p?(0,$.jsx)(h,{className:`size-3.5 animate-spin`}):(0,$.jsx)(R,{className:`size-3.5`})}),(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>o({type:`patch`,patch:{revokeOpen:!0}}),disabled:c,children:c?(0,$.jsx)(h,{className:`size-3.5 animate-spin`}):(0,$.jsx)(M,{className:`size-3.5`})})]})})]}),g&&l?(0,$.jsxs)(`div`,{id:C,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,$.jsx)(A,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),f?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(me,{reachability:e.reachability})})]}):null]}),(0,$.jsx)(k,{open:s,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void b(),onCancel:()=>o({type:`patch`,patch:{revokeOpen:!1}})})]})}function at({t:e,onCleaned:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!1),o=(0,J.useCallback)(async()=>{r(!1),a(!0);try{await U(),t()}catch{}finally{a(!1)}},[t]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsxs)(T,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>r(!0),className:`border-danger/40 px-2 py-1 text-xs text-danger hover:bg-danger/10`,children:[i?(0,$.jsx)(h,{className:`size-3.5 animate-spin`}):(0,$.jsx)(M,{className:`size-3.5`}),e.cleanExpired]})}),(0,$.jsx)(k,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{He as SharesSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{d as a,h as o,p as s,t as c}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{i as l,n as u,o as d,r as f,s as p,t as m}from"./dist-CpzYSoz7.js";import{n as h,r as g}from"./popover-select-CKBYnT3c.js";import{t as _}from"./circle-check-C23XjkUj.js";import{t as v}from"./external-link-DjqjBmc3.js";import{d as ee,p as te,t as ne}from"./markdown-view-k_PJsY2C.js";import{t as re}from"./x-B_N4OPjy.js";import{n as ie,s as y}from"./locale-store-DJPCr2mb.js";import{t as b}from"./cn-JdwAhgNB.js";import{t as x}from"./button-CtTvuElV.js";import{t as S}from"./skeleton-BwbyijEw.js";import{Ar as ae,Bi as C,Ds as w,Ec as T,Es as oe,Hc as se,Mc as ce,Oa as le,Ol as ue,Ou as de,P as E,Rl as fe,Ss as D,Ts as pe,_n as O,aa as me,as as he,bs as ge,cs as k,ds as A,eo as j,eu as M,gn as N,gs as P,hn as F,kl as I,mn as _e,n as ve,ni as L,pn as ye,qn as be,ri as xe,ss as Se,tu as Ce,vn as we,ws as Te,zt as Ee}from"./index-BWdn9NaX.js";import{t as De}from"./date-picker-vKUcJeQZ.js";import{t as Oe}from"./dependency-picker-BpZ9A2gi.js";var R=e(t(),1),ke=e(n(),1),z=r();function Ae(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function je(e,t){let n={...e.task};t.title!==void 0&&(n.title=t.title),t.priority!==void 0&&(n.priority=t.priority);for(let e of[`body`,`projectId`,`milestoneId`,`parentTaskId`,`dueAt`,`ownerId`]){let r=t[e];r!==void 0&&(r===null?delete n[e]:Object.assign(n,{[e]:r}))}return n.version+=1,n.updatedAt=Date.now(),{...e,task:n}}var B=i();function Me(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已完成`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Completed`})[e]}function Ne(){let e=(0,z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,B.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,B.jsx)(S,{className:`h-32 rounded-2xl`}),(0,B.jsx)(S,{className:`h-52 rounded-2xl`}),(0,B.jsx)(S,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Pe(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function Fe(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var V=[`backlog`,`ready`,`active`,`review`,`closed`],H=[`low`,`normal`,`high`,`critical`],Ie=(0,R.memo)(function(e){let t=(0,z.c)(20),{value:n,disabled:r,canMove:i,canApprove:a,canReopen:o,language:s,label:c,onChange:l}=e,u;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(u=e=>e!==n&&(e===`closed`?!a:n===`closed`?!o:!i),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=u):u=t[4];let d=u,f;t[5]===c?f=t[6]:(f=(0,B.jsx)(`span`,{children:c}),t[5]=c,t[6]=f);let p;t[7]===l?p=t[8]:(p=e=>l(e.target.value),t[7]=l,t[8]=p);let m;t[9]!==s||t[10]!==d?(m=V.map(e=>(0,B.jsx)(g,{value:e,disabled:d(e),children:Me(e,s)},e)),t[9]=s,t[10]=d,t[11]=m):m=t[11];let _;t[12]!==r||t[13]!==p||t[14]!==m||t[15]!==n?(_=(0,B.jsx)(h,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:p,children:m}),t[12]=r,t[13]=p,t[14]=m,t[15]=n,t[16]=_):_=t[16];let v;return t[17]!==f||t[18]!==_?(v=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[f,_]}),t[17]=f,t[18]=_,t[19]=v):v=t[19],v}),Le=(0,R.memo)(function(e){let t=(0,z.c)(14),{value:n,disabled:r,label:i,labels:a,onChange:o}=e,s;t[0]===i?s=t[1]:(s=(0,B.jsx)(`span`,{children:i}),t[0]=i,t[1]=s);let c;t[2]===o?c=t[3]:(c=e=>o(e.target.value),t[2]=o,t[3]=c);let l;t[4]===a?l=t[5]:(l=H.map(e=>(0,B.jsx)(g,{value:e,children:a[e]},e)),t[4]=a,t[5]=l);let u;t[6]!==r||t[7]!==c||t[8]!==l||t[9]!==n?(u=(0,B.jsx)(h,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:c,children:l}),t[6]=r,t[7]=c,t[8]=l,t[9]=n,t[10]=u):u=t[10];let d;return t[11]!==s||t[12]!==u?(d=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[s,u]}),t[11]=s,t[12]=u,t[13]=d):d=t[13],d}),Re=(0,R.memo)(function(e){let t=(0,z.c)(10),{value:n,disabled:r,label:i,onChange:a}=e,o;t[0]===i?o=t[1]:(o=(0,B.jsx)(`span`,{children:i}),t[0]=i,t[1]=o);let s;t[2]!==r||t[3]!==i||t[4]!==a||t[5]!==n?(s=(0,B.jsx)(De,{disabled:r,value:n,onChange:a,ariaLabel:i}),t[2]=r,t[3]=i,t[4]=a,t[5]=n,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}),ze=(0,R.memo)(function(e){let t=(0,z.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:s}=e,c;t[0]===i?c=t[1]:(c=(0,B.jsx)(`span`,{children:i}),t[0]=i,t[1]=c);let l;t[2]===s?l=t[3]:(l=e=>s(e.target.value),t[2]=s,t[3]=l);let u;t[4]===a?u=t[5]:(u=(0,B.jsx)(g,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=u);let d;t[6]===o?d=t[7]:(d=o.map(nt),t[6]=o,t[7]=d);let f;t[8]!==r||t[9]!==l||t[10]!==u||t[11]!==d||t[12]!==n?(f=(0,B.jsxs)(h,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:l,children:[u,d]}),t[8]=r,t[9]=l,t[10]=u,t[11]=d,t[12]=n,t[13]=f):f=t[13];let p;return t[14]!==c||t[15]!==f?(p=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[c,f]}),t[14]=c,t[15]=f,t[16]=p):p=t[16],p}),Be=(0,R.memo)(function(e){let t=(0,z.c)(8),{candidates:n,selected:r,disabled:i,labels:a,onChange:o}=e,s;t[0]===r?s=t[1]:(s=r.map(rt),t[0]=r,t[1]=s);let c;return t[2]!==n||t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,B.jsx)(Oe,{borderless:!0,candidates:n,selectedIds:s,disabled:i,onChange:o,labels:a}),t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c},(e,t)=>e.disabled===t.disabled&&e.labels===t.labels&&e.onChange===t.onChange&&e.candidates.length===t.candidates.length&&e.candidates.every((e,n)=>e.id===t.candidates[n]?.id&&e.title===t.candidates[n]?.title)&&e.selected.length===t.selected.length&&e.selected.every((e,n)=>e.id===t.selected[n]?.id&&e.title===t.selected[n]?.title)),Ve=`xopc.taskDetail.chatPanelPercent`,He=42;function Ue(e,t){let n=Math.max(30,352/Math.max(t,1)*100),r=Math.min(60,(t-480)/Math.max(t,1)*100);return r<n?He:Math.min(r,Math.max(n,e))}function We(){try{let e=Number(window.localStorage.getItem(Ve));return Number.isFinite(e)&&e>=30&&e<=60?e:He}catch{return He}}function Ge(e){return e.task.phase===`closed`?e.task.resolution===`done`?`completed`:`ended`:e.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`)?`needsUser`:e.operationalState===`idle`?e.task.phase===`backlog`?`captured`:e.task.phase===`ready`?`ready`:e.task.phase===`review`?`review`:`paused`:e.operationalState}function U(e){let t=(0,z.c)(9),{items:n,empty:r,verificationByCriterion:i}=e;if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,B.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:r}),t[0]=r,t[1]=e),e}let a;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>{let t=i?.get(e)??`unverified`;return(0,B.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,B.jsx)(t===`passed`?_:t===`failed`?Ce:M,{className:t===`passed`?`mt-1 size-4 shrink-0 text-success`:t===`failed`?`mt-1 size-4 shrink-0 text-danger`:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,B.jsx)(`span`,{children:e})]},e)},t[5]=i,t[6]=e),a=n.map(e),t[2]=n,t[3]=i,t[4]=a}else a=t[4];let o;return t[7]===a?o=t[8]:(o=(0,B.jsx)(`ul`,{className:`space-y-2`,children:a}),t[7]=a,t[8]=o),o}function Ke({taskId:e,presentation:t,backgroundPath:n,onDeleted:r}){let[i]=o(),s=a(),l=ie(e=>e.language),u=y(e=>e.token),d=(0,R.useMemo)(()=>w(l),[l]),f=j(e=>e.setPageHeader),p=j(e=>e.clearPageHeader),m=xe(e=>e.open),h=xe(e=>e.sessionKeyOverride),g=xe(e=>e.openForSession),re=be(e=>e.setOpen),{data:S,error:M,mutate:L,lastChange:Ce,conversationLoading:Ee,conversationError:De}=he(e),[Oe,z]=(0,R.useState)(null),[Me,V]=(0,R.useState)(null),[H,Ke]=(0,R.useState)(()=>new Set),[qe,Je]=(0,R.useState)([]),[W,Ye]=(0,R.useState)(null),[Xe,Ze]=(0,R.useState)([]),[Qe,G]=(0,R.useState)(!1),[$e,et]=(0,R.useState)(``),[tt,K]=(0,R.useState)(!1),[nt,rt]=(0,R.useState)(``),[it,at]=(0,R.useState)(We),[ot,st]=(0,R.useState)(!1),ct=(0,R.useRef)(null),lt=(0,R.useRef)(!1),ut=(0,R.useRef)(!1),dt=(0,R.useRef)(``),ft=(0,R.useRef)(null),pt=(0,R.useRef)(null),mt=(0,R.useRef)(null),ht=(0,R.useRef)(S),[gt,q]=(0,R.useState)(null),[_t,vt]=(0,R.useState)(null),[yt,bt]=(0,R.useState)(!1),xt=(0,R.useMemo)(()=>({link:d.linkDependencies,linked:d.linkedDependencies,searchPlaceholder:d.dependencySearchPlaceholder,noMatches:d.noDependencyMatches,noCandidates:d.noDependencyCandidates,remove:d.removeDependency}),[d.dependencySearchPlaceholder,d.linkDependencies,d.linkedDependencies,d.noDependencyCandidates,d.noDependencyMatches,d.removeDependency]),St=S?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,Ct=(0,R.useMemo)(()=>ee(i.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[i]);ht.current=S;let J=(0,R.useCallback)((e,t)=>{Ke(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,R.useEffect)(()=>{V(null),q(null),G(!1),K(!1),vt(null),bt(!1)},[e]),(0,R.useEffect)(()=>{let e=!0;return le().then(t=>{e&&Ze(t.items)}).catch(()=>void 0),()=>{e=!1}},[u]),(0,R.useEffect)(()=>{if(!Ce||Ce.source===`user`)return;vt(Ce);let e=window.setTimeout(()=>vt(null),3500);return()=>window.clearTimeout(e)},[Ce]),(0,R.useEffect)(()=>{let t=S?.task.projectId,n=S?.dependencies??[];if(!t){mt.current=null,Ye(null),Je(n);return}mt.current!==t&&(mt.current=t,Ye(null));let r=!0;return me(t).then(t=>{if(!r)return;Ye(t.project.name);let i=new Map;for(let r of[...t.tasks,...n])r.id!==e&&i.set(r.id,{id:r.id,title:r.title});Je([...i.values()])}).catch(()=>{r&&Je(n)}),()=>{r=!1}},[St,S?.task.projectId,e]);let Y=(0,R.useCallback)(async(t,n=`command`)=>{let r=ht.current;if(r){J(n,!0),V(null);try{await L(await k(e,t,r.task.version),{revalidate:!1})}catch{V(d.actionFailed)}finally{J(n,!1)}}},[d.actionFailed,L,J,e]),X=(0,R.useCallback)(async(t,n)=>{let r=ht.current;if(!r)return!1;n&&J(n,!0),V(null);try{return await L(D(e,t,r.task.version),{optimisticData:je(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return V(d.actionFailed),!1}finally{n&&J(n,!1)}},[d.actionFailed,L,J,e]),wt=async()=>{if(!S)return;if(lt.current){lt.current=!1;return}let e=$e.trim(),t=ft.current;if(Ae(t,S.task.version,S.task.title,e)){q(`title`);return}if(!e||e===S.task.title){et(S.task.title),G(!1);return}await X({title:e})&&(q(null),G(!1))},Tt=async()=>{if(!S)return;if(ut.current){ut.current=!1;return}let e=nt.trim(),t=pt.current;if(Ae(t,S.task.version,S.task.body??``,e)){q(`description`);return}if(nt===dt.current||e===(S.task.body??``).trim()){K(!1);return}await X({body:e||null})&&(q(null),K(!1))},Et=(0,R.useCallback)(async e=>{let t=ht.current;if(!(!t||e===t.task.phase)){if(t.task.phase===`closed`){await Y({type:`reopen`,phase:e===`closed`?`ready`:e},`phase`);return}if(e===`closed`){await Y({type:`close`,resolution:`done`},`phase`);return}await Y({type:`move`,phase:e},`phase`)}},[Y]),Dt=(0,R.useCallback)(e=>{X({priority:e},`priority`)},[X]),Ot=(0,R.useCallback)(e=>{X({dueAt:Fe(e)},`dueAt`)},[X]),kt=(0,R.useCallback)(e=>{at(e);try{window.localStorage.setItem(Ve,String(e))}catch{}},[]),At=(0,R.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=ct.current?.clientWidth??0;kt(Ue(e.key===`Home`?He:it+(e.key===`ArrowLeft`?2:-2),t))},[it,kt]),jt=(0,R.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=ct.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),st(!0);let i=it,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=Ue((n.right-e.clientX)/n.width*100,n.width),a===0&&(a=window.requestAnimationFrame(o))},c=()=>{a!==0&&(window.cancelAnimationFrame(a),o());try{n.releasePointerCapture(r)}catch{}st(!1),kt(i),window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[it,kt]),Mt=(0,R.useCallback)(async t=>{let n=ht.current;if(n){J(`dependencies`,!0),V(null);try{await L(await Te(e,t,n.task.version),{revalidate:!1})}catch{V(d.dependencyUpdateFailed)}finally{J(`dependencies`,!1)}}},[d.dependencyUpdateFailed,L,J,e]),Nt=(0,R.useCallback)(async t=>{let n=ht.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){J(`delegateAgentId`,!0),V(null);try{await L(await P(e,t,n.task.version),{revalidate:!1})}catch{V(d.actionFailed)}finally{J(`delegateAgentId`,!1)}}},[d.actionFailed,L,J,e]),Pt=(0,R.useCallback)(async()=>{J(`delete`,!0),V(null);try{await A(e),r?r():s(Ct,{replace:!0})}catch(e){V(e instanceof Error?e.message:d.actionFailed)}finally{J(`delete`,!1)}},[d.actionFailed,s,r,Ct,J,e]);if((0,R.useLayoutEffect)(()=>{if(t!==`modal`)return f({startExtra:(0,B.jsx)(c,{to:Ct,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":d.backToWork,children:(0,B.jsx)(de,{className:`size-4`})}),main:S?(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:W?`${W} / ${d.taskLabel}`:d.taskLabel}),(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:d.detailStatuses[Ge(S)]})]}):null,end:(0,B.jsx)(`div`,{ref:z,className:`flex min-w-0 items-center justify-end`})}),p},[p,d.backToWork,d.detailStatuses,d.taskLabel,S,t,W,Ct,f]),M&&!S)return(0,B.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:d.taskNotFound});if(!S)return(0,B.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,B.jsx)(Ne,{})});let Ft=S.waits[0],It=Ft?.kind===`paused`?Ft:void 0,Z=S.receipts[0],Lt=d.detailStatuses[Ge(S)],Rt=d.detailStatusDescriptions[Ge(S)],zt=S.task.body?.trim()||S.task.contract?.objective.trim(),Bt=new Map(Z?.verification.checks.map(e=>[e.criterion,e.status])),Vt=S.allowedCommands.includes(`mark_ready`),Ht=S.allowedCommands.includes(`start`),Ut=S.allowedCommands.includes(`add_wait`),Wt=S.task.phase===`review`&&S.allowedCommands.includes(`close`),Gt=S.allowedCommands.includes(`reopen`),Kt=S.conversation.activeSessionKey,qt=S.conversation.currentExecutorAgentId??S.task.delegateAgentId??S.task.ownerId,Jt=Xe.find(e=>e.id===qt),Yt=!!(Kt&&m&&h===Kt),Xt=S.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),Zt=S.task.contract?.acceptanceCriteria??[],Qt=Zt.filter(e=>Bt.get(e)===`passed`).length,$t=S.task.contract?.expectedOutputs??[],en=S.task.contract?.constraints??[],tn=S.task.contract?.approvalRequired??[],nn=S.task.contract?.assumptions??[],rn=S.task.contract?.risks??[],Q=(...e)=>!!_t?.changedFields.some(t=>e.includes(t)),an=e=>t===`modal`&&n?oe(n,e):te(`/tasks/${e}`,Ct),on=S.allowedCommands.includes(`move`),$=H.has(`command`),sn=H.has(`delete`),cn=S.runs.find(e=>[`queued`,`running`,`waiting`,`verifying`].includes(e.status)),ln=cn!==void 0,un=(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Vt?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`mark_ready`}),children:[(0,B.jsx)(T,{className:`size-4`}),d.scheduleTask]}):null,It?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`resolve_wait`,waitId:It.id}),children:[(0,B.jsx)(T,{className:`size-4`}),d.resumeTask]}):null,!Ft&&Ht&&qt?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`start`,executor:{kind:`agent`,agentId:qt}}),children:[(0,B.jsx)(T,{className:`size-4`}),d.runTask]}):null,Wt?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`close`,resolution:`done`}),children:[(0,B.jsx)(_,{className:`size-4`}),d.approveTask]}):null,Gt?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`reopen`,phase:`ready`}),children:[(0,B.jsx)(T,{className:`size-4`}),d.reopenTask]}):null,!Ft&&Ut?(0,B.jsxs)(x,{variant:`secondary`,className:`border-0 bg-surface-hover shadow-none`,disabled:$,onClick:()=>void Y({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,B.jsx)(ce,{className:`size-4`}),d.pauseTask]}):null,(0,B.jsxs)(N,{children:[(0,B.jsx)(we,{asChild:!0,children:(0,B.jsx)(x,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:$||sn,"aria-label":d.moreActions,children:(0,B.jsx)(fe,{className:`size-4`,"aria-hidden":!0})})}),(0,B.jsx)(F,{children:(0,B.jsxs)(ye,{align:`end`,sideOffset:6,className:`z-[100] min-w-44 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[cn?(0,B.jsx)(_e,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{J(`command`,!0),V(null),L(Se(e,cn.id,cn.version),{revalidate:!1}).catch(()=>V(d.actionFailed)).finally(()=>J(`command`,!1))},children:d.cancelActiveRun}):null,cn?(0,B.jsx)(O,{className:`my-1 h-px bg-edge`}):null,S.task.phase===`closed`?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(_e,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void Y({type:`close`,resolution:`cancelled`}),children:d.cancelTask}),(0,B.jsx)(O,{className:`my-1 h-px bg-edge`})]}),(0,B.jsx)(_e,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{if(ln){V(d.deleteActiveTaskBlocked);return}bt(!0)},children:d.deleteTask})]})})]})]}),Kt&&t!==`modal`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(x,{type:`button`,variant:`ghost`,className:b(`h-8 shrink-0 px-2 text-xs`,Yt&&`bg-surface-hover text-fg`),"aria-label":l===`zh`?`项目文件`:`Project files`,"aria-pressed":Yt,onClick:()=>{re(Kt,!1),g(Kt)},children:[(0,B.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),l===`zh`?`文件`:`Files`]}),(0,B.jsx)(x,{asChild:!0,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,children:(0,B.jsxs)(c,{to:pe(e),children:[(0,B.jsx)(v,{className:`size-3.5`}),l===`zh`?`全屏`:`Full screen`]})})]}):null]});return(0,B.jsxs)(`div`,{ref:ct,className:`${t===`modal`?`flex h-full min-h-0 flex-col lg:flex-row`:`flex min-h-[calc(100dvh-8rem)] flex-col overflow-hidden lg:flex-row`} ${ot?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${it}%`},children:[t===`page`&&Oe?(0,ke.createPortal)(un,Oe):null,(0,B.jsxs)(`section`,{className:`task-detail-scroll min-w-0 flex-1 overflow-y-auto overscroll-contain p-5 sm:p-6`,children:[(0,B.jsxs)(`header`,{className:b(`px-4 pb-5`,Q(`title`)&&`task-detail-live-update`),children:[(0,B.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[W?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),W]}):null,(0,B.jsx)(`span`,{children:`/`}),(0,B.jsx)(`span`,{children:d.taskLabel}),_t?(0,B.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:_t.source===`agent`?l===`zh`?`Agent 刚刚更新`:`Updated by Agent`:l===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),Qe?(0,B.jsx)(`input`,{autoFocus:!0,"data-task-inline-editor":!0,value:$e,onChange:e=>et(e.target.value),onBlur:()=>void wt(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),lt.current=!0,et(S.task.title),G(!1),queueMicrotask(()=>{lt.current=!1}))},className:`mt-3 w-full max-w-3xl rounded-lg bg-surface-hover px-3 py-2 text-2xl font-semibold leading-8 text-fg outline-none ring-2 ring-accent/30 focus:ring-accent/60`}):(0,B.jsx)(`button`,{type:`button`,className:`mt-3 block max-w-3xl rounded-lg text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{ft.current={value:S.task.title,version:S.task.version},q(null),et(S.task.title),G(!0)},children:(0,B.jsx)(`h1`,{className:`text-2xl font-semibold leading-8 text-fg`,children:S.task.title})}),gt===`title`?(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,B.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{et(S.task.title),q(null),G(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void X({title:$e.trim()}).then(e=>{e&&(q(null),G(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]})}),Me?(0,B.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:Me}):null]}),(0,B.jsxs)(`div`,{className:`mt-5 flex flex-col gap-5`,children:[(0,B.jsxs)(`main`,{className:`order-2 min-w-0 space-y-5`,children:[(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`body`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.taskDescription}),tt?(0,B.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:nt,onChange:e=>rt(e.target.value),onBlur:()=>void Tt(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ut.current=!0,rt(S.task.body??S.task.contract?.objective??``),K(!1),queueMicrotask(()=>{ut.current=!1}))},className:`mt-3 w-full resize-y rounded-lg bg-surface-hover px-3 py-2 text-sm leading-6 text-fg outline-none ring-2 ring-accent/20 focus:ring-accent/50`}):(0,B.jsx)(`button`,{type:`button`,className:`-mx-1 mt-2 block w-[calc(100%+0.5rem)] rounded-lg px-1 py-1 text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{let e=S.task.body??S.task.contract?.objective??``;dt.current=e,pt.current={value:S.task.body??``,version:S.task.version},q(null),rt(e),K(!0)},children:(0,B.jsx)(`span`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg-muted`,children:zt&&zt!==S.task.title?zt:d.noTaskDescription})}),gt===`description`?(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,B.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{rt(S.task.body??``),q(null),K(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void X({body:nt.trim()||null}).then(e=>{e&&(q(null),K(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),S.attention.length>0?(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-warning/10 p-4`,Q(`attention`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h3`,{className:`font-medium text-fg`,children:Xt?d.needsAttention:d.waitingStatus}),(0,B.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm text-fg-muted`,children:S.attention.map((e,t)=>(0,B.jsx)(`li`,{children:e.summary},`${e.kind}-${t}`))})]}):null,(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`contract`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.taskDefinition}),(0,B.jsxs)(`div`,{className:`mt-5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:d.successDefinition}),Zt.length>0?(0,B.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:d.criteriaProgress.replace(`{{verified}}`,String(Qt)).replace(`{{total}}`,String(Zt.length))}):null]}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:Zt,empty:d.noDefinition,verificationByCriterion:Bt})})]}),$t.length>0?(0,B.jsxs)(`div`,{className:`mt-5 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:d.expectedOutputs}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:$t,empty:d.noDefinition})})]}):null,en.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:d.constraints}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:en,empty:d.noDefinition})})]}):null,tn.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:d.approvalRequired}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:tn,empty:d.noDefinition})})]}):null,nn.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:d.contextAssumptions}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:nn,empty:d.noDefinition})})]}):null,rn.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:d.contextRisks}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:rn,empty:d.noDefinition})})]}):null]}),Z?(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.latestResult}),(0,B.jsx)(ne,{content:Z.summary,compact:!0,className:`mt-2 text-sm leading-6 text-fg`})]}),(0,B.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[d.receiptStatuses[Z.status],` · `,d.verificationStatuses[Z.verification.status]]})]}),Z.remainingWork.length>0?(0,B.jsxs)(`div`,{className:`mt-4`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:d.remainingWork}),(0,B.jsx)(`div`,{className:`mt-2`,children:(0,B.jsx)(U,{items:Z.remainingWork,empty:d.noRemainingWork})})]}):null,Z.nextAction?(0,B.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,B.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:d.nextAction}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:Z.nextAction})]}):null,(0,B.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(x,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void ge(Z.runId,`helpful`),children:d.doneWell}),(0,B.jsx)(x,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void ge(Z.runId,`not_helpful`),children:d.needsFix}),Z.evidence.filter(e=>e.uri).map(e=>(0,B.jsxs)(`a`,{className:`ml-auto inline-flex items-center gap-1 text-xs text-accent hover:underline`,href:e.uri,children:[(0,B.jsx)(v,{className:`size-3`}),e.title]},`${e.title}-${e.uri}`))]}),S.receipts.length>1?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:d.executionHistory.replace(`{{count}}`,String(S.receipts.length-1))}),(0,B.jsx)(`div`,{className:`mt-3 space-y-3`,children:S.receipts.slice(1).map(e=>(0,B.jsx)(`article`,{className:`rounded-lg bg-surface-active p-3`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,B.jsx)(`p`,{className:`text-sm text-fg`,children:e.summary}),(0,B.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:d.receiptStatuses[e.status]})]})},e.runId))})]}):null]}):null,S.context.length>0?(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`context`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.contextUsed}),(0,B.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:S.context.map(e=>(0,B.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,B.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[d.contextRoleLabels[e.role],` · `,d.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,B.jsx)(`a`,{className:`mt-1 block break-all text-sm text-accent hover:underline`,href:e.targetId,target:`_blank`,rel:`noreferrer`,children:e.title??e.targetId}):(0,B.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,B.jsxs)(`aside`,{className:`order-1 min-w-0 space-y-4`,children:[(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-subtle p-4`,Q(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.taskProperties}),(0,B.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,B.jsx)(Ie,{value:S.task.phase,disabled:H.has(`phase`),canMove:on,canApprove:Wt,canReopen:Gt,language:l,label:d.taskPhase,onChange:Et}),(0,B.jsx)(Le,{value:S.task.priority,disabled:H.has(`priority`),label:d.priority,labels:d.priorityLabels,onChange:Dt}),(0,B.jsx)(Re,{value:Pe(S.task.dueAt),disabled:H.has(`dueAt`),label:d.dueDate,onChange:Ot}),(0,B.jsx)(ze,{value:S.conversation.currentExecutorAgentId??``,disabled:H.has(`delegateAgentId`),label:d.executorLabel,unassignedLabel:d.unassigned,agents:Xe,onChange:Nt}),W?(0,B.jsxs)(`div`,{className:`grid gap-1 text-xs text-fg-muted`,children:[(0,B.jsx)(`span`,{children:d.projectLabel}),(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-lg bg-surface-hover px-3 py-2 text-sm text-fg`,children:[(0,B.jsx)(I,{className:`size-3.5`}),W]})]}):null]}),(0,B.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3 text-xs leading-5 text-fg-subtle`,children:[(0,B.jsx)(`p`,{children:Lt}),(0,B.jsx)(`p`,{children:Rt}),(0,B.jsx)(`p`,{className:`mt-2`,children:d.updatedAt.replace(`{{date}}`,ae(S.task.updatedAt,l))})]})]}),(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`dependencies`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.taskRelations}),(0,B.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:d.dependencies}),(0,B.jsx)(Be,{candidates:qe,selected:S.dependencies,disabled:H.has(`dependencies`),labels:xt,onChange:Mt})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:d.dependents}),S.dependents.length>0?(0,B.jsx)(`div`,{className:`space-y-1.5`,children:S.dependents.map(e=>(0,B.jsx)(c,{to:an(e.id),className:`block rounded-lg bg-surface-hover p-2.5 text-sm text-accent hover:underline`,children:e.title},e.id))}):(0,B.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:d.noDependents})]})]})]})]})]})]}),(0,B.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":l===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(it),tabIndex:0,onPointerDown:jt,onKeyDown:At,onDoubleClick:()=>kt(He),className:`group hidden w-2 shrink-0 cursor-col-resize touch-none items-stretch justify-center bg-surface-panel outline-none transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover lg:flex ${ot?`bg-surface-hover`:``}`,children:(0,B.jsx)(`div`,{className:`my-3 w-px rounded-full bg-edge-strong/70 transition-colors group-hover:bg-accent group-focus-visible:bg-accent`})}),(0,B.jsxs)(`aside`,{className:`flex min-h-[34rem] min-w-0 flex-col bg-surface-panel lg:min-h-0 lg:w-[var(--task-chat-panel-width)] lg:shrink-0`,children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 bg-surface-subtle px-4 py-3.5`,children:[(0,B.jsx)(`div`,{className:`min-w-0`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[qt?(0,B.jsx)(E,{agentId:qt,avatar:Jt?.avatar,size:28,className:`shrink-0`}):null,(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:l===`zh`?`Agent 执行与对话`:`Agent execution and chat`}),(0,B.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[Jt?.name??qt??d.unassigned,` · `,Lt]})]})]})}),t===`modal`?un:null]}),Kt?(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(ve,{embedded:!0,sessionKey:Kt,taskId:e})}):Ee?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,B.jsxs)(`div`,{className:`max-w-xs`,children:[(0,B.jsx)(se,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,B.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):De?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,B.jsxs)(`div`,{className:`max-w-xs`,children:[(0,B.jsx)(se,{className:`mx-auto size-8 text-danger`}),(0,B.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,B.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:De instanceof Error?De.message:String(De)})]})}):(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,B.jsxs)(`div`,{className:`max-w-xs`,children:[(0,B.jsx)(se,{className:`mx-auto size-8 text-fg-subtle`}),(0,B.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,B.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:l===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]}),(0,B.jsx)(C,{open:yt,title:d.deleteTaskTitle,description:d.deleteTaskDescription.replace(`{{title}}`,S.task.title),confirmLabel:d.confirmDeleteTask,cancelLabel:d.keepTask,destructive:!0,onConfirm:()=>{bt(!1),Pt()},onCancel:()=>bt(!1)})]})}function qe(){let e=(0,z.c)(2),{taskId:t}=s(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,B.jsx)(Ke,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function Je(e){let t=(0,z.c)(58),{taskId:n,backgroundPath:r,onClose:i}=e,a=ie(K),{data:o}=he(n),s=o?.conversation.activeSessionKey??null,h=xe(tt),g=xe(et),_=xe($e),ee=xe(G),te=be(Qe),ne=L(Ze),y=L(Xe),x=h?g:0,S;t[0]!==i||t[1]!==y?(S=e=>{e||(y(null),i())},t[0]=i,t[1]=y,t[2]=S):S=t[2];let ae=a===`zh`?`关闭任务详情`:`Close task details`,C;t[3]!==i||t[4]!==y?(C=()=>{y(null),i()},t[3]=i,t[4]=y,t[5]=C):C=t[5];let w;t[6]!==ae||t[7]!==C?(w=(0,B.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45 backdrop-blur-[1px]`,"aria-label":ae,onClick:C}),t[6]=ae,t[7]=C,t[8]=w):w=t[8];let T=h?`true`:`false`,oe=`${x/2}px`,se=`${x}px`,ce;t[9]!==oe||t[10]!==se?(ce={"--task-detail-workspace-offset":oe,"--task-detail-workspace-width":se},t[9]=oe,t[10]=se,t[11]=ce):ce=t[11];let le=ce,de=a===`zh`?`任务详情`:`Task details`,E;t[12]===de?E=t[13]:(E=(0,B.jsx)(p,{className:`font-medium text-fg`,children:de}),t[12]=de,t[13]=E);let fe=a===`zh`?`查看并操作任务详情`:`View and manage task details`,D;t[14]===fe?D=t[15]:(D=(0,B.jsx)(l,{className:`sr-only`,children:fe}),t[14]=fe,t[15]=D);let O;t[16]!==s||t[17]!==a||t[18]!==ee||t[19]!==te||t[20]!==n||t[21]!==h||t[22]!==_?(O=s?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,className:b(`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,h&&_===s&&`bg-surface-hover text-fg`),"aria-label":a===`zh`?`项目文件`:`Project files`,title:a===`zh`?`项目文件`:`Project files`,"aria-pressed":h&&_===s,onClick:()=>{te(s,!1),ee(s)},children:(0,B.jsx)(ue,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsx)(c,{to:pe(n),className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":a===`zh`?`全屏打开对话`:`Open chat full screen`,title:a===`zh`?`全屏打开对话`:`Open chat full screen`,children:(0,B.jsx)(v,{className:`size-4`,"aria-hidden":!0})})]}):null,t[16]=s,t[17]=a,t[18]=ee,t[19]=te,t[20]=n,t[21]=h,t[22]=_,t[23]=O):O=t[23];let me=a===`zh`?`关闭任务详情`:`Close task details`,ge;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,B.jsx)(re,{className:`size-4`,"aria-hidden":!0}),t[24]=ge):ge=t[24];let k;t[25]===me?k=t[26]:(k=(0,B.jsx)(u,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":me,children:ge}),t[25]=me,t[26]=k);let A;t[27]!==O||t[28]!==k?(A=(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[O,k]}),t[27]=O,t[28]=k,t[29]=A):A=t[29];let j;t[30]!==E||t[31]!==D||t[32]!==A?(j=(0,B.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[E,D,A]}),t[30]=E,t[31]=D,t[32]=A,t[33]=j):j=t[33];let M;t[34]!==i||t[35]!==y?(M=()=>{y(null),i()},t[34]=i,t[35]=y,t[36]=M):M=t[36];let N;t[37]!==r||t[38]!==M||t[39]!==n?(N=(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,B.jsx)(Ke,{taskId:n,presentation:`modal`,backgroundPath:r,onDeleted:M})}),t[37]=r,t[38]=M,t[39]=n,t[40]=N):N=t[40];let P;t[41]!==j||t[42]!==N||t[43]!==T||t[44]!==le?(P=(0,B.jsxs)(f,{className:`task-detail-modal-content fixed top-1/2 z-[90] flex h-[min(54rem,calc(100dvh-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl bg-surface-base shadow-float focus:outline-none`,"data-workspace-panel-open":T,style:le,onEscapeKeyDown:Ye,onInteractOutside:W,children:[j,N]}),t[41]=j,t[42]=N,t[43]=T,t[44]=le,t[45]=P):P=t[45];let F;t[46]!==ne||t[47]!==h||t[48]!==g||t[49]!==_?(F=ne?(0,B.jsx)(`div`,{className:`fixed inset-y-0 left-0 z-[100] flex min-h-0 min-w-0 overflow-hidden bg-surface-panel transition-[right] duration-200 ease-out motion-reduce:transition-none`,style:{right:h?g:0},children:(0,B.jsx)(Ee,{allowOutsideChat:!0,sessionKey:_??void 0})}):null,t[46]=ne,t[47]=h,t[48]=g,t[49]=_,t[50]=F):F=t[50];let I;t[51]!==P||t[52]!==F||t[53]!==w?(I=(0,B.jsxs)(d,{children:[w,P,F]}),t[51]=P,t[52]=F,t[53]=w,t[54]=I):I=t[54];let _e;return t[55]!==S||t[56]!==I?(_e=(0,B.jsx)(m,{modal:!1,open:!0,onOpenChange:S,children:I}),t[55]=S,t[56]=I,t[57]=_e):_e=t[57],_e}function W(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function Ye(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function Xe(e){return e.setPath}function Ze(e){return e.path}function Qe(e){return e.setOpen}function G(e){return e.openForSession}function $e(e){return e.sessionKeyOverride}function et(e){return e.widthPx}function tt(e){return e.open}function K(e){return e.language}function nt(e){return(0,B.jsx)(g,{value:e.id,children:e.name||e.id},e.id)}function rt(e){return e.id}export{Je as TaskDetailModal,qe as TaskDetailPage};
|
|
@@ -1,2 +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{a as i,i as a,n as o,o as s,r as c,s as l,t as u}from"./dist-CpzYSoz7.js";import{t as d}from"./check-DUBLcKHA.js";import{n as f,r as p}from"./popover-select-CKBYnT3c.js";import{t as m}from"./loader-circle-CifKLtgG.js";import{t as h}from"./x-B_N4OPjy.js";import{n as g}from"./locale-store-DJPCr2mb.js";import{i as _}from"./vendor-swr-BIWyz7Rc.js";import{t as v}from"./button-CtTvuElV.js";import{t as y}from"./skeleton-BwbyijEw.js";import{$ as b,Ac as x,Au as S,Cl as C,Gc as w,Is as T,Kc as E,Ls as D,Q as O,Vl as ee,Wl as te,X as ne,Xl as re,Z as k,bu as ie,eo as ae,et as oe,ll as se,mu as A,nc as j,nt as ce,pc as le,pu as ue,tt as de,uu as M,vc as fe}from"./index-BWdn9NaX.js";import{t as pe}from"./page-tabs-DoxnT3X4.js";var N=n(),P=e(t(),1),F=r(),I={en:{pageTitle:`You`,pageSubtitle:`A living portrait shaped by you and xopc.`,overview:`Your portrait`,understanding:`Shared understanding`,knowledge:`Work memory`,portraitEyebrow:`YOU × XOPC`,portraitIntro:`Your explicit profile stays clear and editable. xopc builds a separate shared understanding through conversations and work.`,editProfile:`Edit basics`,callName:`What should xopc call you?`,callNamePlaceholder:`For example: Alex, Joyce, or Dr. Chen`,role:`Your role`,rolePlaceholder:`For example: founder, designer, or engineer`,pronouns:`Pronouns (optional)`,pronounsPlaceholder:`For example: she/her, he/him, they/them`,timezone:`Timezone`,locale:`Language / locale`,useDeviceTimezone:`Use this device`,notProvided:`Not provided`,editProfileHint:`These are facts you provide directly. They remain separate from xopc’s observations and inferences.`,saveProfile:`Save`,saving:`Saving…`,explicit:`You told me`,explicitHint:`Facts and preferences you stated directly`,learned:`Learned together`,learnedHint:`Patterns formed from our work`,pending:`To confirm together`,pendingHint:`Items that need your judgment`,confirmTogether:`Confirm together`,confirmHint:`These may affect future behavior. Confirm them, correct the wording, or tell me not to use them.`,nothingToConfirm:`Nothing needs your confirmation right now.`,importantNow:`What matters now`,noPriority:`No current priority has been set.`,otherGoals:`Other active outcomes`,howWeWork:`How we work together`,howWeWorkHint:`Your standing instructions for how I should communicate and act.`,noRules:`No collaboration preferences yet.`,recent:`Recently formed understanding`,recentHint:`The most useful current facts, with their origin and time horizon.`,seeAll:`See all`,workMemory:`What I remember from the work`,workMemoryHint:`Project facts, decisions, lessons, and open questions stay separate from facts about you.`,items:`items`,maintenanceReady:`Memory upkeep is enabled and waiting for its first run.`,maintenanceComplete:`Memory was last organized`,maintenanceFailed:`The latest memory upkeep needs attention`,refresh:`Refresh`,aboutYouTitle:`A view you can correct`,aboutYouHint:`This is working context, not a fixed profile. Every item can be corrected or retired.`,identity:`Who you are`,preferences:`Preferences and working rhythm`,relationships:`People and relationships`,currentState:`Current context`,insights:`My current read`,emptyGroup:`No understanding has formed here yet.`,correct:`Correct`,stopUsing:`Stop using`,confirm:`Confirm`,notTrue:`Not true`,save:`Save correction`,cancel:`Cancel`,correctionPlaceholder:`Write the accurate version…`,searchPlaceholder:`Search work memory…`,allMemory:`All work memory`,memoryLibraryHint:`Only distilled facts, decisions, lessons, commitments, and open questions appear here. Source records stay with their connector.`,noKnowledge:`No work memory has formed yet.`,noKnowledgeMatch:`No work memory matches this search.`,archive:`Archive`,showMore:`Show more`,expand:`Show details`,collapse:`Hide details`,disable:`Disable`,disabled:`Not in use`,enable:`Enable`,loadFailed:`Could not load your understanding.`,tryAgain:`Try again`,actionFailed:`The change could not be saved. Please try again.`},zh:{pageTitle:`你`,pageSubtitle:`一份由你和 xopc 共同塑造、持续生长的画像。`,overview:`你的画像`,understanding:`共同理解`,knowledge:`工作记忆`,portraitEyebrow:`YOU × XOPC`,portraitIntro:`你明确提供的基本信息会被清晰呈现并由你直接编辑;xopc 在对话与共事中形成的理解则单独维护。`,editProfile:`编辑基本信息`,callName:`希望 xopc 如何称呼你?`,callNamePlaceholder:`例如:Mic、Joyce、张老师`,role:`你的角色`,rolePlaceholder:`例如:创业者、产品设计师、工程师`,pronouns:`代词(可选)`,pronounsPlaceholder:`例如:she/her、he/him、they/them`,timezone:`时区`,locale:`语言 / 地区`,useDeviceTimezone:`使用本机时区`,notProvided:`未填写`,editProfileHint:`这些是由你直接提供的事实,与 xopc 的观察和推断分开维护。`,saveProfile:`保存`,saving:`正在保存…`,explicit:`你告诉我的`,explicitHint:`你明确表达的事实与偏好`,learned:`协作中学到的`,learnedHint:`从实际协作中形成的认识`,pending:`等待一起确认`,pendingHint:`需要由你判断的内容`,confirmTogether:`一起确认`,confirmHint:`这些理解可能影响之后的行为。你可以确认、修正,或告诉我以后不要使用。`,nothingToConfirm:`目前没有需要你确认的理解。`,importantNow:`此刻重要`,noPriority:`还没有设置当前优先事项。`,otherGoals:`其他进行中的目标`,howWeWork:`我们怎样协作`,howWeWorkHint:`你对沟通方式和执行行为的长期约定。`,noRules:`还没有形成协作偏好。`,recent:`最近形成的理解`,recentHint:`最值得使用的当前认识,同时说明它来自哪里、适用多久。`,seeAll:`查看全部`,workMemory:`我在工作中记住的`,workMemoryHint:`项目事实、决定、经验和待解问题,与“关于你”的理解分别管理。`,items:`条`,maintenanceReady:`记忆整理已经启用,正在等待首次运行。`,maintenanceComplete:`最近一次记忆整理于`,maintenanceFailed:`最近一次记忆整理需要处理`,refresh:`刷新`,aboutYouTitle:`一份可以共同修正的理解`,aboutYouHint:`它是协作中的工作认知,不是给你定型的档案。每一条都能修正或停止使用。`,identity:`关于你是谁`,preferences:`偏好与工作节奏`,relationships:`重要的人与关系`,currentState:`当前状态`,insights:`我形成的判断`,emptyGroup:`这里还没有形成理解。`,correct:`修正`,stopUsing:`不再使用`,confirm:`确认`,notTrue:`不是这样`,save:`保存修正`,cancel:`取消`,correctionPlaceholder:`写下更准确的说法…`,searchPlaceholder:`搜索工作记忆…`,allMemory:`全部工作记忆`,memoryLibraryHint:`这里只显示提炼后的事实、决定、经验、承诺和待解问题;邮件、日历与文档原文保留在对应来源中。`,noKnowledge:`还没有形成工作记忆。`,noKnowledgeMatch:`没有符合搜索条件的工作记忆。`,archive:`归档`,showMore:`显示更多`,expand:`查看详情`,collapse:`收起详情`,disable:`停用`,disabled:`已停用`,enable:`启用`,loadFailed:`无法载入对你的理解。`,tryAgain:`重试`,actionFailed:`修改没有保存,请重试。`}},L=[`candidate`,`needs_review`,`conflicted`,`stale`],me=new Set([`identity.call_name`,`identity.role`,`identity.pronouns`,`preference.timezone`,`preference.locale`]),he=[`project_fact`,`workspace_fact`,`decision`,`task_lesson`,`commitment`,`open_question`,`episode`,`note`];function R(e,t,n=!1){return e?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,...n?{timeStyle:`short`}:{}}).format(e):null}function z(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function ge(e){return{callName:z(e.profile.callName)??``,role:z(e.profile.role)??``,pronouns:z(e.profile.pronouns)??``,timezone:z(e.profile.timezone)??``,locale:z(e.profile.locale)??``}}function _e(e,t){return{"zh-CN":{en:`Simplified Chinese`,zh:`简体中文`},"zh-TW":{en:`Traditional Chinese`,zh:`繁体中文`},"en-US":{en:`English (US)`,zh:`英语(美国)`},"en-GB":{en:`English (UK)`,zh:`英语(英国)`},"ja-JP":{en:`Japanese`,zh:`日语`}}[e]?.[t]??e}function ve(e){return Array.from(e.trim()).slice(0,2).join(``).toLocaleUpperCase()}function B(e,t){return(t===`zh`?{user_explicit:`你告诉我的`,user_observed:`从协作中观察到`,system_inferred:`我形成的判断`,external_untrusted:`来自连接的信息`}:{user_explicit:`You told me`,user_observed:`Observed while working together`,system_inferred:`My current read`,external_untrusted:`From connected information`})[e.authority]}function V(e,t){if(e.validTo){let n=R(e.validTo,t);return t===`zh`?`适用至 ${n}`:`Applies until ${n}`}return(t===`zh`?{stable:`长期有效`,slow:`会随时间复核`,dynamic:`近期状态`,event:`特定阶段`}:{stable:`Long-term`,slow:`Reviewed over time`,dynamic:`Current context`,event:`Specific period`})[e.volatility]}function ye(e,t){let n=R(e,t);return t===`zh`?`当前安排至 ${n}`:`Current plan through ${n}`}function be(e,t){return e.authority===`user_explicit`?null:e.confidence>=.85?t===`zh`?`把握较高`:`High confidence`:e.confidence>=.65?t===`zh`?`把握中等`:`Medium confidence`:t===`zh`?`仍需确认`:`Needs confirmation`}function H(e,t){return(t===`zh`?{global:`所有协作`,agent:`当前智能体`,workspace:`当前工作区`,project:`当前项目`,session:`当前会话`}:{global:`All work`,agent:`This agent`,workspace:`This workspace`,project:`This project`,session:`This conversation`})[e.type]}function U(e,t){return(t===`zh`?{project_fact:`项目事实`,workspace_fact:`工作区事实`,decision:`已经决定`,task_lesson:`工作经验`,commitment:`承诺与约定`,open_question:`待解问题`,episode:`重要经历`,note:`其他记录`}:{project_fact:`Project facts`,workspace_fact:`Workspace facts`,decision:`Decisions`,task_lesson:`Lessons`,commitment:`Commitments`,open_question:`Open questions`,episode:`Episodes`,note:`Notes`})[e]}function xe(e,t,n){if(e)return e.targetType===`goal`?t.find(t=>t.id===e.targetId)?.title:/^[0-9a-f]{8}-[0-9a-f-]{20,}$/i.test(e.targetId)?(n===`zh`?{project:`当前项目`,task:`当前任务`,assertion:`一项待处理的理解`,topic:`当前主题`}:{project:`Current project`,task:`Current task`,assertion:`An understanding to address`,topic:`Current topic`})[e.targetType]:e.targetId}function W(e){let t=(0,N.c)(14),{title:n,hint:r,action:i,children:a,className:o}=e,s=`rounded-xl border border-edge bg-surface-panel shadow-surface ${o===void 0?``:o}`,c;t[0]===n?c=t[1]:(c=(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n}),t[0]=n,t[1]=c);let l;t[2]===r?l=t[3]:(l=r?(0,F.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-5 text-fg-muted`,children:r}):null,t[2]=r,t[3]=l);let u;t[4]!==c||t[5]!==l?(u=(0,F.jsxs)(`div`,{children:[c,l]}),t[4]=c,t[5]=l,t[6]=u):u=t[6];let d;t[7]!==i||t[8]!==u?(d=(0,F.jsxs)(`header`,{className:`flex items-start justify-between gap-4 border-b border-edge-subtle px-5 py-4`,children:[u,i]}),t[7]=i,t[8]=u,t[9]=d):d=t[9];let f;return t[10]!==a||t[11]!==s||t[12]!==d?(f=(0,F.jsxs)(`section`,{className:s,children:[d,a]}),t[10]=a,t[11]=s,t[12]=d,t[13]=f):f=t[13],f}function G(e){let t=(0,N.c)(7),{icon:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,F.jsx)(`span`,{className:`text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,F.jsx)(`p`,{children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,F.jsxs)(`div`,{className:`flex min-h-32 flex-col items-center justify-center gap-2 px-5 py-8 text-center text-sm text-fg-muted`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Se({open:e,profile:t,language:n,saving:r,onOpenChange:d,onSave:g}){let _=I[n],[y,b]=(0,P.useState)(t);(0,P.useEffect)(()=>{e&&b(t)},[e,t]);let x=e=>{e.preventDefault(),g({callName:y.callName.trim(),role:y.role.trim(),pronouns:y.pronouns.trim(),timezone:y.timezone.trim(),locale:y.locale.trim()})},S=(e,t,n)=>(0,F.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,F.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,F.jsx)(`input`,{value:y[e],onChange:t=>b(n=>({...n,[e]:t.target.value})),placeholder:n,className:`h-10 w-full rounded-xl border border-edge bg-surface-base px-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}),C=[`zh-CN`,`zh-TW`,`en-US`,`en-GB`,`ja-JP`];return y.locale&&!C.includes(y.locale)&&C.push(y.locale),(0,F.jsx)(u,{open:e,onOpenChange:d,children:(0,F.jsxs)(s,{children:[(0,F.jsx)(i,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,F.jsx)(c,{className:`fixed left-1/2 top-1/2 z-[90] h-[min(40rem,calc(100vh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:(0,F.jsxs)(`form`,{className:`flex h-full min-h-0 flex-col`,onSubmit:x,children:[(0,F.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4 sm:px-6`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(l,{className:`font-semibold text-fg`,children:_.editProfile}),(0,F.jsx)(a,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:_.editProfileHint})]}),(0,F.jsx)(o,{asChild:!0,children:(0,F.jsx)(v,{variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":_.cancel,children:(0,F.jsx)(h,{className:`size-4`})})})]}),(0,F.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5 sm:p-6`,children:(0,F.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[S(`callName`,_.callName,_.callNamePlaceholder),S(`role`,_.role,_.rolePlaceholder),S(`pronouns`,_.pronouns,_.pronounsPlaceholder),(0,F.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,F.jsx)(`span`,{className:`font-medium text-fg`,children:_.locale}),(0,F.jsxs)(f,{value:y.locale,onChange:e=>b(t=>({...t,locale:e.target.value})),children:[(0,F.jsx)(p,{value:``,children:_.notProvided}),C.map(e=>(0,F.jsx)(p,{value:e,children:_e(e,n)},e))]})]}),(0,F.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:col-span-2`,children:[(0,F.jsx)(`span`,{className:`font-medium text-fg`,children:_.timezone}),(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(`input`,{value:y.timezone,onChange:e=>b(t=>({...t,timezone:e.target.value})),placeholder:k(),className:`h-10 min-w-0 flex-1 rounded-xl border border-edge bg-surface-base px-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,F.jsx)(v,{className:`shrink-0 whitespace-nowrap`,onClick:()=>b(e=>({...e,timezone:k()})),children:_.useDeviceTimezone})]})]})]})}),(0,F.jsxs)(`footer`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-3 sm:px-6`,children:[(0,F.jsx)(o,{asChild:!0,children:(0,F.jsx)(v,{disabled:r,children:_.cancel})}),(0,F.jsxs)(v,{type:`submit`,variant:`primary`,disabled:r,children:[r?(0,F.jsx)(m,{className:`size-4 animate-spin`}):null,r?_.saving:_.saveProfile]})]})]})})]})})}function Ce(e){let t=(0,N.c)(28),{item:n,language:r,busy:i,editing:a,draft:o,onDraftChange:s,onEdit:c,onCancel:l,onAction:u,onCorrect:f}=e,p=I[r],m;t[0]===n.status?m=t[1]:(m=L.includes(n.status),t[0]=n.status,t[1]=m);let g=m,_;t[2]!==n||t[3]!==r?(_=be(n,r),t[2]=n,t[3]=r,t[4]=_):_=t[4];let y=_,b=`rounded-xl border p-4 ${g?`border-edge-strong bg-surface-base`:`border-edge bg-surface-panel`}`,C;t[5]!==i||t[6]!==y||t[7]!==o||t[8]!==a||t[9]!==n||t[10]!==r||t[11]!==g||t[12]!==u||t[13]!==l||t[14]!==f||t[15]!==s||t[16]!==c||t[17]!==p.cancel||t[18]!==p.confirm||t[19]!==p.correct||t[20]!==p.correctionPlaceholder||t[21]!==p.notTrue||t[22]!==p.save||t[23]!==p.stopUsing?(C=a?(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`label`,{className:`sr-only`,htmlFor:`assertion-${n.id}`,children:p.correctionPlaceholder}),(0,F.jsx)(`textarea`,{id:`assertion-${n.id}`,value:o,onChange:e=>s(e.target.value),placeholder:p.correctionPlaceholder,className:`min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm leading-6 text-fg outline-none transition focus:border-accent focus:ring-2 focus:ring-accent/20`,autoFocus:!0}),(0,F.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,F.jsx)(v,{variant:`ghost`,className:`h-8`,onClick:l,children:p.cancel}),(0,F.jsx)(v,{variant:`primary`,className:`h-8`,disabled:!o.trim()||i,onClick:f,children:p.save})]})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:n.statement}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1.5 text-xs text-fg-subtle`,children:[(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(w,{className:`size-3.5`}),B(n,r)]}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(re,{className:`size-3.5`}),V(n,r)]}),n.scope.type===`global`?null:(0,F.jsx)(`span`,{children:H(n.scope,r)}),y?(0,F.jsx)(`span`,{children:y}):null]}),(0,F.jsx)(`div`,{className:`mt-4 flex flex-wrap justify-end gap-1.5`,children:g?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(v,{variant:`secondary`,className:`h-8 gap-1.5 px-2.5`,disabled:i,onClick:()=>u(`active`),children:[(0,F.jsx)(d,{className:`size-3.5`}),p.confirm]}),(0,F.jsxs)(v,{variant:`ghost`,className:`h-8 gap-1.5 px-2.5`,disabled:i,onClick:c,children:[(0,F.jsx)(x,{className:`size-3.5`}),p.correct]}),(0,F.jsxs)(v,{variant:`ghost`,className:`h-8 gap-1.5 px-2.5`,disabled:i,onClick:()=>u(`rejected`),children:[(0,F.jsx)(h,{className:`size-3.5`}),p.notTrue]})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(v,{variant:`ghost`,className:`h-8 gap-1.5 px-2.5`,disabled:i,onClick:c,children:[(0,F.jsx)(x,{className:`size-3.5`}),p.correct]}),(0,F.jsxs)(v,{variant:`ghost`,className:`h-8 gap-1.5 px-2.5`,disabled:i,onClick:()=>u(`archived`),children:[(0,F.jsx)(S,{className:`size-3.5`}),p.stopUsing]})]})})]}),t[5]=i,t[6]=y,t[7]=o,t[8]=a,t[9]=n,t[10]=r,t[11]=g,t[12]=u,t[13]=l,t[14]=f,t[15]=s,t[16]=c,t[17]=p.cancel,t[18]=p.confirm,t[19]=p.correct,t[20]=p.correctionPlaceholder,t[21]=p.notTrue,t[22]=p.save,t[23]=p.stopUsing,t[24]=C):C=t[24];let T;return t[25]!==b||t[26]!==C?(T=(0,F.jsx)(`article`,{className:b,children:C}),t[25]=b,t[26]=C,t[27]=T):T=t[27],T}function we(e){let t=(0,N.c)(16),{rule:n,language:r,busy:i,onToggle:a}=e,o=I[r],s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,F.jsx)(C,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),t[0]=s):s=t[0];let c;t[1]===n.statement?c=t[2]:(c=(0,F.jsx)(`p`,{className:`min-w-0 flex-1 text-sm leading-6 text-fg`,children:n.statement}),t[1]=n.statement,t[2]=c);let l;t[3]!==n.status||t[4]!==o.disabled?(l=n.status===`disabled`?(0,F.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:o.disabled}):null,t[3]=n.status,t[4]=o.disabled,t[5]=l):l=t[5];let u=n.status===`active`?o.disable:o.enable,d;t[6]!==i||t[7]!==a||t[8]!==u?(d=(0,F.jsx)(v,{variant:`ghost`,className:`h-8`,disabled:i,onClick:a,children:u}),t[6]=i,t[7]=a,t[8]=u,t[9]=d):d=t[9];let f;t[10]!==l||t[11]!==d?(f=(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[l,d]}),t[10]=l,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==c||t[14]!==f?(p=(0,F.jsxs)(`div`,{className:`flex items-start gap-3 border-t border-edge-subtle px-5 py-3 first:border-t-0`,children:[s,c,f]}),t[13]=c,t[14]=f,t[15]=p):p=t[15],p}function Te(e){let t=(0,N.c)(39),{item:n,language:r,busy:i,expanded:a,onToggle:o,onArchive:s}=e,c=I[r],l=n.updatedAt??n.createdAt,u;t[0]!==r||t[1]!==l?(u=R(l,r),t[0]=r,t[1]=l,t[2]=u):u=t[2];let d=u,f;t[3]===n.content?f=t[4]:(f=n.content.length>96||n.content.includes(`
|
|
2
|
-
`),t[3]=n.content,t[4]=f);let p=f,m;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,F.jsx)(ie,{className:`mt-1 size-4 shrink-0 text-fg-subtle`}),t[5]=m):m=t[5];let h=`whitespace-pre-wrap text-sm leading-6 text-fg ${a?``:`line-clamp-2`}`,g;t[6]!==n.content||t[7]!==h?(g=(0,F.jsx)(`p`,{className:h,children:n.content}),t[6]=n.content,t[7]=h,t[8]=g):g=t[8];let _;t[9]!==n.scope||t[10]!==r?(_=H(n.scope,r),t[9]=n.scope,t[10]=r,t[11]=_):_=t[11];let y;t[12]===_?y=t[13]:(y=(0,F.jsx)(`span`,{children:_}),t[12]=_,t[13]=y);let b;t[14]===d?b=t[15]:(b=d?(0,F.jsx)(`span`,{children:d}):null,t[14]=d,t[15]=b);let x;t[16]!==y||t[17]!==b?(x=(0,F.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[y,b]}),t[16]=y,t[17]=b,t[18]=x):x=t[18];let C;t[19]!==x||t[20]!==g?(C=(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[g,x]}),t[19]=x,t[20]=g,t[21]=C):C=t[21];let w;t[22]!==p||t[23]!==a||t[24]!==o||t[25]!==c.collapse||t[26]!==c.expand?(w=p?(0,F.jsxs)(v,{variant:`ghost`,className:`h-8 gap-1 px-2`,onClick:o,children:[(0,F.jsx)(`span`,{className:`hidden sm:inline`,children:a?c.collapse:c.expand}),(0,F.jsx)(M,{className:`size-3.5 transition-transform ${a?`rotate-180`:``}`})]}):null,t[22]=p,t[23]=a,t[24]=o,t[25]=c.collapse,t[26]=c.expand,t[27]=w):w=t[27];let T;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,F.jsx)(S,{className:`size-3.5`}),t[28]=T):T=t[28];let E;t[29]!==i||t[30]!==s||t[31]!==c.archive?(E=(0,F.jsx)(v,{variant:`ghost`,className:`size-8 shrink-0 p-0`,disabled:i,onClick:s,"aria-label":c.archive,title:c.archive,children:T}),t[29]=i,t[30]=s,t[31]=c.archive,t[32]=E):E=t[32];let D;t[33]!==w||t[34]!==E?(D=(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[w,E]}),t[33]=w,t[34]=E,t[35]=D):D=t[35];let O;return t[36]!==C||t[37]!==D?(O=(0,F.jsx)(`article`,{className:`group border-t border-edge-subtle px-5 py-4 first:border-t-0 sm:px-6`,children:(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[m,C,D]})}),t[36]=C,t[37]=D,t[38]=O):O=t[38],O}function Ee(){let e=g(e=>e.language),t=I[e],n=ae(e=>e.setPageHeader),r=ae(e=>e.clearPageHeader),{data:i,error:a,isLoading:o,mutate:s}=_(`/api/user-model`,O),[c,l]=(0,P.useState)(`overview`),[u,f]=(0,P.useState)(),[p,m]=(0,P.useState)(),[x,S]=(0,P.useState)(),[k,M]=(0,P.useState)(``),[N,z]=(0,P.useState)(``),[B,V]=(0,P.useState)(24),[be,H]=(0,P.useState)(),[Ee,K]=(0,P.useState)(!1);(0,P.useEffect)(()=>(n({startExtra:null,main:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:t.pageTitle}),(0,F.jsx)(`p`,{className:`hidden text-xs text-fg-muted sm:block`,children:t.pageSubtitle})]}),end:null}),r),[r,n,t]);let q=async(e,n)=>{f(e),m(void 0);try{await n(),await s()}catch{m(t.actionFailed)}finally{f(void 0)}},De=(e,t)=>{q(e.id,()=>b(e.id,t))},Oe=e=>{q(e.id,async()=>{await ne(e.id,k.trim()),S(void 0),M(``)})},ke=async e=>{f(`profile`),m(void 0);try{await ce(e),await s(),K(!1)}catch{m(t.actionFailed)}finally{f(void 0)}};if(o)return(0,F.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl space-y-5 p-4 sm:p-6 lg:py-8`,children:[(0,F.jsx)(y,{className:`h-10 w-72 rounded-xl`}),(0,F.jsx)(y,{className:`h-72 rounded-xl`}),(0,F.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-2`,children:[(0,F.jsx)(y,{className:`h-80 rounded-xl`}),(0,F.jsx)(y,{className:`h-80 rounded-xl`})]})]});if(a||!i)return(0,F.jsxs)(`div`,{className:`mx-auto flex min-h-72 max-w-xl flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,F.jsx)(A,{className:`size-6 text-fg-subtle`}),(0,F.jsx)(`p`,{className:`text-sm text-danger`,children:t.loadFailed}),(0,F.jsx)(v,{onClick:()=>void s(),children:t.tryAgain})]});let J=[...i.assertions].sort((e,t)=>{let n=Number(L.includes(t.status))-Number(L.includes(e.status));if(n)return n;let r=e.declaredImportance??e.inferredImportance;return(t.declaredImportance??t.inferredImportance)-r||t.recordedAt-e.recordedAt}).filter(e=>!me.has(e.predicate)),Y=ge(i),Ae=Y.callName||(e===`zh`?`你`:`You`),je=J.filter(e=>L.includes(e.status)),Me=J.filter(e=>e.status===`active`),Ne=Me.filter(e=>e.authority===`user_explicit`).length,Pe=Me.length-Ne,Fe=i.priorities.filter(e=>e.status===`active`&&e.validTo>Date.now()),X=Fe.find(e=>e.rank===`primary`)??Fe[0],Ie=xe(X,i.goals,e),Le=X?.targetType===`goal`?i.goals.find(e=>e.id===X.targetId):void 0,Re=i.goals.filter(e=>e.status===`active`||e.status===`paused`).filter(e=>X?.targetType!==`goal`||e.id!==X.targetId),ze=i.rules.filter(e=>e.status!==`archived`),Be=[...Me].sort((e,t)=>t.recordedAt-e.recordedAt),Z=i.knowledge.filter(e=>e.status!==`archived`&&e.status!==`rejected`),Ve=N.trim().toLocaleLowerCase(),Q=Z.filter(t=>!Ve||t.content.toLocaleLowerCase().includes(Ve)||U(t.kind,e).toLocaleLowerCase().includes(Ve)),He=[{key:`identity`,title:t.identity,icon:T,items:J.filter(e=>e.kind===`identity`)},{key:`preferences`,title:t.preferences,icon:te,items:J.filter(e=>[`preference`,`value`,`routine`,`capability`].includes(e.kind))},{key:`relationships`,title:t.relationships,icon:C,items:J.filter(e=>e.kind===`relationship`)},{key:`current`,title:t.currentState,icon:re,items:J.filter(e=>e.kind===`current_state`)},{key:`insights`,title:t.insights,icon:j,items:J.filter(e=>e.kind===`derived_insight`)}].filter(e=>e.items.length>0),Ue=he.map(e=>({kind:e,count:Z.filter(t=>t.kind===e).length})).filter(e=>e.count>0),We=Q.slice(0,B),Ge=he.map(e=>({kind:e,items:We.filter(t=>t.kind===e),totalCount:Q.filter(t=>t.kind===e).length})).filter(e=>e.items.length>0),$=t=>(0,F.jsx)(Ce,{item:t,language:e,busy:u===t.id,editing:x===t.id,draft:x===t.id?k:``,onDraftChange:M,onEdit:()=>{S(t.id),M(t.statement)},onCancel:()=>{S(void 0),M(``)},onAction:e=>De(t,e),onCorrect:()=>Oe(t)},t.id),Ke=i.maintenance.lastRun?R(i.maintenance.lastRun.finishedAt??i.maintenance.lastRun.startedAt,e,!0):null,qe=i.maintenance.lastRun?i.maintenance.lastRun.status===`completed`?`${t.maintenanceComplete} ${Ke}`:t.maintenanceFailed:t.maintenanceReady;return(0,F.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl space-y-5 p-4 sm:p-6 lg:py-8`,children:[(0,F.jsx)(pe,{items:[{id:`overview`,label:t.overview,icon:j},{id:`understanding`,label:t.understanding,icon:T,count:J.length},{id:`knowledge`,label:t.knowledge,icon:ie,count:Z.length}],activeTab:c,onChange:l,ariaLabel:t.pageTitle,tabIdPrefix:`understanding-tab`,panelIdPrefix:`understanding-panel`}),p?(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl border border-danger bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,F.jsx)(`span`,{children:p}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>m(void 0),"aria-label":t.cancel,children:(0,F.jsx)(h,{className:`size-4`})})]}):null,c===`overview`?(0,F.jsxs)(`div`,{id:`understanding-panel-overview`,role:`tabpanel`,"aria-labelledby":`understanding-tab-overview`,className:`space-y-5`,children:[(0,F.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-surface`,children:[(0,F.jsxs)(`div`,{className:`grid gap-8 px-5 py-7 sm:px-8 sm:py-9 lg:grid-cols-[minmax(0,1fr)_21rem] lg:gap-10`,children:[(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold tracking-[0.16em] text-accent-fg`,children:[(0,F.jsx)(j,{className:`size-3.5`}),(0,F.jsx)(`span`,{children:t.portraitEyebrow})]}),(0,F.jsxs)(`div`,{className:`mt-6 flex items-center gap-4`,children:[(0,F.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl border border-edge bg-surface-active text-lg font-semibold text-fg sm:size-20 sm:text-xl`,children:ve(Ae)}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`h2`,{className:`truncate text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:Ae}),(0,F.jsx)(`p`,{className:`mt-1 truncate text-sm text-fg-muted`,children:Y.role||t.notProvided})]}),(0,F.jsxs)(v,{className:`shrink-0`,onClick:()=>K(!0),children:[(0,F.jsx)(D,{className:`size-4`}),t.editProfile]})]}),(0,F.jsx)(`p`,{className:`mt-6 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.portraitIntro}),(0,F.jsx)(`div`,{className:`mt-6 overflow-hidden rounded-xl border border-edge bg-edge-subtle`,children:(0,F.jsx)(`div`,{className:`grid gap-px sm:grid-cols-3`,children:[{icon:se,label:t.locale,value:Y.locale?_e(Y.locale,e):t.notProvided},{icon:E,label:t.timezone,value:Y.timezone||t.notProvided},{icon:T,label:t.pronouns,value:Y.pronouns||t.notProvided}].map(({icon:e,label:t,value:n})=>(0,F.jsxs)(`div`,{className:`bg-surface-panel px-4 py-3.5`,children:[(0,F.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-fg-subtle`,children:[(0,F.jsx)(e,{className:`size-3.5`}),t]}),(0,F.jsx)(`p`,{className:`mt-1.5 truncate text-sm font-medium text-fg`,children:n})]},t))})})]}),(0,F.jsxs)(`div`,{className:`flex min-h-52 flex-col rounded-xl border border-edge bg-surface-base p-5 sm:p-6`,children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold tracking-wide text-fg-subtle`,children:t.importantNow}),Ie?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`mt-4 text-xl font-semibold leading-7 tracking-tight text-fg`,children:Ie}),Le?.desiredOutcome?(0,F.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Le.desiredOutcome}):null,X?(0,F.jsx)(`p`,{className:`mt-4 text-xs text-fg-subtle`,children:ye(X.validTo,e)}):null]}):(0,F.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 py-6 text-center text-sm text-fg-muted`,children:[(0,F.jsx)(ue,{className:`size-5 text-fg-subtle`}),(0,F.jsx)(`span`,{children:t.noPriority})]}),Re.length?(0,F.jsxs)(`div`,{className:`mt-5 border-t border-edge pt-4`,children:[(0,F.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.otherGoals}),(0,F.jsx)(`div`,{className:`mt-2 space-y-2`,children:Re.slice(0,3).map(e=>(0,F.jsx)(`p`,{className:`text-sm text-fg`,children:e.title},e.id))})]}):null]})]}),(0,F.jsx)(`div`,{className:`grid border-t border-edge-subtle sm:grid-cols-3`,children:[{icon:w,label:t.explicit,hint:t.explicitHint,count:Ne},{icon:A,label:t.learned,hint:t.learnedHint,count:Pe},{icon:d,label:t.pending,hint:t.pendingHint,count:je.length}].map(({icon:e,label:t,hint:n,count:r},i)=>(0,F.jsxs)(`div`,{className:`flex gap-3 px-5 py-4 sm:px-6 ${i?`border-t border-edge-subtle sm:border-l sm:border-t-0`:``}`,children:[(0,F.jsx)(e,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`p`,{className:`text-sm font-medium text-fg`,children:[(0,F.jsx)(`span`,{className:`mr-1.5 text-lg tabular-nums`,children:r}),t]}),(0,F.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:n})]})]},t))})]}),je.length?(0,F.jsx)(W,{title:t.confirmTogether,hint:t.confirmHint,children:(0,F.jsx)(`div`,{className:`grid gap-3 p-4 lg:grid-cols-2`,children:je.map($)})}):null,(0,F.jsx)(W,{title:t.howWeWork,hint:t.howWeWorkHint,children:ze.length?ze.map(t=>(0,F.jsx)(we,{rule:t,language:e,busy:u===t.id,onToggle:()=>void q(t.id,()=>de(t.id,t.status===`active`?`disabled`:`active`))},t.id)):(0,F.jsx)(G,{icon:(0,F.jsx)(C,{className:`size-5`}),children:t.noRules})}),(0,F.jsx)(W,{title:t.recent,hint:t.recentHint,action:(0,F.jsx)(v,{variant:`ghost`,className:`h-8 shrink-0`,onClick:()=>l(`understanding`),children:t.seeAll}),children:Be.length?(0,F.jsx)(`div`,{className:`grid gap-3 p-4 lg:grid-cols-2`,children:Be.slice(0,6).map($)}):(0,F.jsx)(G,{icon:(0,F.jsx)(A,{className:`size-5`}),children:t.emptyGroup})}),(0,F.jsx)(W,{title:t.workMemory,hint:t.workMemoryHint,action:(0,F.jsx)(v,{variant:`ghost`,className:`h-8 shrink-0`,onClick:()=>l(`knowledge`),children:t.seeAll}),children:Ue.length?(0,F.jsx)(`div`,{className:`grid gap-px bg-edge-subtle sm:grid-cols-2 lg:grid-cols-4`,children:Ue.slice(0,4).map(({kind:t,count:n})=>(0,F.jsxs)(`div`,{className:`bg-surface-panel px-5 py-4`,children:[(0,F.jsx)(`p`,{className:`text-2xl font-semibold tabular-nums text-fg`,children:n}),(0,F.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:U(t,e)})]},t))}):(0,F.jsx)(G,{icon:(0,F.jsx)(ee,{className:`size-5`}),children:t.noKnowledge})}),(0,F.jsxs)(`footer`,{className:`flex items-center justify-between gap-4 px-1 pb-2 text-xs text-fg-subtle`,children:[(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,F.jsx)(fe,{className:`size-3.5`}),qe]}),(0,F.jsxs)(v,{variant:`ghost`,className:`h-8 gap-1.5 px-2.5`,onClick:()=>void s(),children:[(0,F.jsx)(fe,{className:`size-3.5`}),t.refresh]})]})]}):null,c===`understanding`?(0,F.jsxs)(`div`,{id:`understanding-panel-understanding`,role:`tabpanel`,"aria-labelledby":`understanding-tab-understanding`,className:`space-y-5`,children:[(0,F.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-5 py-5 shadow-surface sm:px-6`,children:(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(A,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`font-semibold text-fg`,children:t.aboutYouTitle}),(0,F.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:t.aboutYouHint})]})]})}),He.length?He.map(({key:e,title:t,icon:n,items:r})=>(0,F.jsx)(W,{title:t,action:(0,F.jsx)(n,{className:`size-4 text-fg-subtle`}),children:(0,F.jsx)(`div`,{className:`grid gap-3 p-4 lg:grid-cols-2`,children:r.map($)})},e)):(0,F.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-panel shadow-surface`,children:(0,F.jsx)(G,{icon:(0,F.jsx)(A,{className:`size-5`}),children:t.emptyGroup})})]}):null,c===`knowledge`?(0,F.jsxs)(`div`,{id:`understanding-panel-knowledge`,role:`tabpanel`,"aria-labelledby":`understanding-tab-knowledge`,className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-edge bg-surface-panel p-4 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,F.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,F.jsx)(`h2`,{className:`font-semibold text-fg`,children:t.allMemory}),(0,F.jsxs)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:[Z.length,` `,t.items,` · `,t.memoryLibraryHint]})]}),(0,F.jsxs)(`label`,{className:`relative block sm:w-80`,children:[(0,F.jsx)(le,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`}),(0,F.jsx)(`span`,{className:`sr-only`,children:t.searchPlaceholder}),(0,F.jsx)(`input`,{type:`search`,value:N,onChange:e=>{z(e.target.value),V(24)},placeholder:t.searchPlaceholder,className:`h-10 w-full rounded-xl border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]})]}),Q.length?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`space-y-4`,children:Ge.map(({kind:t,items:n,totalCount:r})=>(0,F.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-surface`,children:[(0,F.jsxs)(`header`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-3 sm:px-6`,children:[(0,F.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:U(t,e)}),(0,F.jsx)(`span`,{className:`text-xs tabular-nums text-fg-subtle`,children:r})]}),(0,F.jsx)(`div`,{children:n.map(t=>(0,F.jsx)(Te,{item:t,language:e,busy:u===t.id,expanded:be===t.id,onToggle:()=>H(e=>e===t.id?void 0:t.id),onArchive:()=>void q(t.id,()=>oe(t.id,`archived`))},t.id))})]},t))}),Q.length>B?(0,F.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,F.jsx)(v,{onClick:()=>V(e=>e+24),children:t.showMore})}):null]}):(0,F.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-panel shadow-surface`,children:(0,F.jsx)(G,{icon:(0,F.jsx)(le,{className:`size-5`}),children:N.trim()?t.noKnowledgeMatch:t.noKnowledge})})]}):null,(0,F.jsx)(Se,{open:Ee,profile:Y,language:e,saving:u===`profile`,onOpenChange:K,onSave:e=>void ke(e)})]})}export{Ee as UserModelPage};
|