@xopcai/xopc 0.0.151 → 0.0.152
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-BuO-OVfD.js → agent-avatar-dicebear-CXe2KDZj.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-Bpv3h31T.js → agents-BjLxhsVX.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-B6OU3Eol.js → app-management-settings-panel-DekP2_hC.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BaP4GFvN.js → appearance-settings-Cfd5YavF.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DZKNIMRg.js → apps-page-PS-uUoSk.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-CJX3zIh_.js → archive-plugin-DWglUgbp.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CI1ejk_l.js → attachment-load-BJdxo2Vn.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-CjmhICbv.js → automation-suggestion-card-B-TfxjJF.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BtZl3B8m.js → automations-page-CtNevo3y.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-CZ8nOXqK.js → binary-plugins-DwrYsL8l.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BoSfyS_j.js → block-editor-CIxjL5Kp.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-CL1UiPcb.js → browser-settings-page-QncZ-2vS.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-api-XzDKxPZ8.js → capability-presets-api-ChR2rMfo.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-Dc_uHYgl.js → capability-presets-settings-panel-_JBmJl5A.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-mALvXpJj.js → channels-settings-Bz3tyWpH.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-logo-BSjlInHT.js → connector-logo-KsRvub5G.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-Cm_E3mmI.js → connectors-page-_pT0aE0S.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DcJc91-C.js → desktop-pet-CRCERvWy.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CdeqTa3Q.js → desktop-pet-settings-vGrxshsU.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-Cp3fpm0k.js → directory-picker-path-field-BGPYrtx6.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-Bwj1O3zr.js → dreaming-settings-B5pzvNgs.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-D_1xpKbZ.js → extension-debug-page-BaCko1XU.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CqZNCj96.js → extension-page-TTXKCMtb.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-5MWbtQaQ.js → extension-settings-page-CEMb3uXY.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-Co_IaS34.js → gateway-config-api-Bf37OGhQ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-kmeWm2Pt.js → gateway-settings-cu-vyeNk.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-create-dialog-FoO-R4_U.js → goal-create-dialog-C-bL8rj8.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-detail-page-CkJq7N5g.js → goal-detail-page-p5zPrlTq.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-config-api-DrtsYjXz.js → goals-config-api-D2pEoiiO.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-page-DRAN-R64.js → goals-page-D-H2u2-J.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-settings-wq9TKhIZ.js → goals-settings-BVZaBqPa.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-B5zDoHbo.js → heartbeat-settings-B-AC_uwa.js} +1 -1
- package/dist/gateway/static/root/assets/{index-apLU0Hun.js → index-DSydVlxZ.js} +6 -6
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-3tC9iD21.js → keyboard-shortcuts-settings-w0yIP0UB.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CT-vDTLK.js → local-app-workbench-page-CTq0TIH4.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-B9ruF9GV.js → local-apps-page-srIyxJuy.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-Ca1X8X2P.js → logs-page-MQB6-NKt.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-CzuhSQAB.js → markdown-split-Du5yPuDb.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-a3R4y-EL.js → media-plugins-Cd1Rmw15.js} +1 -1
- package/dist/gateway/static/root/assets/{models-hub-panel-CbTlz9Of.js → models-hub-panel-BMg_Xqd9.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-BCxDy2dV.js → notes-page-DhfrFd89.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-workbench-z6sBX9B2.js → notes-workbench-CwJk-D7Y.js} +2 -2
- package/dist/gateway/static/root/assets/{page-tabs-CJfk6M78.js → page-tabs-HACawonJ.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-MFopTSgF.js → preview-open-alternatives-CjEZt_F5.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-DU29deIr.js → project-detail-page-Dut_micj.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-Ck3DLTlZ.js → projects-page-sTRlCEZ5.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-gLsLyAyi.js → remote-access-hub-Fx81YH7S.js} +1 -1
- package/dist/gateway/static/root/assets/{save-bar-controls-D0uhU3Z8.js → save-bar-controls-CbktHUqt.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-NGOH-7wV.js → schedule-field-BGx_Nb45.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-BJz5LoqG.js → schema-form-Cg-LJVvG.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-TmNoWpa_.js → sessions-page-DFnmyBpj.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BlWxQ6Ea.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-oDnUHnX_.js → settings-collapsible-section-yYK4O-5E.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-DND90dDt.js → settings-form-section-DPSA8tG8.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-CEJtaoQp.js → settings-loading-skeleton-ClHNJwRL.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-B1LJlRi9.js → settings-page-lPM7md10.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-CsrLuDsW.js → settings-page-layout-B_-VepeK.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-BPCJPHHY.js → setup-status-panel-hORJvGAQ.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-C1PwLh-p.js → share-preview-page-DyzplAEL.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-DCuqr7js.js → shares-settings-DO3IIgcC.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-kn1Vypcy.js → skill-reload-api-C9BqzDjZ.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-k6VIqTkK.js → skills-page-CvOIrcCJ.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-BEsrEkSx.js → system-settings-panel-eIyklo0K.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-dOypdlMf.js → typed-models-lib-BgOpEx3h.js} +1 -1
- package/dist/gateway/static/root/assets/{user-context-page-B9Y_Ciav.js → user-context-page-BG_1IrIJ.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-fields-editor-DGC38Lx7.js → user-profile-fields-editor-CfLUK6MT.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-DFkZ-tan.js → user-profile-settings-panel-BmzPREhJ.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-CEIYZihF.js → utils-DbFnvDPi.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-DK6gaQsA.js → voice-api-key-field-1xyza74n.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-DSJb9Kq7.js → work-discovery-page-Dhyk4LHJ.js} +1 -1
- package/dist/gateway/static/root/assets/{work-item-detail-page-DVavwV3D.js → work-item-detail-page-CxBRnWeQ.js} +1 -1
- package/dist/gateway/static/root/assets/{work-page-foJDp0nz.js → work-page-Btq3YeCH.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BYqZpFCC.js → workflow-run-setup-panel-8HLqUALq.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-DgO0WAzs.js → workflows-page-D48bPgLI.js} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/product-delivery.js +63 -0
- package/dist/src/agent/code-intelligence/tool-gating.d.ts +5 -0
- package/dist/src/agent/code-intelligence/tool-gating.js +6 -0
- package/dist/src/agent/tools/automation-tool.js +1 -1
- package/dist/src/agent/tools/factory.js +2 -1
- package/dist/src/agent/tools/goal-tool.js +1 -1
- package/dist/src/agent/tools/workflow-tool.js +1 -1
- package/dist/src/agent/tools/write.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/hono/routes/status.d.ts +8 -0
- package/dist/src/gateway/hono/routes/status.js +71 -1
- package/package.json +9 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CtPhh2m9.js +0 -1
package/dist/gateway/static/root/assets/{sessions-page-TmNoWpa_.js → sessions-page-DFnmyBpj.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-B0B40tpO.js";import{l as s,n as c,r as l,s as u}from"./locale-store-GfSwnwIZ.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{$o as f,Ca as p,Cc as m,Cs as h,Cu as ee,Fl as g,Fo as _,Fs as v,Il as y,Lc as b,Lo as te,Mt as x,No as ne,Nt as S,Po as C,Ro as re,Sa as w,Sl as T,Ss as E,Ta as D,Uc as O,Yo as k,Zo as A,_a as j,ac as M,ao as N,co as P,el as F,es as I,fs as L,ga as R,ha as z,jt as B,ma as V,pa as ie,ps as H,ql as ae,rl as U,so as W,tc as G,tl as oe,va as se,vs as ce,wa as K,wc as le,wu as ue,xa as de,ya as fe,ys as q,zo as pe}from"./index-apLU0Hun.js";import{n as J,t as Y}from"./settings-form-section-DND90dDt.js";import{t as X}from"./page-tabs-CJfk6M78.js";import{n as me,r as he}from"./segmented-styles-BL8oLBEp.js";var Z=e(t(),1),ge=n(),Q=r();function _e(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function ve(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ye(e){let t=(0,ge.c)(105),{session:n,variant:r,labels:i,sessionAgentId:o,sessionAgentAvatar:s,onOpen:c,onAction:l}=e,u;t[0]!==i.unnamedSession||t[1]!==n.name?(u=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=u):u=t[2];let d=u,f;t[3]===n.name?f=t[4]:(f=n.name?.trim(),t[3]=n.name,t[4]=f);let p=!!f,h=n.status===`archived`,_=n.status===`pinned`,y=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,te;t[5]===y?te=t[6]:(te=a(`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`,y),t[5]=y,t[6]=te);let x;t[7]===c?x=t[8]:(x=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=x);let ne=r===`list`&&`sm:py-3`,S;t[9]===ne?S=t[10]:(S=a(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,ne),t[9]=ne,t[10]=S);let C;t[11]===n.sourceChannel?C=t[12]:(C=(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]=C);let re;t[13]===_?re=t[14]:(re=_?(0,Q.jsx)(le,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=_,t[14]=re);let w;t[15]===n.updatedAt?w=t[16]:(w=_e(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 O;t[19]!==T||t[20]!==re?(O=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[re,T]}),t[19]=T,t[20]=re,t[21]=O):O=t[21];let k;t[22]!==O||t[23]!==S||t[24]!==C?(k=(0,Q.jsxs)(`div`,{className:S,children:[C,O]}),t[22]=O,t[23]=S,t[24]=C,t[25]=k):k=t[25];let A=r===`list`&&`sm:py-3`,j;t[26]===A?j=t[27]:(j=a(`min-w-0 flex-1 px-3 py-2`,A),t[26]=A,t[27]=j);let M=r===`list`&&`sm:items-start`,N;t[28]===M?N=t[29]:(N=a(`flex gap-3`,M),t[28]=M,t[29]=N);let P;t[30]!==s||t[31]!==o?(P=(0,Q.jsx)(D,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=s,t[31]=o,t[32]=P):P=t[32];let F;t[33]===d?F=t[34]:(F=(0,Q.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:d,children:d}),t[33]=d,t[34]=F);let I;t[35]!==n.key||t[36]!==p?(I=p?(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]=p,t[37]=I):I=t[37];let R;t[38]!==F||t[39]!==I?(R=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[F,I]}),t[38]=F,t[39]=I,t[40]=R):R=t[40];let z;t[41]!==N||t[42]!==P||t[43]!==R?(z=(0,Q.jsxs)(`div`,{className:N,children:[P,R]}),t[41]=N,t[42]=P,t[43]=R,t[44]=z):z=t[44];let B;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Q.jsx)(b,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=B):B=t[45];let V;t[46]===n.messageCount?V=t[47]:(V=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[B,n.messageCount]}),t[46]=n.messageCount,t[47]=V);let ie;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Q.jsx)(E,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=ie):ie=t[48];let H;t[49]===n.estimatedTokens?H=t[50]:(H=ve(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=H);let ae;t[51]===H?ae=t[52]:(ae=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[ie,H]}),t[51]=H,t[52]=ae);let U;t[53]!==V||t[54]!==ae?(U=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[V,ae]}),t[53]=V,t[54]=ae,t[55]=U):U=t[55];let W;t[56]===n.tags?W=t[57]:(W=n.tags.length>0?(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Se),n.tags.length>3?(0,Q.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=W);let G;t[58]!==j||t[59]!==z||t[60]!==U||t[61]!==W?(G=(0,Q.jsxs)(`div`,{className:j,children:[z,U,W]}),t[58]=j,t[59]=z,t[60]=U,t[61]=W,t[62]=G):G=t[62];let oe;t[63]===l?oe=t[64]:(oe=()=>l(`continue`),t[63]=l,t[64]=oe);let se;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsx)(b,{className:`size-4`,strokeWidth:1.75}),t[65]=se):se=t[65];let ce;t[66]!==i.continueChat||t[67]!==oe?(ce=(0,Q.jsx)(`button`,{type:`button`,className:L,title:i.continueChat,"aria-label":i.continueChat,onClick:oe,children:se}),t[66]=i.continueChat,t[67]=oe,t[68]=ce):ce=t[68];let K;t[69]!==h||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==l?(K=h?(0,Q.jsx)(`button`,{type:`button`,className:L,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Q.jsx)(ue,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:L,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Q.jsx)(ee,{className:`size-4`,strokeWidth:1.75})}),t[69]=h,t[70]=i.archive,t[71]=i.unarchive,t[72]=l,t[73]=K):K=t[73];let de;t[74]!==_||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==l?(de=_?(0,Q.jsx)(`button`,{type:`button`,className:L,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Q.jsx)(m,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:L,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Q.jsx)(le,{className:`size-4`,strokeWidth:1.75})}),t[74]=_,t[75]=i.pin,t[76]=i.unpin,t[77]=l,t[78]=de):de=t[78];let fe;t[79]===l?fe=t[80]:(fe=()=>l(`export`),t[79]=l,t[80]=fe);let q;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Q.jsx)(g,{className:`size-4`,strokeWidth:1.75}),t[81]=q):q=t[81];let pe;t[82]!==i.export||t[83]!==fe?(pe=(0,Q.jsx)(`button`,{type:`button`,className:L,title:i.export,"aria-label":i.export,onClick:fe,children:q}),t[82]=i.export,t[83]=fe,t[84]=pe):pe=t[84];let J;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(J=a(L,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=J):J=t[85];let Y;t[86]===l?Y=t[87]:(Y=()=>l(`delete`),t[86]=l,t[87]=Y);let X;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Q.jsx)(v,{className:`size-4`,strokeWidth:1.75}),t[88]=X):X=t[88];let me;t[89]!==i.delete||t[90]!==Y?(me=(0,Q.jsx)(`button`,{type:`button`,className:J,title:i.delete,"aria-label":i.delete,onClick:Y,children:X}),t[89]=i.delete,t[90]=Y,t[91]=me):me=t[91];let he;t[92]!==ce||t[93]!==K||t[94]!==de||t[95]!==pe||t[96]!==me?(he=(0,Q.jsxs)(`div`,{role:`group`,className:`flex flex-wrap items-center gap-0.5 border-t border-edge-subtle/80 bg-surface-hover/25 p-2 dark:border-edge-subtle`,onClick:xe,onKeyDown:be,children:[ce,K,de,pe,me]}),t[92]=ce,t[93]=K,t[94]=de,t[95]=pe,t[96]=me,t[97]=he):he=t[97];let Z;return t[98]!==c||t[99]!==k||t[100]!==G||t[101]!==te||t[102]!==he||t[103]!==x?(Z=(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,className:te,onClick:c,onKeyDown:x,children:[k,G,he]}),t[98]=c,t[99]=k,t[100]=G,t[101]=te,t[102]=he,t[103]=x,t[104]=Z):Z=t[104],Z}function be(e){return e.stopPropagation()}function xe(e){return e.stopPropagation()}function Se(e){return(0,Q.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ce(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function we(e){let t=$(e)?e:{},n=$(t.session)?t.session:{},r=$(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:Ce(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Te(e){await u(l(`/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 Ee(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,ce,`dark:border-edge`)}var De=B();function Oe({hasToken:e}){let t=o(c(e=>e.language)).sessions.config,{data:n,isLoading:r}=P(e),i=(0,Z.useMemo)(()=>n?.payload?.config===void 0?null:we(n.payload.config),[n]),[a,s]=(0,Z.useReducer)(De,{form:null,baseline:null}),l=a.form,u=a.baseline,[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),h=(0,Z.useRef)(!1),ee=(0,Z.useRef)(null);x({enabled:e,parsed:i,dirty:h.current,trackedParsedRef:ee,dispatch:s,onResetDirty:()=>{h.current=!1}});let g=l&&u&&JSON.stringify(l)!==JSON.stringify(u),_=(0,Z.useCallback)(e=>{h.current=!0,s({type:`patch`,patch:e})},[]);return!e||!l?r?(0,Q.jsx)(Y,{children:(0,Q.jsx)(O,{className:`size-4 animate-spin text-fg-muted`})}):null:(0,Q.jsxs)(Y,{children:[(0,Q.jsx)(J,{icon:y,title:t.title,subtitle:t.hint}),(0,Q.jsxs)(`div`,{className:`mb-4 flex justify-end gap-2`,children:[(0,Q.jsx)(q,{type:`button`,variant:`secondary`,disabled:!g||d,onClick:()=>s({type:`discard`}),children:t.discard}),(0,Q.jsx)(q,{type:`button`,variant:`primary`,disabled:!g||d,onClick:()=>{(async()=>{f(!0),m(null);try{await Te(l),h.current=!1,s({type:`saved`,value:l})}catch(e){m(e instanceof Error?e.message:t.saveError)}finally{f(!1)}})()},children:d?t.saving:t.save})]}),p?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:p}):null,(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Q.jsxs)(k,{className:Ee(),value:l.dmScope,onChange:e=>_({dmScope:e.target.value}),children:[(0,Q.jsx)(A,{value:`main`,children:t.dmScopeMain}),(0,Q.jsx)(A,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Q.jsx)(A,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Q.jsx)(A,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Q.jsx)(`input`,{type:`number`,min:0,className:Ee(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Q.jsx)(`input`,{type:`number`,min:1,className:Ee(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function ke(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function Ae(e){let t=(0,ge.c)(60),{open:n,loading:r,session:i,sessionAgentId:o,sessionAgentAvatar:s,labels:c,onClose:l,onArchive:u,onUnarchive:d,onPin:p,onUnpin:m,onExport:ee,onDelete:g}=e,v=i?.status===`archived`,y=i?.status===`pinned`,b;t[0]===l?b=t[1]:(b=e=>!e&&l(),t[0]=l,t[1]=b);let x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(te,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,I)}),t[2]=x):x=t[2];let S;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=a(`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`,f,`dark:border-edge`),t[3]=S):S=t[3];let w;t[4]!==i||t[5]!==s||t[6]!==o?(w=i&&o?(0,Q.jsx)(D,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=s,t[6]=o,t[7]=w):w=t[7];let T;t[8]!==c.unnamedSession||t[9]!==i?.name?(T=i?.name?.trim()||c.unnamedSession,t[8]=c.unnamedSession,t[9]=i?.name,t[10]=T):T=t[10];let E;t[11]===T?E=t[12]:(E=(0,Q.jsx)(pe,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:T}),t[11]=T,t[12]=E);let O;t[13]!==w||t[14]!==E?(O=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[w,E]}),t[13]=w,t[14]=E,t[15]=O):O=t[15];let k;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Q.jsx)(h,{className:`size-5`,strokeWidth:1.75}),t[16]=k):k=t[16];let A;t[17]===c.close?A=t[18]:(A=(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsx)(q,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":c.close,children:k})}),t[17]=c.close,t[18]=A);let j;t[19]!==O||t[20]!==A?(j=(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:[O,A]}),t[19]=O,t[20]=A,t[21]=j):j=t[21];let M;t[22]!==c.detailLoading||t[23]!==c.detailMessages||t[24]!==r||t[25]!==i?(M=r?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.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:c.detailMessages}),(0,Q.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(je)})]}):null,t[22]=c.detailLoading,t[23]=c.detailMessages,t[24]=r,t[25]=i,t[26]=M):M=t[26];let N;t[27]===M?N=t[28]:(N=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:M}),t[27]=M,t[28]=N);let P;t[29]!==c.detailExport||t[30]!==ee?(P=(0,Q.jsx)(q,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:ee,children:c.detailExport}),t[29]=c.detailExport,t[30]=ee,t[31]=P):P=t[31];let F;t[32]!==v||t[33]!==c.archive||t[34]!==c.unarchive||t[35]!==u||t[36]!==d?(F=v?(0,Q.jsx)(q,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:c.unarchive}):(0,Q.jsx)(q,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:c.archive}),t[32]=v,t[33]=c.archive,t[34]=c.unarchive,t[35]=u,t[36]=d,t[37]=F):F=t[37];let L;t[38]!==y||t[39]!==c.pin||t[40]!==c.unpin||t[41]!==p||t[42]!==m?(L=y?(0,Q.jsx)(q,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:c.unpin}):(0,Q.jsx)(q,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:c.pin}),t[38]=y,t[39]=c.pin,t[40]=c.unpin,t[41]=p,t[42]=m,t[43]=L):L=t[43];let R;t[44]!==c.delete||t[45]!==g?(R=(0,Q.jsx)(q,{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:g,children:c.delete}),t[44]=c.delete,t[45]=g,t[46]=R):R=t[46];let z;t[47]!==P||t[48]!==F||t[49]!==L||t[50]!==R?(z=(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:[P,F,L,R]})}),t[47]=P,t[48]=F,t[49]=L,t[50]=R,t[51]=z):z=t[51];let B;t[52]!==j||t[53]!==N||t[54]!==z?(B=(0,Q.jsxs)(re,{children:[x,(0,Q.jsxs)(_,{className:S,"aria-describedby":void 0,children:[j,N,z]})]}),t[52]=j,t[53]=N,t[54]=z,t[55]=B):B=t[55];let V;return t[56]!==n||t[57]!==b||t[58]!==B?(V=(0,Q.jsx)(ne,{open:n,onOpenChange:b,children:B}),t[56]=n,t[57]=b,t[58]=B,t[59]=V):V=t[59],V}function je(e){return(0,Q.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Q.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:ke(e.content)})]},`${e.timestamp??``}-${e.role}-${ke(e.content).slice(0,24)}`)}var Me=20;function Ne(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var Pe=new Set([`all`,`active`,`pinned`,`archived`]),Fe=new Set([`grid`,`list`]),Ie=[`sessions`,`settings`];function Le(e){return e&&Ie.includes(e)?e:`sessions`}function Re(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function ze(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function Be(e){let t=(0,ge.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Ie.map(e=>({id:e,label:Re(n,e),icon:e===`sessions`?U:G})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Q.jsx)(X,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function Ve(e){let t=(0,ge.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a===void 0?!1:a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mb-5`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:Re(n,r)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:ze(n,r)})]}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Q.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function He(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:Pe.has(t)?t:`all`,viewMode:Fe.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function Ue(){let e=o(c(e=>e.language)),t=e.sessions,n=s(e=>e.token),r=!!n,{data:l,mutate:u}=d(r?[`gateway-chat-agents`,n]:null,N,{revalidateOnFocus:!1}),m=l?.defaultId??`main`,h=l?.items??[],[g,v]=i(),y=Le(g.get(`tab`)),b=(0,Z.useCallback)(e=>{let t=new URLSearchParams(g);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),v(t,{replace:!0})},[g,v]),[x,C]=(0,Z.useReducer)(S,g,He),{searchInput:E,debouncedSearch:D,statusFilter:O,viewMode:k,channelFilter:A,sessions:P,loading:L,error:B,hasMore:W,stats:G,detailOpen:ce,detailLoading:ue,detailSession:J,confirmOpen:Y,confirmKey:X}=x;(0,Z.useEffect)(()=>{let e=setTimeout(()=>{let e=E.trim();D!==e&&C({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[E,D]);let ge=g.toString(),_e=(0,Z.useRef)(ge);if(_e.current!==ge){_e.current=ge;let e=g.get(`q`)??``,t=g.get(`status`),n=g.get(`view`),r=(g.get(`channel`)??``).trim(),i=Pe.has(t)?t:`all`,a=Fe.has(n)?n:`grid`,o=e.trim();C({type:`patch`,patch:{...E===e?{}:{searchInput:e},...D===o?{}:{debouncedSearch:o},...O===i?{}:{statusFilter:i},...k===a?{}:{viewMode:a},...A===r?{}:{channelFilter:r}}})}(0,Z.useEffect)(()=>{let e=new URLSearchParams(g),t=D.trim();t?e.set(`q`,t):e.delete(`q`),O===`all`?e.delete(`status`):e.set(`status`,O),k===`grid`?e.delete(`view`):e.set(`view`,k),A?e.set(`channel`,A):e.delete(`channel`),e.toString()!==g.toString()&&v(e,{replace:!0})},[D,g,v,O,k,A]),(0,Z.useEffect)(()=>{if(!r||y!==`sessions`)return;let e=!1;return(async()=>{C({type:`patch`,patch:{loading:!0,error:null}});try{let t=await se({limit:Me,offset:0,...D?{search:D}:{},...O===`all`?{}:{status:O},...A?{channel:A}:{}});if(e)return;C({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||C({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||C({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,y,D,O,A,t.loadError]),(0,Z.useEffect)(()=>{!r||y!==`sessions`||j().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,y]),(0,Z.useEffect)(()=>{if(!r||y!==`sessions`)return;let e=()=>void u();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,y,u]),(0,Z.useEffect)(()=>{if(!r||y!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||C({type:`patch`,patch:{sessions:P.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:J&&J.key===t.key?{...J,name:t.name}:J}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,y,P,J]);let ve=(0,Z.useCallback)(async()=>{if(!(!r||L||!W)){C({type:`patch`,patch:{loading:!0,error:null}});try{let e=await se({limit:Me,offset:P.length,...D?{search:D}:{},...O===`all`?{}:{status:O},...A?{channel:A}:{}});C({type:`patch`,patch:{sessions:[...P,...e.items],hasMore:e.hasMore}})}catch(e){C({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{C({type:`patch`,patch:{loading:!1}})}}},[r,L,W,P.length,D,O,A,t.loadError]),be=(0,Z.useCallback)((e,t)=>{C({type:`patch`,patch:{sessions:P.map(n=>n.key===e?{...n,status:t}:n),detailSession:J&&J.key===e?{...J,status:t}:J}})},[P,J]),xe=(0,Z.useCallback)(async e=>{C({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{C({type:`patch`,patch:{detailSession:await R(e)}})}catch{C({type:`patch`,patch:{detailOpen:!1}})}finally{C({type:`patch`,patch:{detailLoading:!1}})}},[]),Se=e=>{xe(e)},$=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){C({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await ie(e),be(e,`archived`);break;case`unarchive`:await de(e),be(e,`active`);break;case`pin`:await fe(e),be(e,`pinned`);break;case`unpin`:await w(e),be(e,`active`);break;case`export`:{let t=await z(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}j().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ce=async e=>{try{await V(e),C({type:`patch`,patch:{sessions:P.filter(t=>t.key!==e),detailSession:J?.key===e?null:J,...J?.key===e?{detailOpen:!1}:{}}}),j().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,unnamedSession:e.chat.newSession},Te={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},Ee=[{key:`all`,label:t.filterAll,icon:U},{key:`active`,label:t.filterActive,icon:ae},{key:`pinned`,label:t.filterPinned,icon:le},{key:`archived`,label:t.filterArchived,icon:ee}],De=(()=>{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)(Be,{s:t,activeTab:y,onChange:b}),(0,Q.jsx)(Ve,{s:t,id:`settings`,activeTab:y,plain:!0,children:(0,Q.jsx)(Oe,{hasToken:r})}),(0,Q.jsxs)(Ve,{s:t,id:`sessions`,activeTab:y,plain:!0,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Ee.map(({key:e,label:t,icon:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":O===e,onClick:()=>C({type:`patch`,patch:{statusFilter:e}}),className:a(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,H.transition,H.focusRingPanel,O===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)(M,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,value:E,onChange:e=>C({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":D||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":!A,onClick:()=>C({type:`patch`,patch:{channelFilter:``}}),className:a(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,H.transition,H.focusRingPanel,A?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),De.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":A===e,onClick:()=>C({type:`patch`,patch:{channelFilter:e}}),className:a(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,H.transition,H.focusRingPanel,A===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:Ne(t.sessionCount,{count:P.length})}),(0,Q.jsxs)(`div`,{className:he,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Q.jsx)(q,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":k===`grid`,onClick:()=>C({type:`patch`,patch:{viewMode:`grid`}}),className:a(me,`size-7 p-0`,k===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,k===`grid`&&`text-accent-fg`),children:(0,Q.jsx)(oe,{className:`size-3.5`,strokeWidth:1.5})}),(0,Q.jsx)(q,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":k===`list`,onClick:()=>C({type:`patch`,patch:{viewMode:`list`}}),className:a(me,`size-9 p-0`,k===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,k===`list`&&`text-accent-fg`),children:(0,Q.jsx)(F,{className:`size-3.5`,strokeWidth:1.5})})]})]}),L&&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)(T,{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)(q,{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:a(`grid min-w-0 gap-3`,k===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":D||void 0,children:P.map(e=>{let t=K(e,m);return(0,Q.jsx)(ye,{session:e,variant:k,labels:we,sessionAgentId:t,sessionAgentAvatar:p(t,h),onOpen:()=>Se(e.key),onAction:t=>void $(e.key,t)},e.key)})}),W?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(q,{type:`button`,variant:`secondary`,disabled:L,onClick:()=>void ve(),children:t.loadMore})}):null]})]})]}),(0,Q.jsx)(Ae,{open:ce,loading:ue,session:J,sessionAgentId:J?K(J,m):void 0,sessionAgentAvatar:J?p(K(J,m),h):void 0,labels:Te,onClose:()=>{C({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>J&&void $(J.key,`archive`),onUnarchive:()=>J&&void $(J.key,`unarchive`),onPin:()=>J&&void $(J.key,`pin`),onUnpin:()=>J&&void $(J.key,`unpin`),onExport:()=>J&&void $(J.key,`export`),onDelete:()=>J&&C({type:`patch`,patch:{confirmKey:J.key,confirmOpen:!0}})}),(0,Q.jsx)(ne,{open:Y,onOpenChange:e=>C({type:`patch`,patch:{confirmOpen:e}}),children:(0,Q.jsxs)(re,{children:[(0,Q.jsx)(te,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,I)}),(0,Q.jsxs)(_,{className:a(`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`,f),children:[(0,Q.jsx)(pe,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:X?Ne(t.deleteSessionMessage,{name:P.find(e=>e.key===X)?.name?.trim()||e.chat.newSession}):``}),(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>C({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Q.jsx)(q,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{X&&Ce(X),C({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Q.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{Ue as SessionsPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-B0B40tpO.js";import{l as s,n as c,r as l,s as u}from"./locale-store-GfSwnwIZ.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{$o as f,Ca as p,Cc as m,Cs as h,Cu as ee,Fl as g,Fo as _,Fs as v,Il as y,Lc as b,Lo as te,Mt as x,No as ne,Nt as S,Po as C,Ro as re,Sa as w,Sl as T,Ss as E,Ta as D,Uc as O,Yo as k,Zo as A,_a as j,ac as M,ao as N,co as P,el as F,es as I,fs as L,ga as R,ha as z,jt as B,ma as V,pa as ie,ps as H,ql as ae,rl as U,so as W,tc as G,tl as oe,va as se,vs as ce,wa as K,wc as le,wu as ue,xa as de,ya as fe,ys as q,zo as pe}from"./index-DSydVlxZ.js";import{n as J,t as Y}from"./settings-form-section-DPSA8tG8.js";import{t as X}from"./page-tabs-HACawonJ.js";import{n as me,r as he}from"./segmented-styles-BL8oLBEp.js";var Z=e(t(),1),ge=n(),Q=r();function _e(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function ve(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ye(e){let t=(0,ge.c)(105),{session:n,variant:r,labels:i,sessionAgentId:o,sessionAgentAvatar:s,onOpen:c,onAction:l}=e,u;t[0]!==i.unnamedSession||t[1]!==n.name?(u=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=u):u=t[2];let d=u,f;t[3]===n.name?f=t[4]:(f=n.name?.trim(),t[3]=n.name,t[4]=f);let p=!!f,h=n.status===`archived`,_=n.status===`pinned`,y=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,te;t[5]===y?te=t[6]:(te=a(`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`,y),t[5]=y,t[6]=te);let x;t[7]===c?x=t[8]:(x=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=x);let ne=r===`list`&&`sm:py-3`,S;t[9]===ne?S=t[10]:(S=a(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,ne),t[9]=ne,t[10]=S);let C;t[11]===n.sourceChannel?C=t[12]:(C=(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]=C);let re;t[13]===_?re=t[14]:(re=_?(0,Q.jsx)(le,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=_,t[14]=re);let w;t[15]===n.updatedAt?w=t[16]:(w=_e(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 O;t[19]!==T||t[20]!==re?(O=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[re,T]}),t[19]=T,t[20]=re,t[21]=O):O=t[21];let k;t[22]!==O||t[23]!==S||t[24]!==C?(k=(0,Q.jsxs)(`div`,{className:S,children:[C,O]}),t[22]=O,t[23]=S,t[24]=C,t[25]=k):k=t[25];let A=r===`list`&&`sm:py-3`,j;t[26]===A?j=t[27]:(j=a(`min-w-0 flex-1 px-3 py-2`,A),t[26]=A,t[27]=j);let M=r===`list`&&`sm:items-start`,N;t[28]===M?N=t[29]:(N=a(`flex gap-3`,M),t[28]=M,t[29]=N);let P;t[30]!==s||t[31]!==o?(P=(0,Q.jsx)(D,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=s,t[31]=o,t[32]=P):P=t[32];let F;t[33]===d?F=t[34]:(F=(0,Q.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:d,children:d}),t[33]=d,t[34]=F);let I;t[35]!==n.key||t[36]!==p?(I=p?(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]=p,t[37]=I):I=t[37];let R;t[38]!==F||t[39]!==I?(R=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[F,I]}),t[38]=F,t[39]=I,t[40]=R):R=t[40];let z;t[41]!==N||t[42]!==P||t[43]!==R?(z=(0,Q.jsxs)(`div`,{className:N,children:[P,R]}),t[41]=N,t[42]=P,t[43]=R,t[44]=z):z=t[44];let B;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Q.jsx)(b,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=B):B=t[45];let V;t[46]===n.messageCount?V=t[47]:(V=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[B,n.messageCount]}),t[46]=n.messageCount,t[47]=V);let ie;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Q.jsx)(E,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=ie):ie=t[48];let H;t[49]===n.estimatedTokens?H=t[50]:(H=ve(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=H);let ae;t[51]===H?ae=t[52]:(ae=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[ie,H]}),t[51]=H,t[52]=ae);let U;t[53]!==V||t[54]!==ae?(U=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[V,ae]}),t[53]=V,t[54]=ae,t[55]=U):U=t[55];let W;t[56]===n.tags?W=t[57]:(W=n.tags.length>0?(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Se),n.tags.length>3?(0,Q.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=W);let G;t[58]!==j||t[59]!==z||t[60]!==U||t[61]!==W?(G=(0,Q.jsxs)(`div`,{className:j,children:[z,U,W]}),t[58]=j,t[59]=z,t[60]=U,t[61]=W,t[62]=G):G=t[62];let oe;t[63]===l?oe=t[64]:(oe=()=>l(`continue`),t[63]=l,t[64]=oe);let se;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsx)(b,{className:`size-4`,strokeWidth:1.75}),t[65]=se):se=t[65];let ce;t[66]!==i.continueChat||t[67]!==oe?(ce=(0,Q.jsx)(`button`,{type:`button`,className:L,title:i.continueChat,"aria-label":i.continueChat,onClick:oe,children:se}),t[66]=i.continueChat,t[67]=oe,t[68]=ce):ce=t[68];let K;t[69]!==h||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==l?(K=h?(0,Q.jsx)(`button`,{type:`button`,className:L,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Q.jsx)(ue,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:L,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Q.jsx)(ee,{className:`size-4`,strokeWidth:1.75})}),t[69]=h,t[70]=i.archive,t[71]=i.unarchive,t[72]=l,t[73]=K):K=t[73];let de;t[74]!==_||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==l?(de=_?(0,Q.jsx)(`button`,{type:`button`,className:L,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Q.jsx)(m,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:L,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Q.jsx)(le,{className:`size-4`,strokeWidth:1.75})}),t[74]=_,t[75]=i.pin,t[76]=i.unpin,t[77]=l,t[78]=de):de=t[78];let fe;t[79]===l?fe=t[80]:(fe=()=>l(`export`),t[79]=l,t[80]=fe);let q;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Q.jsx)(g,{className:`size-4`,strokeWidth:1.75}),t[81]=q):q=t[81];let pe;t[82]!==i.export||t[83]!==fe?(pe=(0,Q.jsx)(`button`,{type:`button`,className:L,title:i.export,"aria-label":i.export,onClick:fe,children:q}),t[82]=i.export,t[83]=fe,t[84]=pe):pe=t[84];let J;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(J=a(L,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=J):J=t[85];let Y;t[86]===l?Y=t[87]:(Y=()=>l(`delete`),t[86]=l,t[87]=Y);let X;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Q.jsx)(v,{className:`size-4`,strokeWidth:1.75}),t[88]=X):X=t[88];let me;t[89]!==i.delete||t[90]!==Y?(me=(0,Q.jsx)(`button`,{type:`button`,className:J,title:i.delete,"aria-label":i.delete,onClick:Y,children:X}),t[89]=i.delete,t[90]=Y,t[91]=me):me=t[91];let he;t[92]!==ce||t[93]!==K||t[94]!==de||t[95]!==pe||t[96]!==me?(he=(0,Q.jsxs)(`div`,{role:`group`,className:`flex flex-wrap items-center gap-0.5 border-t border-edge-subtle/80 bg-surface-hover/25 p-2 dark:border-edge-subtle`,onClick:xe,onKeyDown:be,children:[ce,K,de,pe,me]}),t[92]=ce,t[93]=K,t[94]=de,t[95]=pe,t[96]=me,t[97]=he):he=t[97];let Z;return t[98]!==c||t[99]!==k||t[100]!==G||t[101]!==te||t[102]!==he||t[103]!==x?(Z=(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,className:te,onClick:c,onKeyDown:x,children:[k,G,he]}),t[98]=c,t[99]=k,t[100]=G,t[101]=te,t[102]=he,t[103]=x,t[104]=Z):Z=t[104],Z}function be(e){return e.stopPropagation()}function xe(e){return e.stopPropagation()}function Se(e){return(0,Q.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ce(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function we(e){let t=$(e)?e:{},n=$(t.session)?t.session:{},r=$(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:Ce(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Te(e){await u(l(`/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 Ee(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,ce,`dark:border-edge`)}var De=B();function Oe({hasToken:e}){let t=o(c(e=>e.language)).sessions.config,{data:n,isLoading:r}=P(e),i=(0,Z.useMemo)(()=>n?.payload?.config===void 0?null:we(n.payload.config),[n]),[a,s]=(0,Z.useReducer)(De,{form:null,baseline:null}),l=a.form,u=a.baseline,[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),h=(0,Z.useRef)(!1),ee=(0,Z.useRef)(null);x({enabled:e,parsed:i,dirty:h.current,trackedParsedRef:ee,dispatch:s,onResetDirty:()=>{h.current=!1}});let g=l&&u&&JSON.stringify(l)!==JSON.stringify(u),_=(0,Z.useCallback)(e=>{h.current=!0,s({type:`patch`,patch:e})},[]);return!e||!l?r?(0,Q.jsx)(Y,{children:(0,Q.jsx)(O,{className:`size-4 animate-spin text-fg-muted`})}):null:(0,Q.jsxs)(Y,{children:[(0,Q.jsx)(J,{icon:y,title:t.title,subtitle:t.hint}),(0,Q.jsxs)(`div`,{className:`mb-4 flex justify-end gap-2`,children:[(0,Q.jsx)(q,{type:`button`,variant:`secondary`,disabled:!g||d,onClick:()=>s({type:`discard`}),children:t.discard}),(0,Q.jsx)(q,{type:`button`,variant:`primary`,disabled:!g||d,onClick:()=>{(async()=>{f(!0),m(null);try{await Te(l),h.current=!1,s({type:`saved`,value:l})}catch(e){m(e instanceof Error?e.message:t.saveError)}finally{f(!1)}})()},children:d?t.saving:t.save})]}),p?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:p}):null,(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Q.jsxs)(k,{className:Ee(),value:l.dmScope,onChange:e=>_({dmScope:e.target.value}),children:[(0,Q.jsx)(A,{value:`main`,children:t.dmScopeMain}),(0,Q.jsx)(A,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Q.jsx)(A,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Q.jsx)(A,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Q.jsx)(`input`,{type:`number`,min:0,className:Ee(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Q.jsx)(`input`,{type:`number`,min:1,className:Ee(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function ke(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function Ae(e){let t=(0,ge.c)(60),{open:n,loading:r,session:i,sessionAgentId:o,sessionAgentAvatar:s,labels:c,onClose:l,onArchive:u,onUnarchive:d,onPin:p,onUnpin:m,onExport:ee,onDelete:g}=e,v=i?.status===`archived`,y=i?.status===`pinned`,b;t[0]===l?b=t[1]:(b=e=>!e&&l(),t[0]=l,t[1]=b);let x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(te,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,I)}),t[2]=x):x=t[2];let S;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=a(`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`,f,`dark:border-edge`),t[3]=S):S=t[3];let w;t[4]!==i||t[5]!==s||t[6]!==o?(w=i&&o?(0,Q.jsx)(D,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=s,t[6]=o,t[7]=w):w=t[7];let T;t[8]!==c.unnamedSession||t[9]!==i?.name?(T=i?.name?.trim()||c.unnamedSession,t[8]=c.unnamedSession,t[9]=i?.name,t[10]=T):T=t[10];let E;t[11]===T?E=t[12]:(E=(0,Q.jsx)(pe,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:T}),t[11]=T,t[12]=E);let O;t[13]!==w||t[14]!==E?(O=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[w,E]}),t[13]=w,t[14]=E,t[15]=O):O=t[15];let k;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Q.jsx)(h,{className:`size-5`,strokeWidth:1.75}),t[16]=k):k=t[16];let A;t[17]===c.close?A=t[18]:(A=(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsx)(q,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":c.close,children:k})}),t[17]=c.close,t[18]=A);let j;t[19]!==O||t[20]!==A?(j=(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:[O,A]}),t[19]=O,t[20]=A,t[21]=j):j=t[21];let M;t[22]!==c.detailLoading||t[23]!==c.detailMessages||t[24]!==r||t[25]!==i?(M=r?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.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:c.detailMessages}),(0,Q.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(je)})]}):null,t[22]=c.detailLoading,t[23]=c.detailMessages,t[24]=r,t[25]=i,t[26]=M):M=t[26];let N;t[27]===M?N=t[28]:(N=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:M}),t[27]=M,t[28]=N);let P;t[29]!==c.detailExport||t[30]!==ee?(P=(0,Q.jsx)(q,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:ee,children:c.detailExport}),t[29]=c.detailExport,t[30]=ee,t[31]=P):P=t[31];let F;t[32]!==v||t[33]!==c.archive||t[34]!==c.unarchive||t[35]!==u||t[36]!==d?(F=v?(0,Q.jsx)(q,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:c.unarchive}):(0,Q.jsx)(q,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:c.archive}),t[32]=v,t[33]=c.archive,t[34]=c.unarchive,t[35]=u,t[36]=d,t[37]=F):F=t[37];let L;t[38]!==y||t[39]!==c.pin||t[40]!==c.unpin||t[41]!==p||t[42]!==m?(L=y?(0,Q.jsx)(q,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:c.unpin}):(0,Q.jsx)(q,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:c.pin}),t[38]=y,t[39]=c.pin,t[40]=c.unpin,t[41]=p,t[42]=m,t[43]=L):L=t[43];let R;t[44]!==c.delete||t[45]!==g?(R=(0,Q.jsx)(q,{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:g,children:c.delete}),t[44]=c.delete,t[45]=g,t[46]=R):R=t[46];let z;t[47]!==P||t[48]!==F||t[49]!==L||t[50]!==R?(z=(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:[P,F,L,R]})}),t[47]=P,t[48]=F,t[49]=L,t[50]=R,t[51]=z):z=t[51];let B;t[52]!==j||t[53]!==N||t[54]!==z?(B=(0,Q.jsxs)(re,{children:[x,(0,Q.jsxs)(_,{className:S,"aria-describedby":void 0,children:[j,N,z]})]}),t[52]=j,t[53]=N,t[54]=z,t[55]=B):B=t[55];let V;return t[56]!==n||t[57]!==b||t[58]!==B?(V=(0,Q.jsx)(ne,{open:n,onOpenChange:b,children:B}),t[56]=n,t[57]=b,t[58]=B,t[59]=V):V=t[59],V}function je(e){return(0,Q.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Q.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:ke(e.content)})]},`${e.timestamp??``}-${e.role}-${ke(e.content).slice(0,24)}`)}var Me=20;function Ne(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var Pe=new Set([`all`,`active`,`pinned`,`archived`]),Fe=new Set([`grid`,`list`]),Ie=[`sessions`,`settings`];function Le(e){return e&&Ie.includes(e)?e:`sessions`}function Re(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function ze(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function Be(e){let t=(0,ge.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Ie.map(e=>({id:e,label:Re(n,e),icon:e===`sessions`?U:G})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Q.jsx)(X,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function Ve(e){let t=(0,ge.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a===void 0?!1:a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mb-5`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:Re(n,r)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:ze(n,r)})]}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Q.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function He(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:Pe.has(t)?t:`all`,viewMode:Fe.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function Ue(){let e=o(c(e=>e.language)),t=e.sessions,n=s(e=>e.token),r=!!n,{data:l,mutate:u}=d(r?[`gateway-chat-agents`,n]:null,N,{revalidateOnFocus:!1}),m=l?.defaultId??`main`,h=l?.items??[],[g,v]=i(),y=Le(g.get(`tab`)),b=(0,Z.useCallback)(e=>{let t=new URLSearchParams(g);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),v(t,{replace:!0})},[g,v]),[x,C]=(0,Z.useReducer)(S,g,He),{searchInput:E,debouncedSearch:D,statusFilter:O,viewMode:k,channelFilter:A,sessions:P,loading:L,error:B,hasMore:W,stats:G,detailOpen:ce,detailLoading:ue,detailSession:J,confirmOpen:Y,confirmKey:X}=x;(0,Z.useEffect)(()=>{let e=setTimeout(()=>{let e=E.trim();D!==e&&C({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[E,D]);let ge=g.toString(),_e=(0,Z.useRef)(ge);if(_e.current!==ge){_e.current=ge;let e=g.get(`q`)??``,t=g.get(`status`),n=g.get(`view`),r=(g.get(`channel`)??``).trim(),i=Pe.has(t)?t:`all`,a=Fe.has(n)?n:`grid`,o=e.trim();C({type:`patch`,patch:{...E===e?{}:{searchInput:e},...D===o?{}:{debouncedSearch:o},...O===i?{}:{statusFilter:i},...k===a?{}:{viewMode:a},...A===r?{}:{channelFilter:r}}})}(0,Z.useEffect)(()=>{let e=new URLSearchParams(g),t=D.trim();t?e.set(`q`,t):e.delete(`q`),O===`all`?e.delete(`status`):e.set(`status`,O),k===`grid`?e.delete(`view`):e.set(`view`,k),A?e.set(`channel`,A):e.delete(`channel`),e.toString()!==g.toString()&&v(e,{replace:!0})},[D,g,v,O,k,A]),(0,Z.useEffect)(()=>{if(!r||y!==`sessions`)return;let e=!1;return(async()=>{C({type:`patch`,patch:{loading:!0,error:null}});try{let t=await se({limit:Me,offset:0,...D?{search:D}:{},...O===`all`?{}:{status:O},...A?{channel:A}:{}});if(e)return;C({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||C({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||C({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,y,D,O,A,t.loadError]),(0,Z.useEffect)(()=>{!r||y!==`sessions`||j().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,y]),(0,Z.useEffect)(()=>{if(!r||y!==`sessions`)return;let e=()=>void u();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,y,u]),(0,Z.useEffect)(()=>{if(!r||y!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||C({type:`patch`,patch:{sessions:P.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:J&&J.key===t.key?{...J,name:t.name}:J}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,y,P,J]);let ve=(0,Z.useCallback)(async()=>{if(!(!r||L||!W)){C({type:`patch`,patch:{loading:!0,error:null}});try{let e=await se({limit:Me,offset:P.length,...D?{search:D}:{},...O===`all`?{}:{status:O},...A?{channel:A}:{}});C({type:`patch`,patch:{sessions:[...P,...e.items],hasMore:e.hasMore}})}catch(e){C({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{C({type:`patch`,patch:{loading:!1}})}}},[r,L,W,P.length,D,O,A,t.loadError]),be=(0,Z.useCallback)((e,t)=>{C({type:`patch`,patch:{sessions:P.map(n=>n.key===e?{...n,status:t}:n),detailSession:J&&J.key===e?{...J,status:t}:J}})},[P,J]),xe=(0,Z.useCallback)(async e=>{C({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{C({type:`patch`,patch:{detailSession:await R(e)}})}catch{C({type:`patch`,patch:{detailOpen:!1}})}finally{C({type:`patch`,patch:{detailLoading:!1}})}},[]),Se=e=>{xe(e)},$=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){C({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await ie(e),be(e,`archived`);break;case`unarchive`:await de(e),be(e,`active`);break;case`pin`:await fe(e),be(e,`pinned`);break;case`unpin`:await w(e),be(e,`active`);break;case`export`:{let t=await z(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}j().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ce=async e=>{try{await V(e),C({type:`patch`,patch:{sessions:P.filter(t=>t.key!==e),detailSession:J?.key===e?null:J,...J?.key===e?{detailOpen:!1}:{}}}),j().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,unnamedSession:e.chat.newSession},Te={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},Ee=[{key:`all`,label:t.filterAll,icon:U},{key:`active`,label:t.filterActive,icon:ae},{key:`pinned`,label:t.filterPinned,icon:le},{key:`archived`,label:t.filterArchived,icon:ee}],De=(()=>{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)(Be,{s:t,activeTab:y,onChange:b}),(0,Q.jsx)(Ve,{s:t,id:`settings`,activeTab:y,plain:!0,children:(0,Q.jsx)(Oe,{hasToken:r})}),(0,Q.jsxs)(Ve,{s:t,id:`sessions`,activeTab:y,plain:!0,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Ee.map(({key:e,label:t,icon:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":O===e,onClick:()=>C({type:`patch`,patch:{statusFilter:e}}),className:a(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,H.transition,H.focusRingPanel,O===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)(M,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,value:E,onChange:e=>C({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":D||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":!A,onClick:()=>C({type:`patch`,patch:{channelFilter:``}}),className:a(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,H.transition,H.focusRingPanel,A?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),De.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":A===e,onClick:()=>C({type:`patch`,patch:{channelFilter:e}}),className:a(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,H.transition,H.focusRingPanel,A===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:Ne(t.sessionCount,{count:P.length})}),(0,Q.jsxs)(`div`,{className:he,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Q.jsx)(q,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":k===`grid`,onClick:()=>C({type:`patch`,patch:{viewMode:`grid`}}),className:a(me,`size-7 p-0`,k===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,k===`grid`&&`text-accent-fg`),children:(0,Q.jsx)(oe,{className:`size-3.5`,strokeWidth:1.5})}),(0,Q.jsx)(q,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":k===`list`,onClick:()=>C({type:`patch`,patch:{viewMode:`list`}}),className:a(me,`size-9 p-0`,k===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,k===`list`&&`text-accent-fg`),children:(0,Q.jsx)(F,{className:`size-3.5`,strokeWidth:1.5})})]})]}),L&&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)(T,{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)(q,{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:a(`grid min-w-0 gap-3`,k===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":D||void 0,children:P.map(e=>{let t=K(e,m);return(0,Q.jsx)(ye,{session:e,variant:k,labels:we,sessionAgentId:t,sessionAgentAvatar:p(t,h),onOpen:()=>Se(e.key),onAction:t=>void $(e.key,t)},e.key)})}),W?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(q,{type:`button`,variant:`secondary`,disabled:L,onClick:()=>void ve(),children:t.loadMore})}):null]})]})]}),(0,Q.jsx)(Ae,{open:ce,loading:ue,session:J,sessionAgentId:J?K(J,m):void 0,sessionAgentAvatar:J?p(K(J,m),h):void 0,labels:Te,onClose:()=>{C({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>J&&void $(J.key,`archive`),onUnarchive:()=>J&&void $(J.key,`unarchive`),onPin:()=>J&&void $(J.key,`pin`),onUnpin:()=>J&&void $(J.key,`unpin`),onExport:()=>J&&void $(J.key,`export`),onDelete:()=>J&&C({type:`patch`,patch:{confirmKey:J.key,confirmOpen:!0}})}),(0,Q.jsx)(ne,{open:Y,onOpenChange:e=>C({type:`patch`,patch:{confirmOpen:e}}),children:(0,Q.jsxs)(re,{children:[(0,Q.jsx)(te,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,I)}),(0,Q.jsxs)(_,{className:a(`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`,f),children:[(0,Q.jsx)(pe,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:X?Ne(t.deleteSessionMessage,{name:P.find(e=>e.key===X)?.name?.trim()||e.chat.newSession}):``}),(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>C({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Q.jsx)(q,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{X&&Ce(X),C({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Q.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{Ue as SessionsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{si as e}from"./index-DSydVlxZ.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{au as a}from"./index-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{au as a}from"./index-DSydVlxZ.js";import{t as o}from"./settings-advanced-gate-BlWxQ6Ea.js";var s=n(),c=e(t(),1),l=r();function u(e){let t=(0,s.c)(26),{showLabel:n,hideLabel:r,icon:u,hint:d,children:f,className:p,defaultOpen:m,advancedOnly:h}=e,g=h===void 0?!1:h,[_,v]=(0,c.useState)(m??!1),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>v(e.currentTarget.open),t[0]=y):y=t[0];let b;t[1]===p?b=t[2]:(b=i(`group rounded-2xl bg-surface-base open:pb-1`,p),t[1]=p,t[2]=b);let x;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,l.jsx)(a,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[3]=x):x=t[3];let S;t[4]===u?S=t[5]:(S=u?(0,l.jsx)(u,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}):null,t[4]=u,t[5]=S);let C;t[6]===n?C=t[7]:(C=(0,l.jsx)(`span`,{className:`group-open:hidden`,children:n}),t[6]=n,t[7]=C);let w;t[8]===r?w=t[9]:(w=(0,l.jsx)(`span`,{className:`hidden group-open:inline`,children:r}),t[8]=r,t[9]=w);let T;t[10]!==S||t[11]!==C||t[12]!==w?(T=(0,l.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-2xl px-4 py-3.5 text-sm font-medium text-fg transition-colors hover:text-fg group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:[x,S,C,w]}),t[10]=S,t[11]=C,t[12]=w,t[13]=T):T=t[13];let E;t[14]===d?E=t[15]:(E=d?(0,l.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:d}):null,t[14]=d,t[15]=E);let D;t[16]!==f||t[17]!==E?(D=(0,l.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-4 pt-1`,children:[E,f]}),t[16]=f,t[17]=E,t[18]=D):D=t[18];let O;t[19]!==_||t[20]!==D||t[21]!==b||t[22]!==T?(O=(0,l.jsxs)(`details`,{open:_,onToggle:y,className:b,children:[T,D]}),t[19]=_,t[20]=D,t[21]=b,t[22]=T,t[23]=O):O=t[23];let k=O;if(g){let e;return t[24]===k?e=t[25]:(e=(0,l.jsx)(o,{children:k}),t[24]=k,t[25]=e),e}return k}export{u as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-BQ_8x0bT.js";import{Tc as r,ps as i}from"./index-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-BQ_8x0bT.js";import{Tc as r,ps as i}from"./index-DSydVlxZ.js";var a=e();function o(){return`rounded-2xl border border-edge-subtle bg-surface-base px-4 py-5 sm:px-5`}var s=t();function c(e){let t=(0,a.c)(6),{children:r,className:i,id:c}=e,l;t[0]===i?l=t[1]:(l=n(o(),i),t[0]=i,t[1]=l);let u;return t[2]!==r||t[3]!==c||t[4]!==l?(u=(0,s.jsx)(`section`,{id:c,className:l,children:r}),t[2]=r,t[3]=c,t[4]=l,t[5]=u):u=t[5],u}var l=`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted transition-colors dark:bg-surface-hover/70`;function u(e){let t=(0,a.c)(29),{icon:o,title:c,subtitle:u,trailing:d,titleAccessory:f,className:p,iconInteractive:m,iconLeading:h}=e,g;t[0]===o?g=t[1]:(g=(0,s.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=o,t[1]=g);let _=h??g,v;t[2]===h?v=t[3]:(v=h?n(`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel p-0 ring-1 ring-inset ring-edge-subtle transition-[box-shadow] hover:ring-accent/40 dark:ring-edge-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i.press):n(l,`hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i.press),t[2]=h,t[3]=v);let y=v,b=!!(m&&h),x;t[4]===p?x=t[5]:(x=n(`mb-5 flex items-start gap-3`,p),t[4]=p,t[5]=x);let S;t[6]!==m||t[7]!==h||t[8]!==_||t[9]!==y||t[10]!==b?(S=m?b?(0,s.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:y,children:_}),(0,s.jsx)(`span`,{className:`pointer-events-none absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-md border border-edge bg-surface-panel text-fg-muted shadow-sm dark:border-edge dark:bg-surface-base`,"aria-hidden":!0,children:(0,s.jsx)(r,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:y,children:_}):(0,s.jsx)(`div`,{className:n(h?`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel ring-1 ring-inset ring-edge-subtle dark:ring-edge-subtle`:l),"aria-hidden":!h,children:_}),t[6]=m,t[7]=h,t[8]=_,t[9]=y,t[10]=b,t[11]=S):S=t[11];let C;t[12]===c?C=t[13]:(C=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c}),t[12]=c,t[13]=C);let w;t[14]!==C||t[15]!==f?(w=(0,s.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[C,f]}),t[14]=C,t[15]=f,t[16]=w):w=t[16];let T;t[17]===u?T=t[18]:(T=u?(0,s.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u}):null,t[17]=u,t[18]=T);let E;t[19]!==w||t[20]!==T?(E=(0,s.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,T]}),t[19]=w,t[20]=T,t[21]=E):E=t[21];let D;t[22]===d?D=t[23]:(D=d?(0,s.jsx)(`div`,{className:`shrink-0`,children:d}):null,t[22]=d,t[23]=D);let O;return t[24]!==x||t[25]!==S||t[26]!==E||t[27]!==D?(O=(0,s.jsxs)(`div`,{className:x,children:[S,E,D]}),t[24]=x,t[25]=S,t[26]=E,t[27]=D,t[28]=O):O=t[28],O}export{u as n,o as r,c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{lo as n}from"./index-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{lo as n}from"./index-DSydVlxZ.js";var r=e(),i=t();function a(e){let t=(0,r.c)(2),{rows:n}=e,a=n===void 0?3:n,s;return t[0]===a?s=t[1]:(s=(0,i.jsx)(`div`,{className:`flex flex-col gap-2.5`,"aria-busy":`true`,children:Array.from({length:a}).map(o)}),t[0]=a,t[1]=s),s}function o(e,t){return(0,i.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,i.jsx)(n,{className:`h-4 w-48 max-w-full`}),(0,i.jsx)(n,{className:`mt-2 h-3 w-72 max-w-full`})]},t)}function s(e){let t=(0,r.c)(3),{sections:a}=e,o=a===void 0?2:a,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,i.jsxs)(`div`,{className:`space-y-2`,children:[(0,i.jsx)(n,{className:`h-6 w-48 max-w-full`}),(0,i.jsx)(n,{className:`h-4 w-80 max-w-full`})]}),t[0]=s):s=t[0];let l;return t[1]===o?l=t[2]:(l=(0,i.jsxs)(`div`,{className:`flex flex-col gap-6`,"aria-busy":`true`,children:[s,Array.from({length:o}).map(c)]}),t[1]=o,t[2]=l),l}function c(e,t){return(0,i.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,children:[(0,i.jsx)(n,{className:`h-5 w-40 max-w-full`}),(0,i.jsx)(n,{className:`mt-2 h-4 w-72 max-w-full`}),(0,i.jsx)(`div`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:Array.from({length:4}).map(l)})]},t)}function l(e,t){return(0,i.jsxs)(`div`,{className:`space-y-2`,children:[(0,i.jsx)(n,{className:`h-3 w-24`}),(0,i.jsx)(n,{className:`h-10 w-full rounded-lg`})]},t)}function u(e){let t=(0,r.c)(2),{rows:n}=e,a=n===void 0?3:n,o;return t[0]===a?o=t[1]:(o=(0,i.jsx)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:Array.from({length:a}).map(d)}),t[0]=a,t[1]=o),o}function d(e,t){return(0,i.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/70 p-3 shadow-surface`,children:[(0,i.jsx)(n,{className:`h-4 w-40 max-w-full`}),(0,i.jsx)(n,{className:`mt-2 h-3 w-64 max-w-full`})]},t)}export{s as n,a as r,u as t};
|
package/dist/gateway/static/root/assets/{settings-page-B1LJlRi9.js → settings-page-lPM7md10.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{r as i,u as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./messages-B0B40tpO.js";import{n as s}from"./locale-store-GfSwnwIZ.js";import{Ao as c,Co as l,Do as u,Eo as d,Oo as f,So as p,To as m,_o as h,bo as g,go as _,ko as v,vo as y,wo as b,xo as x,yo as S}from"./index-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{r as i,u as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./messages-B0B40tpO.js";import{n as s}from"./locale-store-GfSwnwIZ.js";import{Ao as c,Co as l,Do as u,Eo as d,Oo as f,So as p,To as m,_o as h,bo as g,go as _,ko as v,vo as y,wo as b,xo as x,yo as S}from"./index-DSydVlxZ.js";var C=n(),w=e(t(),1),T=r(),E=[`overview`,`appearance`,`keyboard-shortcuts`,`user-profile`,`system`,`desktop-pet`,`desktop-app`,`credentials`,`capability-presets`,`gateway`,`heartbeat`,`remote-access`,`shares`,`goals`,`dreams`],D=(0,w.lazy)(()=>u().then(e=>({default:e.SetupStatusPanel}))),O=(0,w.lazy)(()=>h().then(e=>({default:e.AppearanceSettingsPanel}))),k=(0,w.lazy)(()=>b().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),A=(0,w.lazy)(()=>c().then(e=>({default:e.UserProfileSettingsPanel}))),j=(0,w.lazy)(()=>v().then(e=>({default:e.SystemSettingsPanel}))),M=(0,w.lazy)(()=>S().then(e=>({default:e.DesktopPetSettings}))),N=(0,w.lazy)(()=>_().then(e=>({default:e.AppManagementSettingsPanel}))),P=(0,w.lazy)(()=>m().then(e=>({default:e.ModelsHubPanel}))),F=(0,w.lazy)(()=>x().then(e=>({default:e.GatewaySettingsPanel}))),I=(0,w.lazy)(()=>l().then(e=>({default:e.HeartbeatSettingsPanel}))),L=(0,w.lazy)(()=>d().then(e=>({default:e.RemoteAccessHub}))),R=(0,w.lazy)(()=>f().then(e=>({default:e.SharesSettingsPanel}))),z=(0,w.lazy)(()=>g().then(e=>({default:e.DreamingSettingsPanel}))),B=(0,w.lazy)(()=>p().then(e=>({default:e.GoalsSettingsPanel}))),V=(0,w.lazy)(()=>y().then(e=>({default:e.CapabilityPresetsSettingsPanel})));function H(){let e=(0,C.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,T.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,T.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function U(e){return(0,T.jsx)(w.Suspense,{fallback:(0,T.jsx)(H,{}),children:(0,T.jsx)(e,{})})}function W(){let e=(0,C.c)(30),{section:t}=a(),n=s(G),r,c,l,u,d;if(e[0]!==n||e[1]!==t){d=Symbol.for(`react.early_return_sentinel`);bb0:{let a=o(n);if(!t||!E.includes(t)){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,T.jsx)(i,{to:`/settings/overview`,replace:!0}),e[7]=t):t=e[7],d=t;break bb0}let s=t;if(s===`overview`){let t;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(D),e[8]=t):t=e[8],d=t;break bb0}let f=a.settingsSections[s];if(s===`appearance`){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(O),e[9]=t):t=e[9],d=t;break bb0}if(s===`keyboard-shortcuts`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(k),e[10]=t):t=e[10],d=t;break bb0}if(s===`user-profile`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(A),e[11]=t):t=e[11],d=t;break bb0}if(s===`system`){let t;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(j),e[12]=t):t=e[12],d=t;break bb0}if(s===`desktop-pet`){let t;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(M),e[13]=t):t=e[13],d=t;break bb0}if(s===`desktop-app`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(N),e[14]=t):t=e[14],d=t;break bb0}if(s===`credentials`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(P),e[15]=t):t=e[15],d=t;break bb0}if(s===`capability-presets`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(V),e[16]=t):t=e[16],d=t;break bb0}if(s===`gateway`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(F),e[17]=t):t=e[17],d=t;break bb0}if(s===`heartbeat`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(I),e[18]=t):t=e[18],d=t;break bb0}if(s===`remote-access`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(L),e[19]=t):t=e[19],d=t;break bb0}if(s===`shares`){let t;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(R),e[20]=t):t=e[20],d=t;break bb0}if(s===`dreams`){let t;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(z),e[21]=t):t=e[21],d=t;break bb0}if(s===`goals`){let t;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(B),e[22]=t):t=e[22],d=t;break bb0}l=`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,u=(0,T.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:f}),r=`text-sm text-fg-muted`,c=a.settingsPage.comingSoon.replace(`{{title}}`,f)}e[0]=n,e[1]=t,e[2]=r,e[3]=c,e[4]=l,e[5]=u,e[6]=d}else r=e[2],c=e[3],l=e[4],u=e[5],d=e[6];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;e[23]!==r||e[24]!==c?(f=(0,T.jsx)(`p`,{className:r,children:c}),e[23]=r,e[24]=c,e[25]=f):f=e[25];let p;return e[26]!==l||e[27]!==u||e[28]!==f?(p=(0,T.jsxs)(`div`,{className:l,children:[u,f]}),e[26]=l,e[27]=u,e[28]=f,e[29]=p):p=e[29],p}function G(e){return e.language}export{W as SettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-BQ_8x0bT.js";import{Ml as r}from"./index-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-BQ_8x0bT.js";import{Ml as r}from"./index-DSydVlxZ.js";var i=e(),a=t();function o(e){let t=(0,i.c)(14),r,o,s,c,l;t[0]===e?(r=t[1],o=t[2],s=t[3],c=t[4],l=t[5]):({children:r,className:o,gap:c,padding:l,...s}=e,t[0]=e,t[1]=r,t[2]=o,t[3]=s,t[4]=c,t[5]=l);let u=c===void 0?`gap-4`:c,d=l===void 0?`px-3 py-6 sm:px-5 xl:px-6`:l,f;t[6]!==o||t[7]!==u||t[8]!==d?(f=n(`flex min-h-full w-full flex-col bg-surface-panel`,u,d,o),t[6]=o,t[7]=u,t[8]=d,t[9]=f):f=t[9];let p;return t[10]!==r||t[11]!==s||t[12]!==f?(p=(0,a.jsx)(`div`,{className:f,...s,children:r}),t[10]=r,t[11]=s,t[12]=f,t[13]=p):p=t[13],p}function s(e){let t=(0,i.c)(20),{title:o,subtitle:s,docsLink:c,docsLabel:l,meta:u,actions:d,className:f}=e,p;t[0]===f?p=t[1]:(p=n(`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,f),t[0]=f,t[1]=p);let m;t[2]===o?m=t[3]:(m=(0,a.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:o}),t[2]=o,t[3]=m);let h;t[4]===s?h=t[5]:(h=s?(0,a.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null,t[4]=s,t[5]=h);let g;t[6]!==l||t[7]!==c?(g=c&&l?(0,a.jsxs)(`a`,{href:c,target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[l,(0,a.jsx)(r,{className:`size-3.5`,"aria-hidden":!0})]}):null,t[6]=l,t[7]=c,t[8]=g):g=t[8];let _;t[9]!==u||t[10]!==m||t[11]!==h||t[12]!==g?(_=(0,a.jsxs)(`div`,{className:`min-w-0`,children:[m,h,g,u]}),t[9]=u,t[10]=m,t[11]=h,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d?(0,a.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:d}):null,t[14]=d,t[15]=v);let y;return t[16]!==p||t[17]!==_||t[18]!==v?(y=(0,a.jsxs)(`header`,{className:p,children:[_,v]}),t[16]=p,t[17]=_,t[18]=v,t[19]=y):y=t[19],y}function c(e){let t=(0,i.c)(13),{id:r,activeTab:o,tabIdPrefix:s,panelIdPrefix:c,title:l,hint:u,showHeading:d,framed:f,children:p,className:m}=e,h=d===void 0?!0:d,g=f===void 0?!0:f;if(o!==r)return null;let _=`${c}-${r}`,v=`${s}-${r}`,y=g&&`rounded-2xl border border-edge-subtle bg-surface-base px-4 py-5 sm:px-5`,b;t[0]!==m||t[1]!==y?(b=n(`min-w-0`,y,m),t[0]=m,t[1]=y,t[2]=b):b=t[2];let x;t[3]!==u||t[4]!==h||t[5]!==l?(x=h&&(l||u)?(0,a.jsxs)(`div`,{className:`mb-5`,children:[l?(0,a.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:l}):null,u?(0,a.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:u}):null]}):null,t[3]=u,t[4]=h,t[5]=l,t[6]=x):x=t[6];let S;return t[7]!==p||t[8]!==_||t[9]!==v||t[10]!==b||t[11]!==x?(S=(0,a.jsxs)(`section`,{id:_,role:`tabpanel`,"aria-labelledby":v,className:b,children:[x,p]}),t[7]=p,t[8]=_,t[9]=v,t[10]=b,t[11]=x,t[12]=S):S=t[12],S}export{s as n,o as r,c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-B0B40tpO.js";import{l as s,n as c,r as l,s as u}from"./locale-store-GfSwnwIZ.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Jl as f,Kn as p,Ps as m,Tu as h,Uc as g,Ws as _,co as v,ds as y,er as b,fc as ee,ii as x,ol as S,ps as C,ql as w,ru as T,sr as E,tr as D,tu as O}from"./index-apLU0Hun.js";import{n as k,r as A}from"./settings-page-layout-CsrLuDsW.js";import{n as j}from"./settings-loading-skeleton-CEJtaoQp.js";import{n as M,t as N}from"./settings-form-section-DND90dDt.js";var P=e(t(),1),F=n();function I(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`&&y(e)).length}function L(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t,r=typeof n.defaultPreset==`string`&&n.defaultPreset.trim()?n.defaultPreset.trim():`default`,i=n.capabilityPresets,a=i&&typeof i==`object`&&!Array.isArray(i)?i[r]:void 0,o=a&&typeof a==`object`&&!Array.isArray(a)?a.models:void 0;if(!o||typeof o!=`object`||Array.isArray(o))return``;let s=o,c=s.roles;if(!c||typeof c!=`object`||Array.isArray(c))return``;let l=c,u=typeof s.defaultRole==`string`&&s.defaultRole.trim()?s.defaultRole.trim():Object.keys(l)[0],d=u?l[u]:void 0;if(!d||typeof d!=`object`||Array.isArray(d))return``;let f=d.model;return typeof f==`string`?f.trim():``}function R(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 z(e){if(!e||typeof e!=`object`)return{enabled:!1,backend:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,backend:`extension`};let n=t;return{enabled:n.enabled===!0,backend:typeof n.backend==`string`&&n.backend.trim()?n.backend.trim():`extension`}}function B(e){return e?`pass`:`fail`}function V(e){if(e===`provider-auth`)return`/settings/credentials`;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 H(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function te(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:V(e.id),source:`doctor`})).toSorted((e,t)=>H(t.status)-H(e.status)||e.label.localeCompare(t.label))}function U(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:V(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 ne(e){let t=I(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=L(e.config),o=a.length>0,s=e.hasToken&&e.sseConnected,c=R(e.config),l=e.skillCount>0,u=e.doctorChecks??[],d=te(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:B(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:B(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/credentials`},{id:`defaultModel`,status:B(o),title:`Default model`,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing,path:`/settings/credentials?tab=services`},{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=U({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 re(e){return z(e)}function W(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 ie(){return l(`/api/doctor`)}async function ae(){return((await u(ie())).checks??[]).map(W).filter(e=>e!==null)}function oe(){return l(`/api/logs/health`)}async function se(){return u(oe())}function G(e){return e?`pass`:`warn`}function K(e){return`/settings/agent-browser?tab=${encodeURIComponent(e)}`}function ce(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function le(e){if(!e.enabled)return[];if(e.backend===`local`){let e=await u(l(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:G(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:K(`local`)}]}if(e.backend===`cloakbrowser`){let e=await u(l(`/api/browser/cloakbrowser/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-cloakbrowser`,label:`Browser: CloakBrowser`,status:G(t),message:t?`CloakBrowser ${e.payload?.version??``}`.trim():`CloakBrowser is not installed.`,path:K(`cloakbrowser`)}]}if(e.backend===`extension`){let e=await u(l(`/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:K(`extension`)}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser backend "${e.backend}" is not checked on this overview.`,path:K(e.backend||`overview`)}]}function q(){let e=(0,F.c)(57),t=s(he),n=c(me),r;e[0]===n?r=e[1]:(r=o(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,l=E(pe),{data:u,error:f,isLoading:m,mutate:h}=v(!!t),g;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1},e[2]=g):g=e[2];let{data:_,error:y,isLoading:ee,mutate:x}=d(t?`setup-checklist-skills`:null,fe,g),S;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(S={revalidateOnFocus:!1},e[3]=S):S=e[3];let{data:C,error:w,isLoading:T,mutate:O}=d(t?`setup-checklist-provider-meta`:null,p,S),k;e[4]===t?k=e[5]:(k=t?ie():null,e[4]=t,e[5]=k);let A;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1},e[6]=A):A=e[6];let{data:j,error:M,isLoading:N,mutate:P}=d(k,ae,A),I;e[7]===t?I=e[8]:(I=t?oe():null,e[7]=t,e[8]=I);let L;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(L={revalidateOnFocus:!1},e[9]=L):L=e[9];let{data:R,isLoading:z,mutate:B}=d(I,se,L);u?.payload?.config;let V=u?.payload?.config,H;e[10]===V?H=e[11]:(H=re(V),e[10]=V,e[11]=H);let te=t?H:null,U;e[12]===te?U=e[13]:(U=ce(te),e[12]=te,e[13]=U);let W;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(W={revalidateOnFocus:!1},e[14]=W):W=e[14];let{data:G,isLoading:K,mutate:le}=d(U,de,W),q;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(q={revalidateOnFocus:!1},e[15]=q):q=e[15],d(t?b:null,D,q);let J=!t||!m&&!ee&&!T&&!N&&!z&&!K,Y=!!(f||y||w||M),X;bb0:{if(!t||!J){X=null;break bb0}let n=_?.catalog?.length??0,r;if(e[16]!==G||e[17]!==u?.payload?.config||e[18]!==j||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]!==R||e[31]!==i.setupStatus.requiredCompleteMessage||e[32]!==C||e[33]!==n||e[34]!==l||e[35]!==t){let o=C?.filter(ue).length??0,s=C?.length??0,c;e[37]===a.providersConfigured?c=e[38]:(c=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[37]=a.providersConfigured,e[38]=c);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=ne({hasToken:!!t,sseConnected:l,config:u?.payload?.config,skillCount:n,providerMeta:s>0?{configured:o,total:s}:null,doctorChecks:j,logsHealth:R,browserDiagnostics:G,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:c,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]=G,e[17]=u?.payload?.config,e[18]=j,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]=R,e[31]=i.setupStatus.requiredCompleteMessage,e[32]=C,e[33]=n,e[34]=l,e[35]=t,e[36]=r}else r=e[36];X=r}let Z=X,Q;e[45]!==le||e[46]!==h||e[47]!==P||e[48]!==B||e[49]!==O||e[50]!==x?(Q=async()=>{await Promise.all([h(),x(),O(),P(),B(),le()])},e[45]=le,e[46]=h,e[47]=P,e[48]=B,e[49]=O,e[50]=x,e[51]=Q):Q=e[51];let ge=Q,$;return e[52]!==Y||e[53]!==J||e[54]!==ge||e[55]!==Z?($={ready:J,error:Y,snapshot:Z,refresh:ge},e[52]=Y,e[53]=J,e[54]=ge,e[55]=Z,e[56]=$):$=e[56],$}function ue(e){return e.configured}function de(e){let[,t]=e;return le(t)}function fe(){return x()}function pe(e){return e.connectionState===`connected`}function me(e){return e.language}function he(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`?O:e===`warn`?m:e===`fail`?f:S}function Z(e,t){return e===`blocked`?{icon:f,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:m,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:O,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function Q(e){let t=(0,F.c)(48),{tier:n,issueCount:r,onRunDoctor:s,ready:l,doctorRunning:u,doctorRunState:d}=e,f=c(ge),p,m,h,_,v,y,b,x,S,w,E;if(t[0]!==r||t[1]!==f||t[2]!==n){m=o(f).setupStatus;let e=Z(n,m),s=e.icon,c=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,l=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;p=c?(0,J.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(c)?.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)(T,{className:`size-4`,"aria-hidden":!0})]}):(0,J.jsxs)(i,{to:l,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)(T,{className:`size-4`,"aria-hidden":!0})]}),E=a(`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)(s,{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}),h=`mt-2 text-xs opacity-75`,_=m.health.issueCount.replace(`{{count}}`,String(r)),t[0]=r,t[1]=f,t[2]=n,t[3]=p,t[4]=m,t[5]=h,t[6]=_,t[7]=v,t[8]=y,t[9]=b,t[10]=x,t[11]=S,t[12]=w,t[13]=E}else p=t[3],m=t[4],h=t[5],_=t[6],v=t[7],y=t[8],b=t[9],x=t[10],S=t[11],w=t[12],E=t[13];let D;t[14]!==h||t[15]!==_?(D=(0,J.jsx)(`p`,{className:h,children:_}),t[14]=h,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 k;t[22]!==O||t[23]!==x||t[24]!==S?(k=(0,J.jsxs)(`div`,{className:x,children:[S,O]}),t[22]=O,t[23]=x,t[24]=S,t[25]=k):k=t[25];let A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=a(`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`,C.press),t[26]=A):A=t[26];let j=!l||u,M;t[27]===u?M=t[28]:(M=u?(0,J.jsx)(g,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,J.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[27]=u,t[28]=M);let N=u?m.health.runDoctorRunning:m.health.runDoctor,P;t[29]!==u||t[30]!==s||t[31]!==j||t[32]!==M||t[33]!==N?(P=(0,J.jsxs)(`button`,{type:`button`,className:A,onClick:s,disabled:j,"aria-busy":u,children:[M,N]}),t[29]=u,t[30]=s,t[31]=j,t[32]=M,t[33]=N,t[34]=P):P=t[34];let I;t[35]!==p||t[36]!==P?(I=(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[p,P]}),t[35]=p,t[36]=P,t[37]=I):I=t[37];let L;t[38]!==k||t[39]!==I||t[40]!==w?(L=(0,J.jsxs)(`div`,{className:w,children:[k,I]}),t[38]=k,t[39]=I,t[40]=w,t[41]=L):L=t[41];let R=u?m.health.doctorRunningMessage:d===`success`?m.health.doctorCompleteMessage:d===`error`?m.health.doctorFailedMessage:m.health.doctorIdleMessage,z;t[42]===R?z=t[43]:(z=(0,J.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:R}),t[42]=R,t[43]=z);let B;return t[44]!==L||t[45]!==z||t[46]!==E?(B=(0,J.jsxs)(`section`,{className:E,children:[L,z]}),t[44]=L,t[45]=z,t[46]=E,t[47]=B):B=t[47],B}function ge(e){return e.language}function $(e){let t=(0,F.c)(34),{issue:n,fixLabel:r}=e,o;t[0]===n.status?o=t[1]:(o=X(n.status),t[0]=n.status,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=(0,J.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=s,t[3]=c);let l;t[4]===n.label?l=t[5]:(l=(0,J.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=l);let u;t[6]===n.status?u=t[7]:(u=a(`rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,Y(n.status)),t[6]=n.status,t[7]=u);let d;t[8]!==n.status||t[9]!==u?(d=(0,J.jsx)(`span`,{className:u,children:n.status}),t[8]=n.status,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==l||t[12]!==d?(f=(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=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]!==f||t[19]!==p||t[20]!==m?(h=(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[18]=f,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)(T,{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]!==c||t[27]!==h?(_=(0,J.jsxs)(J.Fragment,{children:[c,h,g]}),t[25]=g,t[26]=c,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(e){let t=(0,F.c)(27),{item:n,labels:r}=e,o;t[0]===n.status?o=t[1]:(o=X(n.status),t[0]=n.status,t[1]=o);let s=o,c=r[n.id]??n.title,l;t[2]===n.status?l=t[3]:(l=a(`flex size-7 shrink-0 items-center justify-center rounded-full border`,Y(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===s?u=t[5]:(u=(0,J.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t[4]=s,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,J.jsx)(`span`,{className:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===c?f=t[10]:(f=(0,J.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:c}),t[9]=c,t[10]=f);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]!==f||t[14]!==p?(m=(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p]}),t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===n.path?h=t[17]:(h=n.path?(0,J.jsx)(T,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=h);let g;t[18]!==d||t[19]!==m||t[20]!==h?(g=(0,J.jsxs)(J.Fragment,{children:[d,m,h]}),t[18]=d,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 ve(e){let t=(0,F.c)(29),{signal:n,fixLabel:r}=e,o;t[0]===n.status?o=t[1]:(o=X(n.status),t[0]=n.status,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=(0,J.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=s,t[3]=c);let l;t[4]===n.label?l=t[5]:(l=(0,J.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=l);let u;t[6]===n.message?u=t[7]:(u=(0,J.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=u);let d;t[8]!==l||t[9]!==u?(d=(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10];let f;t[11]===n.status?f=t[12]:(f=a(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,Y(n.status)),t[11]=n.status,t[12]=f);let p;t[13]!==n.status||t[14]!==f?(p=(0,J.jsx)(`span`,{className:f,children:n.status}),t[13]=n.status,t[14]=f,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]!==c||t[20]!==d||t[21]!==p||t[22]!==m?(h=(0,J.jsxs)(J.Fragment,{children:[c,d,p,m]}),t[19]=c,t[20]=d,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 ye(){let e=o(c(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=q(),[s,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(`idle`),f=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],p=async()=>{if(!(s||!t)){l(!0),d(`idle`);try{await i(),d(`success`)}catch{d(`error`)}finally{l(!1)}}};return(0,J.jsxs)(A,{gap:`gap-6`,children:[(0,J.jsx)(k,{title:e.title,subtitle:e.subtitle,actions:(0,J.jsxs)(`button`,{type:`button`,className:a(`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`,C.press),onClick:()=>void p(),disabled:!t||s,"aria-busy":s,children:[(0,J.jsx)(ee,{className:a(`size-4`,(!t||s)&&`animate-spin`),"aria-hidden":!0}),s?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)(j,{sections:2}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Q,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void p(),doctorRunning:s,doctorRunState:u}),(0,J.jsxs)(N,{id:`next-steps`,children:[(0,J.jsx)(M,{icon:r.issues.length?m:h,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)($,{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)(_e,{item:t,labels:e.readinessLabels},t.id))})]}),(0,J.jsxs)(N,{children:[(0,J.jsx)(M,{icon:_,title:e.diagnosticsTitle,subtitle:e.diagnosticsSubtitle}),f.length?(0,J.jsx)(`div`,{className:`mt-4 grid gap-2 md:grid-cols-2`,children:f.map(t=>(0,J.jsx)(ve,{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{ye as SetupStatusPanel};
|
|
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-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-B0B40tpO.js";import{l as s,n as c,r as l,s as u}from"./locale-store-GfSwnwIZ.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Jl as f,Kn as p,Ps as m,Tu as h,Uc as g,Ws as _,co as v,ds as y,er as b,fc as ee,ii as x,ol as S,ps as C,ql as w,ru as T,sr as E,tr as D,tu as O}from"./index-DSydVlxZ.js";import{n as k,r as A}from"./settings-page-layout-B_-VepeK.js";import{n as j}from"./settings-loading-skeleton-ClHNJwRL.js";import{n as M,t as N}from"./settings-form-section-DPSA8tG8.js";var P=e(t(),1),F=n();function I(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`&&y(e)).length}function L(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t,r=typeof n.defaultPreset==`string`&&n.defaultPreset.trim()?n.defaultPreset.trim():`default`,i=n.capabilityPresets,a=i&&typeof i==`object`&&!Array.isArray(i)?i[r]:void 0,o=a&&typeof a==`object`&&!Array.isArray(a)?a.models:void 0;if(!o||typeof o!=`object`||Array.isArray(o))return``;let s=o,c=s.roles;if(!c||typeof c!=`object`||Array.isArray(c))return``;let l=c,u=typeof s.defaultRole==`string`&&s.defaultRole.trim()?s.defaultRole.trim():Object.keys(l)[0],d=u?l[u]:void 0;if(!d||typeof d!=`object`||Array.isArray(d))return``;let f=d.model;return typeof f==`string`?f.trim():``}function R(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 z(e){if(!e||typeof e!=`object`)return{enabled:!1,backend:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,backend:`extension`};let n=t;return{enabled:n.enabled===!0,backend:typeof n.backend==`string`&&n.backend.trim()?n.backend.trim():`extension`}}function B(e){return e?`pass`:`fail`}function V(e){if(e===`provider-auth`)return`/settings/credentials`;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 H(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function te(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:V(e.id),source:`doctor`})).toSorted((e,t)=>H(t.status)-H(e.status)||e.label.localeCompare(t.label))}function U(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:V(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 ne(e){let t=I(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=L(e.config),o=a.length>0,s=e.hasToken&&e.sseConnected,c=R(e.config),l=e.skillCount>0,u=e.doctorChecks??[],d=te(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:B(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:B(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/credentials`},{id:`defaultModel`,status:B(o),title:`Default model`,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing,path:`/settings/credentials?tab=services`},{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=U({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 re(e){return z(e)}function W(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 ie(){return l(`/api/doctor`)}async function ae(){return((await u(ie())).checks??[]).map(W).filter(e=>e!==null)}function oe(){return l(`/api/logs/health`)}async function se(){return u(oe())}function G(e){return e?`pass`:`warn`}function K(e){return`/settings/agent-browser?tab=${encodeURIComponent(e)}`}function ce(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function le(e){if(!e.enabled)return[];if(e.backend===`local`){let e=await u(l(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:G(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:K(`local`)}]}if(e.backend===`cloakbrowser`){let e=await u(l(`/api/browser/cloakbrowser/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-cloakbrowser`,label:`Browser: CloakBrowser`,status:G(t),message:t?`CloakBrowser ${e.payload?.version??``}`.trim():`CloakBrowser is not installed.`,path:K(`cloakbrowser`)}]}if(e.backend===`extension`){let e=await u(l(`/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:K(`extension`)}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser backend "${e.backend}" is not checked on this overview.`,path:K(e.backend||`overview`)}]}function q(){let e=(0,F.c)(57),t=s(he),n=c(me),r;e[0]===n?r=e[1]:(r=o(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,l=E(pe),{data:u,error:f,isLoading:m,mutate:h}=v(!!t),g;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1},e[2]=g):g=e[2];let{data:_,error:y,isLoading:ee,mutate:x}=d(t?`setup-checklist-skills`:null,fe,g),S;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(S={revalidateOnFocus:!1},e[3]=S):S=e[3];let{data:C,error:w,isLoading:T,mutate:O}=d(t?`setup-checklist-provider-meta`:null,p,S),k;e[4]===t?k=e[5]:(k=t?ie():null,e[4]=t,e[5]=k);let A;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1},e[6]=A):A=e[6];let{data:j,error:M,isLoading:N,mutate:P}=d(k,ae,A),I;e[7]===t?I=e[8]:(I=t?oe():null,e[7]=t,e[8]=I);let L;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(L={revalidateOnFocus:!1},e[9]=L):L=e[9];let{data:R,isLoading:z,mutate:B}=d(I,se,L);u?.payload?.config;let V=u?.payload?.config,H;e[10]===V?H=e[11]:(H=re(V),e[10]=V,e[11]=H);let te=t?H:null,U;e[12]===te?U=e[13]:(U=ce(te),e[12]=te,e[13]=U);let W;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(W={revalidateOnFocus:!1},e[14]=W):W=e[14];let{data:G,isLoading:K,mutate:le}=d(U,de,W),q;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(q={revalidateOnFocus:!1},e[15]=q):q=e[15],d(t?b:null,D,q);let J=!t||!m&&!ee&&!T&&!N&&!z&&!K,Y=!!(f||y||w||M),X;bb0:{if(!t||!J){X=null;break bb0}let n=_?.catalog?.length??0,r;if(e[16]!==G||e[17]!==u?.payload?.config||e[18]!==j||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]!==R||e[31]!==i.setupStatus.requiredCompleteMessage||e[32]!==C||e[33]!==n||e[34]!==l||e[35]!==t){let o=C?.filter(ue).length??0,s=C?.length??0,c;e[37]===a.providersConfigured?c=e[38]:(c=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[37]=a.providersConfigured,e[38]=c);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=ne({hasToken:!!t,sseConnected:l,config:u?.payload?.config,skillCount:n,providerMeta:s>0?{configured:o,total:s}:null,doctorChecks:j,logsHealth:R,browserDiagnostics:G,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:c,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]=G,e[17]=u?.payload?.config,e[18]=j,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]=R,e[31]=i.setupStatus.requiredCompleteMessage,e[32]=C,e[33]=n,e[34]=l,e[35]=t,e[36]=r}else r=e[36];X=r}let Z=X,Q;e[45]!==le||e[46]!==h||e[47]!==P||e[48]!==B||e[49]!==O||e[50]!==x?(Q=async()=>{await Promise.all([h(),x(),O(),P(),B(),le()])},e[45]=le,e[46]=h,e[47]=P,e[48]=B,e[49]=O,e[50]=x,e[51]=Q):Q=e[51];let ge=Q,$;return e[52]!==Y||e[53]!==J||e[54]!==ge||e[55]!==Z?($={ready:J,error:Y,snapshot:Z,refresh:ge},e[52]=Y,e[53]=J,e[54]=ge,e[55]=Z,e[56]=$):$=e[56],$}function ue(e){return e.configured}function de(e){let[,t]=e;return le(t)}function fe(){return x()}function pe(e){return e.connectionState===`connected`}function me(e){return e.language}function he(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`?O:e===`warn`?m:e===`fail`?f:S}function Z(e,t){return e===`blocked`?{icon:f,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:m,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:O,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function Q(e){let t=(0,F.c)(48),{tier:n,issueCount:r,onRunDoctor:s,ready:l,doctorRunning:u,doctorRunState:d}=e,f=c(ge),p,m,h,_,v,y,b,x,S,w,E;if(t[0]!==r||t[1]!==f||t[2]!==n){m=o(f).setupStatus;let e=Z(n,m),s=e.icon,c=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,l=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;p=c?(0,J.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(c)?.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)(T,{className:`size-4`,"aria-hidden":!0})]}):(0,J.jsxs)(i,{to:l,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)(T,{className:`size-4`,"aria-hidden":!0})]}),E=a(`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)(s,{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}),h=`mt-2 text-xs opacity-75`,_=m.health.issueCount.replace(`{{count}}`,String(r)),t[0]=r,t[1]=f,t[2]=n,t[3]=p,t[4]=m,t[5]=h,t[6]=_,t[7]=v,t[8]=y,t[9]=b,t[10]=x,t[11]=S,t[12]=w,t[13]=E}else p=t[3],m=t[4],h=t[5],_=t[6],v=t[7],y=t[8],b=t[9],x=t[10],S=t[11],w=t[12],E=t[13];let D;t[14]!==h||t[15]!==_?(D=(0,J.jsx)(`p`,{className:h,children:_}),t[14]=h,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 k;t[22]!==O||t[23]!==x||t[24]!==S?(k=(0,J.jsxs)(`div`,{className:x,children:[S,O]}),t[22]=O,t[23]=x,t[24]=S,t[25]=k):k=t[25];let A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=a(`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`,C.press),t[26]=A):A=t[26];let j=!l||u,M;t[27]===u?M=t[28]:(M=u?(0,J.jsx)(g,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,J.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[27]=u,t[28]=M);let N=u?m.health.runDoctorRunning:m.health.runDoctor,P;t[29]!==u||t[30]!==s||t[31]!==j||t[32]!==M||t[33]!==N?(P=(0,J.jsxs)(`button`,{type:`button`,className:A,onClick:s,disabled:j,"aria-busy":u,children:[M,N]}),t[29]=u,t[30]=s,t[31]=j,t[32]=M,t[33]=N,t[34]=P):P=t[34];let I;t[35]!==p||t[36]!==P?(I=(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[p,P]}),t[35]=p,t[36]=P,t[37]=I):I=t[37];let L;t[38]!==k||t[39]!==I||t[40]!==w?(L=(0,J.jsxs)(`div`,{className:w,children:[k,I]}),t[38]=k,t[39]=I,t[40]=w,t[41]=L):L=t[41];let R=u?m.health.doctorRunningMessage:d===`success`?m.health.doctorCompleteMessage:d===`error`?m.health.doctorFailedMessage:m.health.doctorIdleMessage,z;t[42]===R?z=t[43]:(z=(0,J.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:R}),t[42]=R,t[43]=z);let B;return t[44]!==L||t[45]!==z||t[46]!==E?(B=(0,J.jsxs)(`section`,{className:E,children:[L,z]}),t[44]=L,t[45]=z,t[46]=E,t[47]=B):B=t[47],B}function ge(e){return e.language}function $(e){let t=(0,F.c)(34),{issue:n,fixLabel:r}=e,o;t[0]===n.status?o=t[1]:(o=X(n.status),t[0]=n.status,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=(0,J.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=s,t[3]=c);let l;t[4]===n.label?l=t[5]:(l=(0,J.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=l);let u;t[6]===n.status?u=t[7]:(u=a(`rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,Y(n.status)),t[6]=n.status,t[7]=u);let d;t[8]!==n.status||t[9]!==u?(d=(0,J.jsx)(`span`,{className:u,children:n.status}),t[8]=n.status,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==l||t[12]!==d?(f=(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=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]!==f||t[19]!==p||t[20]!==m?(h=(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[18]=f,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)(T,{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]!==c||t[27]!==h?(_=(0,J.jsxs)(J.Fragment,{children:[c,h,g]}),t[25]=g,t[26]=c,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(e){let t=(0,F.c)(27),{item:n,labels:r}=e,o;t[0]===n.status?o=t[1]:(o=X(n.status),t[0]=n.status,t[1]=o);let s=o,c=r[n.id]??n.title,l;t[2]===n.status?l=t[3]:(l=a(`flex size-7 shrink-0 items-center justify-center rounded-full border`,Y(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===s?u=t[5]:(u=(0,J.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t[4]=s,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,J.jsx)(`span`,{className:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===c?f=t[10]:(f=(0,J.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:c}),t[9]=c,t[10]=f);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]!==f||t[14]!==p?(m=(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p]}),t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===n.path?h=t[17]:(h=n.path?(0,J.jsx)(T,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=h);let g;t[18]!==d||t[19]!==m||t[20]!==h?(g=(0,J.jsxs)(J.Fragment,{children:[d,m,h]}),t[18]=d,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 ve(e){let t=(0,F.c)(29),{signal:n,fixLabel:r}=e,o;t[0]===n.status?o=t[1]:(o=X(n.status),t[0]=n.status,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=(0,J.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=s,t[3]=c);let l;t[4]===n.label?l=t[5]:(l=(0,J.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=l);let u;t[6]===n.message?u=t[7]:(u=(0,J.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=u);let d;t[8]!==l||t[9]!==u?(d=(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10];let f;t[11]===n.status?f=t[12]:(f=a(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,Y(n.status)),t[11]=n.status,t[12]=f);let p;t[13]!==n.status||t[14]!==f?(p=(0,J.jsx)(`span`,{className:f,children:n.status}),t[13]=n.status,t[14]=f,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]!==c||t[20]!==d||t[21]!==p||t[22]!==m?(h=(0,J.jsxs)(J.Fragment,{children:[c,d,p,m]}),t[19]=c,t[20]=d,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 ye(){let e=o(c(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=q(),[s,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(`idle`),f=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],p=async()=>{if(!(s||!t)){l(!0),d(`idle`);try{await i(),d(`success`)}catch{d(`error`)}finally{l(!1)}}};return(0,J.jsxs)(A,{gap:`gap-6`,children:[(0,J.jsx)(k,{title:e.title,subtitle:e.subtitle,actions:(0,J.jsxs)(`button`,{type:`button`,className:a(`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`,C.press),onClick:()=>void p(),disabled:!t||s,"aria-busy":s,children:[(0,J.jsx)(ee,{className:a(`size-4`,(!t||s)&&`animate-spin`),"aria-hidden":!0}),s?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)(j,{sections:2}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Q,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void p(),doctorRunning:s,doctorRunState:u}),(0,J.jsxs)(N,{id:`next-steps`,children:[(0,J.jsx)(M,{icon:r.issues.length?m:h,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)($,{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)(_e,{item:t,labels:e.readinessLabels},t.id))})]}),(0,J.jsxs)(N,{children:[(0,J.jsx)(M,{icon:_,title:e.diagnosticsTitle,subtitle:e.diagnosticsSubtitle}),f.length?(0,J.jsx)(`div`,{className:`mt-4 grid gap-2 md:grid-cols-2`,children:f.map(t=>(0,J.jsx)(ve,{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{ye as SetupStatusPanel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-RnGYy9bC.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-zJ_50EbN.js","assets/excel-worksheet-utils-EyvwNT4X.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./preload-helper-zJ_50EbN.js";import{u as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{n as a,r as o}from"./locale-store-GfSwnwIZ.js";import{Fl as s,Ml as c,Qi as l,aa as u,ia as d,lo as f,na as p,to as m}from"./index-
|
|
2
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./preload-helper-zJ_50EbN.js";import{u as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{n as a,r as o}from"./locale-store-GfSwnwIZ.js";import{Fl as s,Ml as c,Qi as l,aa as u,ia as d,lo as f,na as p,to as m}from"./index-DSydVlxZ.js";var h=e(t(),1),g=n();function _(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function v(){let{token:e}=i(),t=a(e=>e.language),n=t===`zh`?b:x,[v,S]=(0,h.useState)(null),[C,w]=(0,h.useState)(_),[T,E]=(0,h.useState)(!0),[D,O]=(0,h.useState)(null),k=(0,h.useMemo)(()=>{if(!v||!e||v.kind!==`file`)return null;let t=d(v.fileName,v.mimeType);return{id:`share:${e}:${v.fileName}`,context:`share`,fileName:v.fileName,mimeType:t,size:v.fileSize,type:p(v.fileName,t),source:{kind:`share`,token:e}}},[v,e]);(0,h.useEffect)(()=>{if(!e){O(n.invalidLink),E(!1);return}let t=!1;return(async()=>{try{E(!0),O(null),w(_());let i=await fetch(o(`/s/${encodeURIComponent(e)}/meta`));if(!i.ok){t||O(i.status===404?n.notFound:n.expired);return}let a=await i.json();if(t)return;if(S(a),!a.valid){O(n.expired);return}if(a.kind!==`file`)return;let s=d(a.fileName,a.mimeType),c=p(a.fileName,s),l=u(c),f=o(`/s/${encodeURIComponent(e)}?inline=1`);if(l===`text`){if(a.fileSize>5242880){O(n.tooLarge);return}let e=await fetch(f);if(!e.ok){O(n.expired);return}let r=await e.text();t||w({..._(),textContent:r});return}if(l===`binary`){if(a.fileSize>33554432){O(n.tooLarge);return}let e=await fetch(f);if(!e.ok){O(n.expired);return}let i=await e.arrayBuffer();if(t)return;if(c===`pptx`){let{processPptx:e}=await r(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(i,a.fileName),n=t.length>m;w({textContent:null,binaryBuffer:i,extractedText:n?t.slice(0,m):t,extractedTextTruncated:n});return}w({..._(),binaryBuffer:i})}}catch(e){t||O(e instanceof Error?e.message:String(e))}finally{t||E(!1)}})(),()=>{t=!0}},[e,n.expired,n.invalidLink,n.notFound,n.tooLarge]);let A=e?o(`/s/${encodeURIComponent(e)}?dl=1`):`#`,j=e?o(`/s/${encodeURIComponent(e)}?inline=1`):`#`;return(0,g.jsxs)(`div`,{className:`flex min-h-screen flex-col bg-surface-base`,children:[(0,g.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-edge px-4`,children:[(0,g.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:`#`}),(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v?(0,g.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:v.fileName,children:v.fileName}):T?(0,g.jsx)(f,{className:`h-4 w-48 max-w-full`}):(0,g.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:n.error}),v?(0,g.jsxs)(`div`,{className:`truncate text-xs text-fg-muted`,children:[y(v.fileSize),` · `,n.expiresAt,` `,new Date(v.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}):null]}),v?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`a`,{href:j,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[(0,g.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),n.openInline]}),(0,g.jsxs)(`a`,{href:A,className:`inline-flex items-center gap-1 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white hover:opacity-90`,download:v.fileName,children:[(0,g.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),n.download]})]}):null]}),(0,g.jsx)(`main`,{className:`flex min-h-0 w-full flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,children:T?(0,g.jsxs)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel p-4 shadow-surface`,"aria-busy":`true`,children:[(0,g.jsx)(f,{className:`h-5 w-56 max-w-full`}),(0,g.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,g.jsx)(f,{className:`h-4 w-full`}),(0,g.jsx)(f,{className:`h-4 w-11/12`}),(0,g.jsx)(f,{className:`h-4 w-10/12`}),(0,g.jsx)(f,{className:`h-4 w-3/4`})]}),(0,g.jsx)(f,{className:`mt-6 min-h-0 flex-1 rounded-lg`})]}):D?(0,g.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg`,children:[(0,g.jsx)(`p`,{className:`font-medium`,children:n.error}),(0,g.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:D})]}):v?.kind===`directory`?(0,g.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg-muted`,children:n.directoryHint}):k?(0,g.jsx)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:(0,g.jsx)(l,{language:t,descriptor:k,loading:!1,loadError:null,textContent:C.textContent,binaryBuffer:C.binaryBuffer,extractedText:C.extractedText,extractedTextTruncated:C.extractedTextTruncated,actions:{onDownload:()=>{window.location.href=A},canDownload:!0}})}):null})]})}function y(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}var b={error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,download:`下载`,openInline:`在新窗口打开`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`},x={error:`Failed to load`,expired:`Link no longer valid`,notFound:`Link not found`,invalidLink:`Invalid link`,expiresAt:`Expires`,download:`Download`,openInline:`Open raw`,directoryHint:`Directory shares are browsed from the main page.`,tooLarge:`This file is too large to preview here. Please download it instead.`};export{v as SharePreviewPage};
|
package/dist/gateway/static/root/assets/{shares-settings-DCuqr7js.js → shares-settings-DO3IIgcC.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./check-BODqo66o.js";import{t as s}from"./copy-to-clipboard-HOJ79TWv.js";import{t as c}from"./messages-B0B40tpO.js";import{l,n as u,r as d,s as f}from"./locale-store-GfSwnwIZ.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{Bi as m,Cs as h,El as g,Fi as _,Fo as v,Fs as y,Hi as b,Ii as x,Jr as S,Li as C,Lo as w,Mi as T,No as E,Nt as D,Pi as O,Po as k,Ri as A,Rl as j,Ro as M,Sl as N,Uc as P,Ul as F,Vi as I,Vr as L,Yo as R,Zo as z,ar as ee,au as te,co as ne,fc as re,lo as B,so as ie,ua as ae,vs as V,yc as oe,ys as H,zi as U,zo as se}from"./index-apLU0Hun.js";import{n as W,r as ce,t as le}from"./settings-page-layout-CsrLuDsW.js";import{t as G}from"./settings-form-section-DND90dDt.js";import{t as ue}from"./page-tabs-CJfk6M78.js";var K=e(t(),1),de=n(),q={enabled:!0,defaultTtlHours:24,maxTtlDays:7,maxActiveShares:100,maxActiveSites:5,maxFileSizeMb:100,inlinePreviewMimes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`application/pdf`,`text/html`,`text/markdown`,`text/plain`,`application/json`]},J=36e5,Y=864e5,fe=1048576;function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pe(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 me(e){let t=X(e)?e:{},n=X(t.gateway)?t.gateway:{},r=X(n.share)?n.share:{},i=X(n.siteShare)?n.siteShare:{},a=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):q.defaultTtlHours*J,o=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):q.maxTtlDays*Y,s=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):q.maxFileSizeMb*fe;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(a/J)),maxTtlDays:Math.max(1,Math.round(o/Y)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):q.maxActiveShares,maxActiveSites:typeof i.maxActiveSites==`number`&&Number.isFinite(i.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(i.maxActiveSites))):q.maxActiveSites,maxFileSizeMb:Math.max(1,Math.round(s/fe)),inlinePreviewMimes:pe(r.inlinePreviewMimes,32).length?pe(r.inlinePreviewMimes,32):[...q.inlinePreviewMimes]}}function he(e){let t=e.defaultTtlHours*J,n=e.maxTtlDays*Y;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.`:null}async function ge(e){let t=he(e);if(t)throw Error(t);await f(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*J,maxTtlMs:e.maxTtlDays*Y,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*fe,inlinePreviewMimes:e.inlinePreviewMimes},siteShare:{maxActiveSites:e.maxActiveSites}}})}),ie()}var Z=r();function _e(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,V,`dark:border-edge`)}function ve({hasToken:e}){let t=c(u(e=>e.language)).sharesSettings,{data:n,isLoading:r}=ne(e),i=(0,K.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(me(n.payload.config)),[n]),a=(0,K.useRef)(!1),[o,s]=(0,K.useState)(null),[l,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(!1),g=o??i,_=i,v=(0,K.useMemo)(()=>!g||!_?!1:JSON.stringify(g)!==JSON.stringify(_),[g,_]),y=(0,K.useCallback)(e=>{a.current=!0,s(t=>{let n=t??_;return n?{...n,...e}:null})},[_]),b=(0,K.useCallback)(async()=>{if(!(!g||l)){d(!0),p(null),h(!1);try{await ge(g),a.current=!1,s(null),h(!0),window.setTimeout(()=>h(!1),2500)}catch(e){p(e instanceof Error?e.message:t.policySaveError)}finally{d(!1)}}},[g,l,t.policySaveError]),x=(0,K.useCallback)(()=>{a.current=!1,s(null),p(null),h(!1)},[]);return!e||!g?r?(0,Z.jsx)(G,{children:(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,Z.jsx)(P,{className:`size-4 animate-spin`}),t.policyLoading]})}):null:(0,Z.jsxs)(G,{children:[(0,Z.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[m?(0,Z.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,Z.jsx)(H,{type:`button`,variant:`secondary`,disabled:!v||l,onClick:x,children:t.policyDiscard}),(0,Z.jsx)(H,{type:`button`,variant:`primary`,disabled:!v||l,onClick:()=>void b(),children:l?t.policySaving:t.policySave})]})]}),v?(0,Z.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,f?(0,Z.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:f}):null,(0,Z.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,Z.jsx)(ye,{t,form:g,onChange:y})]})}function ye(e){let t=(0,de.c)(64),{t:n,form:r,onChange:i}=e,a;t[0]===i?a=t[1]:(a=e=>i({enabled:e.target.checked}),t[0]=i,t[1]=a);let o;t[2]!==r.enabled||t[3]!==a?(o=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:a}),t[2]=r.enabled,t[3]=a,t[4]=o):o=t[4];let s;t[5]!==n.policyEnabled||t[6]!==o?(s=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[o,n.policyEnabled]}),t[5]=n.policyEnabled,t[6]=o,t[7]=s):s=t[7];let c=!r.enabled,l;t[8]===i?l=t[9]:(l=e=>i({defaultTtlHours:e}),t[8]=i,t[9]=l);let u;t[10]!==r.defaultTtlHours||t[11]!==n.policyDefaultTtlHint||t[12]!==n.policyDefaultTtlHours||t[13]!==c||t[14]!==l?(u=(0,Z.jsx)(Q,{id:`share-default-ttl-hours`,label:n.policyDefaultTtlHours,hint:n.policyDefaultTtlHint,value:r.defaultTtlHours,min:1,max:168,disabled:c,onChange:l}),t[10]=r.defaultTtlHours,t[11]=n.policyDefaultTtlHint,t[12]=n.policyDefaultTtlHours,t[13]=c,t[14]=l,t[15]=u):u=t[15];let d=!r.enabled,f;t[16]===i?f=t[17]:(f=e=>i({maxTtlDays:e}),t[16]=i,t[17]=f);let p;t[18]!==r.maxTtlDays||t[19]!==n.policyMaxTtlDays||t[20]!==n.policyMaxTtlHint||t[21]!==d||t[22]!==f?(p=(0,Z.jsx)(Q,{id:`share-max-ttl-days`,label:n.policyMaxTtlDays,hint:n.policyMaxTtlHint,value:r.maxTtlDays,min:1,max:30,disabled:d,onChange:f}),t[18]=r.maxTtlDays,t[19]=n.policyMaxTtlDays,t[20]=n.policyMaxTtlHint,t[21]=d,t[22]=f,t[23]=p):p=t[23];let m=!r.enabled,h;t[24]===i?h=t[25]:(h=e=>i({maxActiveShares:e}),t[24]=i,t[25]=h);let g;t[26]!==r.maxActiveShares||t[27]!==n.policyMaxActiveShares||t[28]!==n.policyMaxActiveSharesHint||t[29]!==m||t[30]!==h?(g=(0,Z.jsx)(Q,{id:`share-max-active`,label:n.policyMaxActiveShares,hint:n.policyMaxActiveSharesHint,value:r.maxActiveShares,min:1,max:1e4,disabled:m,onChange:h}),t[26]=r.maxActiveShares,t[27]=n.policyMaxActiveShares,t[28]=n.policyMaxActiveSharesHint,t[29]=m,t[30]=h,t[31]=g):g=t[31];let _;t[32]===i?_=t[33]:(_=e=>i({maxActiveSites:e}),t[32]=i,t[33]=_);let v;t[34]!==r.maxActiveSites||t[35]!==n.policyMaxActiveSites||t[36]!==n.policyMaxActiveSitesHint||t[37]!==_?(v=(0,Z.jsx)(Q,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,onChange:_}),t[34]=r.maxActiveSites,t[35]=n.policyMaxActiveSites,t[36]=n.policyMaxActiveSitesHint,t[37]=_,t[38]=v):v=t[38];let y=!r.enabled,b;t[39]===i?b=t[40]:(b=e=>i({maxFileSizeMb:e}),t[39]=i,t[40]=b);let x;t[41]!==r.maxFileSizeMb||t[42]!==n.policyMaxFileSizeHint||t[43]!==n.policyMaxFileSizeMb||t[44]!==y||t[45]!==b?(x=(0,Z.jsx)(Q,{id:`share-max-file-mb`,label:n.policyMaxFileSizeMb,hint:n.policyMaxFileSizeHint,value:r.maxFileSizeMb,min:1,max:10240,disabled:y,onChange:b}),t[41]=r.maxFileSizeMb,t[42]=n.policyMaxFileSizeHint,t[43]=n.policyMaxFileSizeMb,t[44]=y,t[45]=b,t[46]=x):x=t[46];let S;t[47]!==g||t[48]!==v||t[49]!==x||t[50]!==u||t[51]!==p?(S=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[u,p,g,v,x]}),t[47]=g,t[48]=v,t[49]=x,t[50]=u,t[51]=p,t[52]=S):S=t[52];let C=!r.enabled,w;t[53]===i?w=t[54]:(w=e=>i({inlinePreviewMimes:e}),t[53]=i,t[54]=w);let T;t[55]!==r.inlinePreviewMimes||t[56]!==n||t[57]!==C||t[58]!==w?(T=(0,Z.jsx)(be,{t:n,values:r.inlinePreviewMimes,disabled:C,onChange:w}),t[55]=r.inlinePreviewMimes,t[56]=n,t[57]=C,t[58]=w,t[59]=T):T=t[59];let E;return t[60]!==S||t[61]!==T||t[62]!==s?(E=(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[s,S,T]}),t[60]=S,t[61]=T,t[62]=s,t[63]=E):E=t[63],E}function Q(e){let t=(0,de.c)(21),{id:n,label:r,hint:i,value:o,min:s,max:c,disabled:l,onChange:u}=e,d;t[0]!==n||t[1]!==r?(d=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=d):d=t[2];let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=a(_e(),`max-w-xs font-mono text-xs`),t[3]=f):f=t[3];let p;t[4]!==c||t[5]!==s||t[6]!==u?(p=e=>{let t=Number(e.target.value);Number.isFinite(t)&&u(Math.max(s,Math.min(c,Math.floor(t))))},t[4]=c,t[5]=s,t[6]=u,t[7]=p):p=t[7];let m;t[8]!==l||t[9]!==n||t[10]!==c||t[11]!==s||t[12]!==p||t[13]!==o?(m=(0,Z.jsx)(`input`,{id:n,type:`number`,min:s,max:c,disabled:l,className:f,value:o,onChange:p}),t[8]=l,t[9]=n,t[10]=c,t[11]=s,t[12]=p,t[13]=o,t[14]=m):m=t[14];let h;t[15]===i?h=t[16]:(h=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=h);let g;return t[17]!==d||t[18]!==m||t[19]!==h?(g=(0,Z.jsxs)(`div`,{children:[d,m,h]}),t[17]=d,t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function be(e){let t=(0,de.c)(25),{t:n,values:r,disabled:i,onChange:o}=e,s;t[0]!==o||t[1]!==r?(s=e=>{let t=e.trim();!t||r.includes(t)||r.length>=32||o([...r,t])},t[0]=o,t[1]=r,t[2]=s):s=t[2];let c=s,l;t[3]===n.policyInlinePreviewMimes?l=t[4]:(l=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.policyInlinePreviewMimes}),t[3]=n.policyInlinePreviewMimes,t[4]=l);let u;t[5]===n.policyInlinePreviewMimesHint?u=t[6]:(u=(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.policyInlinePreviewMimesHint}),t[5]=n.policyInlinePreviewMimesHint,t[6]=u);let d;t[7]!==i||t[8]!==o||t[9]!==r?(d=r.map(e=>(0,Z.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,Z.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,"aria-label":`Remove ${e}`,onClick:()=>o(r.filter(t=>t!==e)),children:`×`})]},e)),t[7]=i,t[8]=o,t[9]=r,t[10]=d):d=t[10];let f;t[11]===d?f=t[12]:(f=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d}),t[11]=d,t[12]=f);let p;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(p=a(_e(),`font-mono text-xs`),t[13]=p):p=t[13];let m=i||r.length>=32,h;t[14]===c?h=t[15]:(h=e=>{e.key===`Enter`&&(e.preventDefault(),c(e.target.value),e.target.value=``)},t[14]=c,t[15]=h);let g;t[16]!==n.policyMimePlaceholder||t[17]!==m||t[18]!==h?(g=(0,Z.jsx)(`input`,{className:p,placeholder:n.policyMimePlaceholder,disabled:m,onKeyDown:h}),t[16]=n.policyMimePlaceholder,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==l||t[21]!==u||t[22]!==f||t[23]!==g?(_=(0,Z.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[l,u,f,g]}),t[20]=l,t[21]=u,t[22]=f,t[23]=g,t[24]=_):_=t[24],_}function xe(e){let t=(0,de.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:o,selectKind:s,sessionKey:d,agentId:f}=e,m=s===void 0?`any`:s,g=c(u(we)),_=g.workspace,y=g.sharesSettings,b=T(Ce),{data:x}=p(l(Se)?`picker-agents-list`:null,S),C;bb0:{let e;t[0]===f?e=t[1]:(e=f?.trim(),t[0]=f,t[1]=e);let n=e;if(n){C=n;break bb0}let r;t[2]===b?r=t[3]:(r=b.trim(),t[2]=b,t[3]=r);let i=r;if(i){C=i;break bb0}if(x?.defaultId){C=x.defaultId;break bb0}if(x?.agents?.[0]?.id){C=x.agents[0].id;break bb0}C=``}let D=C,[A,j]=(0,K.useState)(D),F,I;t[4]===D?(F=t[5],I=t[6]):(F=()=>{j(D)},I=[D],t[4]=D,t[5]=F,t[6]=I),(0,K.useEffect)(F,I);let{tree:ee,loading:te,error:ne,loadRoot:B,loadChildren:ie,reset:V}=O(A,d??null),oe;t[7]===o?oe=t[8]:(oe=o?{path:o,isDirectory:!1}:null,t[7]=o,t[8]=oe);let[U,W]=(0,K.useState)(oe),ce;t[9]!==o||t[10]!==B||t[11]!==n||t[12]!==V||t[13]!==W?(ce=()=>{if(!n){V(),W(o?{path:o,isDirectory:!1}:null);return}B()},t[9]=o,t[10]=B,t[11]=n,t[12]=V,t[13]=W,t[14]=ce):ce=t[14];let le;t[15]!==o||t[16]!==B||t[17]!==n||t[18]!==A||t[19]!==V||t[20]!==d?(le=[n,A,d,B,V,o],t[15]=o,t[16]=B,t[17]=n,t[18]=A,t[19]=V,t[20]=d,t[21]=le):le=t[21],(0,K.useEffect)(ce,le);let G;t[22]===ie?G=t[23]:(G=e=>{ie(e)},t[22]=ie,t[23]=G);let ue=G,q=U!==null&&(m===`any`||m===`file`&&!U.isDirectory||m===`directory`&&U.isDirectory),J;bb1:{if(!U){J=y.pickerHintNone;break bb1}if(m===`file`&&U.isDirectory){J=y.pickerHintNeedsFile;break bb1}if(m===`directory`&&!U.isDirectory){J=y.pickerHintNeedsDirectory;break bb1}J=`${U.isDirectory?`📁`:`📄`} ${U.path}`}let Y=J,fe=x?.agents??[],X;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Z.jsx)(w,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=X):X=t[24];let pe;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(pe=a(`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]=pe):pe=t[25];let me;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,Z.jsx)(N,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=me):me=t[26];let he=g.cron.refresh,ge=g.cron.refresh,_e;t[27]===B?_e=t[28]:(_e=()=>void B(),t[27]=B,t[28]=_e);let ve=te&&`animate-spin`,ye;t[29]===ve?ye=t[30]:(ye=a(`size-4`,ve),t[29]=ve,t[30]=ye);let Q;t[31]===ye?Q=t[32]:(Q=(0,Z.jsx)(re,{className:ye,"aria-hidden":!0}),t[31]=ye,t[32]=Q);let be;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Z.jsx)(h,{className:`size-4`}),t[33]=be):be=t[33];let xe;t[34]!==ne||t[35]!==_.loadError?(xe=ne?(0,Z.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[_.loadError,`: `,ne]}):null,t[34]=ne,t[35]=_.loadError,t[36]=xe):xe=t[36];let $;t[37]!==ue||t[38]!==te||t[39]!==U?.path||t[40]!==W||t[41]!==_.emptyDir||t[42]!==_.title||t[43]!==ee?($=te&&ee.length===0?(0,Z.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,Z.jsx)(P,{className:`size-4 animate-spin`}),_.title,`…`]}):(0,Z.jsx)(ae,{tree:ee,selectedPath:U?.path??null,onSelectFile:e=>W({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>W({path:e,isDirectory:t}),onExpandDir:ue,onAction:void 0,emptyHint:_.emptyDir}),t[37]=ue,t[38]=te,t[39]=U?.path,t[40]=W,t[41]=_.emptyDir,t[42]=_.title,t[43]=ee,t[44]=$):$=t[44];let Te;t[45]!==xe||t[46]!==$?(Te=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[xe,$]}),t[45]=xe,t[46]=$,t[47]=Te):Te=t[47];let Ee;t[48]===Y?Ee=t[49]:(Ee=(0,Z.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:Y}),t[48]=Y,t[49]=Ee);let De;t[50]===r?De=t[51]:(De=()=>r(!1),t[50]=r,t[51]=De);let Oe;t[52]!==y.cancel||t[53]!==De?(Oe=(0,Z.jsx)(H,{type:`button`,variant:`ghost`,onClick:De,children:y.cancel}),t[52]=y.cancel,t[53]=De,t[54]=Oe):Oe=t[54];let ke=!q,Ae;t[55]!==i||t[56]!==r||t[57]!==A||t[58]!==U?(Ae=()=>{U&&(i({...U,agentId:A}),r(!1))},t[55]=i,t[56]=r,t[57]=A,t[58]=U,t[59]=Ae):Ae=t[59];let je;t[60]!==y.pickerConfirm||t[61]!==ke||t[62]!==Ae?(je=(0,Z.jsx)(H,{type:`button`,disabled:ke,onClick:Ae,children:y.pickerConfirm}),t[60]=y.pickerConfirm,t[61]=ke,t[62]=Ae,t[63]=je):je=t[63];let Me;t[64]!==Oe||t[65]!==je?(Me=(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Oe,je]}),t[64]=Oe,t[65]=je,t[66]=Me):Me=t[66];let Ne;return t[67]!==Ee||t[68]!==Me?(Ne=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[Ee,Me]}),t[67]=Ee,t[68]=Me,t[69]=Ne):Ne=t[69],(0,Z.jsx)(E,{open:n,onOpenChange:r,children:(0,Z.jsxs)(M,{children:[X,(0,Z.jsxs)(v,{className:pe,children:[(0,Z.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[me,(0,Z.jsx)(se,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:y.pickerTitle}),(0,Z.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:he,"aria-label":ge,disabled:te,onClick:_e,children:Q}),(0,Z.jsx)(k,{asChild:!0,children:(0,Z.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":_.close,children:be})})]}),fe.length>0?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,Z.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:y.pickerAgentLabel}),(0,Z.jsx)(R,{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:A,onChange:e=>{j(e.target.value),W(null)},children:fe.map(e=>(0,Z.jsxs)(z,{value:e.id,children:[L(e,g.agentsSettings),e.id===x?.defaultId?` ★`:``]},e.id))})]}):null,Te,Ne]})]})})}function Se(e){return e.token}function Ce(e){return e.agentId}function we(e){return e.language}var $=[`shares`,`policy`];function Te(e){let t=(e??``).trim();return $.includes(t)?t:`shares`}function Ee(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 De(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 Oe=[{value:36e5,key:`1h`},{value:216e5,key:`6h`},{value:864e5,key:`24h`},{value:2592e5,key:`3d`},{value:6048e5,key:`7d`}];function ke(){let e=(0,de.c)(24),t=u(je),n=c(t).sharesSettings,r=!!l(Ae),[a,o]=i(),s;e[0]===a?s=e[1]:(s=Te(a.get(`tab`)),e[0]=a,e[1]=s);let d=s,f;e[2]===o?f=e[3]:(f=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]=f);let p=f;if(!r)return(0,Z.jsx)(ce,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let m={shares:n.tabShares,policy:n.tabPolicy},h=$.map(e=>({id:e,label:m[e]})),g;e[4]!==n.subtitle||e[5]!==n.title?(g=(0,Z.jsx)(W,{title:n.title,subtitle:n.subtitle}),e[4]=n.subtitle,e[5]=n.title,e[6]=g):g=e[6];let _;e[7]!==d||e[8]!==p||e[9]!==n.tabsAria||e[10]!==h?(_=(0,Z.jsx)(ue,{items:h,activeTab:d,onChange:p,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[7]=d,e[8]=p,e[9]=n.tabsAria,e[10]=h,e[11]=_):_=e[11];let v;e[12]!==d||e[13]!==r||e[14]!==t||e[15]!==n?(v=d===`shares`?(0,Z.jsx)(Me,{t:n,language:t}):(0,Z.jsx)(ve,{hasToken:r}),e[12]=d,e[13]=r,e[14]=t,e[15]=n,e[16]=v):v=e[16];let y;e[17]!==d||e[18]!==v?(y=(0,Z.jsx)(le,{id:d,activeTab:d,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:v}),e[17]=d,e[18]=v,e[19]=y):y=e[19];let b;return e[20]!==g||e[21]!==_||e[22]!==y?(b=(0,Z.jsxs)(ce,{children:[g,_,y]}),e[20]=g,e[21]=_,e[22]=y,e[23]=b):b=e[23],b}function Ae(e){return e.token}function je(e){return e.language}function Me(e){let t=(0,de.c)(60),{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:o,error:s,isLoading:c,mutate:l}=p(`shares-list`,A,i),u;t[1]===o?.payload?.shares?u=t[2]:(u=o?.payload?.shares??[],t[1]=o?.payload?.shares,t[2]=u);let d=u,[f,m]=(0,K.useState)(!1),h;bb0:{if(f){h=d;break bb0}let e;t[3]===d?e=t[4]:(e=d.filter(Le),t[3]=d,t[4]=e),h=e}let g=h,_;t[5]===d?_=t[6]:(_=d.filter(Ie),t[5]=d,t[6]=_);let v=_.length,y;t[7]===d?y=t[8]:(y=d.filter(Fe),t[7]=d,t[8]=y);let b=y.length,x;t[9]===l?x=t[10]:(x=()=>void l(),t[9]=l,t[10]=x);let S;t[11]!==n||t[12]!==x?(S=(0,Z.jsx)(ze,{t:n,onCreated:x}),t[11]=n,t[12]=x,t[13]=S):S=t[13];let C=f?n.allSharesTitle:n.listTitle,w;t[14]===v?w=t[15]:(w=v>0&&(0,Z.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,v,`)`]}),t[14]=v,t[15]=w);let T;t[16]!==C||t[17]!==w?(T=(0,Z.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[C,w]}),t[16]=C,t[17]=w,t[18]=T):T=t[18];let E;t[19]===l?E=t[20]:(E=()=>void l(),t[19]=l,t[20]=E);let D=c&&`animate-spin`,O;t[21]===D?O=t[22]:(O=a(`size-3.5`,D),t[21]=D,t[22]=O);let k;t[23]===O?k=t[24]:(k=(0,Z.jsx)(re,{className:O}),t[23]=O,t[24]=k);let j;t[25]!==c||t[26]!==E||t[27]!==k?(j=(0,Z.jsx)(H,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:E,disabled:c,children:k}),t[25]=c,t[26]=E,t[27]=k,t[28]=j):j=t[28];let M;t[29]!==b||t[30]!==f||t[31]!==n.hideExpired||t[32]!==n.showExpired?(M=b>0&&(0,Z.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>m(Pe),children:f?n.hideExpired:n.showExpired}),t[29]=b,t[30]=f,t[31]=n.hideExpired,t[32]=n.showExpired,t[33]=M):M=t[33];let N;t[34]!==j||t[35]!==M?(N=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[j,M]}),t[34]=j,t[35]=M,t[36]=N):N=t[36];let P;t[37]!==T||t[38]!==N?(P=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[T,N]}),t[37]=T,t[38]=N,t[39]=P):P=t[39];let F;t[40]!==o||t[41]!==s||t[42]!==g||t[43]!==c||t[44]!==r||t[45]!==l||t[46]!==n?(F=c&&!o?(0,Z.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(Ne)}):s?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,Z.jsx)(`span`,{children:n.error}),(0,Z.jsx)(H,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void l(),children:n.retry})]}):g.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map(e=>(0,Z.jsx)(Ve,{share:e,t:n,language:r,onRevoked:()=>void l(),onExtended:()=>void l()},e.id))}),t[40]=o,t[41]=s,t[42]=g,t[43]=c,t[44]=r,t[45]=l,t[46]=n,t[47]=F):F=t[47];let I;t[48]!==b||t[49]!==l||t[50]!==f||t[51]!==n?(I=b>0&&f&&(0,Z.jsx)(He,{t:n,onCleaned:()=>void l()}),t[48]=b,t[49]=l,t[50]=f,t[51]=n,t[52]=I):I=t[52];let L;t[53]!==P||t[54]!==F||t[55]!==I?(L=(0,Z.jsxs)(G,{children:[P,F,I]}),t[53]=P,t[54]=F,t[55]=I,t[56]=L):L=t[56];let R;return t[57]!==L||t[58]!==S?(R=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[S,L]}),t[57]=L,t[58]=S,t[59]=R):R=t[59],R}function Ne(e,t){return(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(B,{className:`h-4 w-2/3`}),(0,Z.jsx)(B,{className:`mt-2 h-3 w-1/2`})]}),(0,Z.jsx)(B,{className:`h-7 w-20 rounded-md`})]})},t)}function Pe(e){return!e}function Fe(e){return e.expired||e.revoked}function Ie(e){return!e.expired&&!e.revoked}function Le(e){return!e.expired&&!e.revoked}var Re={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function ze({t:e,onCreated:t}){let[n,r]=(0,K.useReducer)(D,Re),{expanded:i,path:o,isDirectory:s,agentId:c,ttlMs:l,maxViews:u,description:d,directoryMode:f,creating:p,result:m,errorMsg:h,resultDialogOpen:_,pickerOpen:v}=n,y=(0,K.useCallback)(async()=>{if(o.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await x({path:o.trim(),ttlMs:l,maxViews:u,description:d.trim()||void 0,...c?{agentId:c}:{},...s?{kind:`directory`,directoryMode:f}:{}})).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}})}}},[o,s,c,l,u,d,f,t]),b=(0,K.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,Z.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:a(`flex min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm`,o?`text-fg`:`text-fg-subtle`),children:o?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:s?`📁`:`📄`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:o,children:o})]}):(0,Z.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,Z.jsxs)(H,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,Z.jsx)(g,{className:`size-4`}),o?e.pathBrowseChange:e.pathBrowse]})]})]}),s?(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,Z.jsxs)(R,{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:f,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,Z.jsx)(z,{value:`browse`,children:e.directoryModeBrowse}),(0,Z.jsx)(z,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,Z.jsx)(R,{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,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:Oe.map(t=>(0,Z.jsx)(z,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,Z.jsxs)(R,{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:u??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,Z.jsx)(z,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,Z.jsx)(z,{value:`1`,children:`1`}),(0,Z.jsx)(z,{value:`5`,children:`5`}),(0,Z.jsx)(z,{value:`10`,children:`10`}),(0,Z.jsx)(z,{value:`50`,children:`50`}),(0,Z.jsx)(z,{value:`100`,children:`100`})]})]})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,Z.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:d,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Z.jsxs)(H,{type:`button`,disabled:p||!o.trim(),onClick:()=>void y(),children:[p?(0,Z.jsx)(P,{className:`size-4 animate-spin`}):(0,Z.jsx)(oe,{className:`size-4`}),p?e.creating:e.createButton]}),(0,Z.jsx)(H,{type:`button`,variant:`ghost`,onClick:()=>{b(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),h&&(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h})]}),(0,Z.jsx)(I,{open:_,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:m}),(0,Z.jsx)(xe,{open:v,onOpenChange:e=>r({type:`patch`,patch:{pickerOpen:e}}),initialPath:o||void 0,selectKind:`any`,onConfirm:e=>r({type:`patch`,patch:{path:e.path,isDirectory:e.isDirectory,agentId:e.agentId,directoryMode:`browse`}})})]}):(0,Z.jsxs)(H,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,Z.jsx)(oe,{className:`size-4`}),e.createTitle]})}var Be={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function Ve({share:e,t,language:n,onRevoked:r,onExtended:i}){let[c,l]=(0,K.useReducer)(D,Be),{revokeOpen:u,revoking:d,linksOpen:f,urlCopied:p,copyFailed:h,extending:_}=c,v=!e.expired&&!e.revoked,x=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,S=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,w=(0,K.useCallback)(async()=>{l({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await U(e.id),r()}catch{}finally{l({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),T=(0,K.useCallback)(async()=>{if(l({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await s(e.shareUrl)){l({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>l({type:`patch`,patch:{copyFailed:!1}}),2500);return}l({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>l({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),E=(0,K.useCallback)(async()=>{l({type:`patch`,patch:{extending:!0}});try{await C(e.id,864e5),i()}catch{}finally{l({type:`patch`,patch:{extending:!1}})}},[e.id,i]),O=`share-links-${e.id}`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:a(`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":f,"aria-controls":O,onClick:()=>l({type:`patch`,patch:{linksOpen:!f}}),children:[(0,Z.jsx)(te,{className:a(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,f?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),(0,Z.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,Z.jsx)(`span`,{className:a(`text-xs font-medium`,S),children:x})]}),(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.workspaceRelativePath}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:Ee(e.fileSize)}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(F,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:De(e.expiresAt,n)]}),(0,Z.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,Z.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:v&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(H,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void T(),children:p?(0,Z.jsx)(o,{className:`size-3.5 text-emerald-500`}):(0,Z.jsx)(j,{className:`size-3.5`})}),(0,Z.jsx)(H,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void E(),disabled:_,title:t.extend,children:_?(0,Z.jsx)(P,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(F,{className:`size-3.5`})}),(0,Z.jsx)(H,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>l({type:`patch`,patch:{revokeOpen:!0}}),disabled:d,children:d?(0,Z.jsx)(P,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(y,{className:`size-3.5`})})]})})]}),v&&f?(0,Z.jsxs)(`div`,{id:O,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,Z.jsx)(b,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),h?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(m,{reachability:e.reachability})})]}):null]}),(0,Z.jsx)(ee,{open:u,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void w(),onCancel:()=>l({type:`patch`,patch:{revokeOpen:!1}})})]})}function He({t:e,onCleaned:t}){let[n,r]=(0,K.useState)(!1),[i,a]=(0,K.useState)(!1),o=(0,K.useCallback)(async()=>{r(!1),a(!0);try{await _(),t()}catch{}finally{a(!1)}},[t]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(H,{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,Z.jsx)(P,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(y,{className:`size-3.5`}),e.cleanExpired]})}),(0,Z.jsx)(ee,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{ke as SharesSettingsPanel};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./check-BODqo66o.js";import{t as s}from"./copy-to-clipboard-HOJ79TWv.js";import{t as c}from"./messages-B0B40tpO.js";import{l,n as u,r as d,s as f}from"./locale-store-GfSwnwIZ.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{Bi as m,Cs as h,El as g,Fi as _,Fo as v,Fs as y,Hi as b,Ii as x,Jr as S,Li as C,Lo as w,Mi as T,No as E,Nt as D,Pi as O,Po as k,Ri as A,Rl as j,Ro as M,Sl as N,Uc as P,Ul as F,Vi as I,Vr as L,Yo as R,Zo as z,ar as ee,au as te,co as ne,fc as re,lo as B,so as ie,ua as ae,vs as V,yc as oe,ys as H,zi as U,zo as se}from"./index-DSydVlxZ.js";import{n as W,r as ce,t as le}from"./settings-page-layout-B_-VepeK.js";import{t as G}from"./settings-form-section-DPSA8tG8.js";import{t as ue}from"./page-tabs-HACawonJ.js";var K=e(t(),1),de=n(),q={enabled:!0,defaultTtlHours:24,maxTtlDays:7,maxActiveShares:100,maxActiveSites:5,maxFileSizeMb:100,inlinePreviewMimes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`application/pdf`,`text/html`,`text/markdown`,`text/plain`,`application/json`]},J=36e5,Y=864e5,fe=1048576;function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pe(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 me(e){let t=X(e)?e:{},n=X(t.gateway)?t.gateway:{},r=X(n.share)?n.share:{},i=X(n.siteShare)?n.siteShare:{},a=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):q.defaultTtlHours*J,o=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):q.maxTtlDays*Y,s=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):q.maxFileSizeMb*fe;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(a/J)),maxTtlDays:Math.max(1,Math.round(o/Y)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):q.maxActiveShares,maxActiveSites:typeof i.maxActiveSites==`number`&&Number.isFinite(i.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(i.maxActiveSites))):q.maxActiveSites,maxFileSizeMb:Math.max(1,Math.round(s/fe)),inlinePreviewMimes:pe(r.inlinePreviewMimes,32).length?pe(r.inlinePreviewMimes,32):[...q.inlinePreviewMimes]}}function he(e){let t=e.defaultTtlHours*J,n=e.maxTtlDays*Y;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.`:null}async function ge(e){let t=he(e);if(t)throw Error(t);await f(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*J,maxTtlMs:e.maxTtlDays*Y,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*fe,inlinePreviewMimes:e.inlinePreviewMimes},siteShare:{maxActiveSites:e.maxActiveSites}}})}),ie()}var Z=r();function _e(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,V,`dark:border-edge`)}function ve({hasToken:e}){let t=c(u(e=>e.language)).sharesSettings,{data:n,isLoading:r}=ne(e),i=(0,K.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(me(n.payload.config)),[n]),a=(0,K.useRef)(!1),[o,s]=(0,K.useState)(null),[l,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(!1),g=o??i,_=i,v=(0,K.useMemo)(()=>!g||!_?!1:JSON.stringify(g)!==JSON.stringify(_),[g,_]),y=(0,K.useCallback)(e=>{a.current=!0,s(t=>{let n=t??_;return n?{...n,...e}:null})},[_]),b=(0,K.useCallback)(async()=>{if(!(!g||l)){d(!0),p(null),h(!1);try{await ge(g),a.current=!1,s(null),h(!0),window.setTimeout(()=>h(!1),2500)}catch(e){p(e instanceof Error?e.message:t.policySaveError)}finally{d(!1)}}},[g,l,t.policySaveError]),x=(0,K.useCallback)(()=>{a.current=!1,s(null),p(null),h(!1)},[]);return!e||!g?r?(0,Z.jsx)(G,{children:(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,Z.jsx)(P,{className:`size-4 animate-spin`}),t.policyLoading]})}):null:(0,Z.jsxs)(G,{children:[(0,Z.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[m?(0,Z.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,Z.jsx)(H,{type:`button`,variant:`secondary`,disabled:!v||l,onClick:x,children:t.policyDiscard}),(0,Z.jsx)(H,{type:`button`,variant:`primary`,disabled:!v||l,onClick:()=>void b(),children:l?t.policySaving:t.policySave})]})]}),v?(0,Z.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,f?(0,Z.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:f}):null,(0,Z.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,Z.jsx)(ye,{t,form:g,onChange:y})]})}function ye(e){let t=(0,de.c)(64),{t:n,form:r,onChange:i}=e,a;t[0]===i?a=t[1]:(a=e=>i({enabled:e.target.checked}),t[0]=i,t[1]=a);let o;t[2]!==r.enabled||t[3]!==a?(o=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:a}),t[2]=r.enabled,t[3]=a,t[4]=o):o=t[4];let s;t[5]!==n.policyEnabled||t[6]!==o?(s=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[o,n.policyEnabled]}),t[5]=n.policyEnabled,t[6]=o,t[7]=s):s=t[7];let c=!r.enabled,l;t[8]===i?l=t[9]:(l=e=>i({defaultTtlHours:e}),t[8]=i,t[9]=l);let u;t[10]!==r.defaultTtlHours||t[11]!==n.policyDefaultTtlHint||t[12]!==n.policyDefaultTtlHours||t[13]!==c||t[14]!==l?(u=(0,Z.jsx)(Q,{id:`share-default-ttl-hours`,label:n.policyDefaultTtlHours,hint:n.policyDefaultTtlHint,value:r.defaultTtlHours,min:1,max:168,disabled:c,onChange:l}),t[10]=r.defaultTtlHours,t[11]=n.policyDefaultTtlHint,t[12]=n.policyDefaultTtlHours,t[13]=c,t[14]=l,t[15]=u):u=t[15];let d=!r.enabled,f;t[16]===i?f=t[17]:(f=e=>i({maxTtlDays:e}),t[16]=i,t[17]=f);let p;t[18]!==r.maxTtlDays||t[19]!==n.policyMaxTtlDays||t[20]!==n.policyMaxTtlHint||t[21]!==d||t[22]!==f?(p=(0,Z.jsx)(Q,{id:`share-max-ttl-days`,label:n.policyMaxTtlDays,hint:n.policyMaxTtlHint,value:r.maxTtlDays,min:1,max:30,disabled:d,onChange:f}),t[18]=r.maxTtlDays,t[19]=n.policyMaxTtlDays,t[20]=n.policyMaxTtlHint,t[21]=d,t[22]=f,t[23]=p):p=t[23];let m=!r.enabled,h;t[24]===i?h=t[25]:(h=e=>i({maxActiveShares:e}),t[24]=i,t[25]=h);let g;t[26]!==r.maxActiveShares||t[27]!==n.policyMaxActiveShares||t[28]!==n.policyMaxActiveSharesHint||t[29]!==m||t[30]!==h?(g=(0,Z.jsx)(Q,{id:`share-max-active`,label:n.policyMaxActiveShares,hint:n.policyMaxActiveSharesHint,value:r.maxActiveShares,min:1,max:1e4,disabled:m,onChange:h}),t[26]=r.maxActiveShares,t[27]=n.policyMaxActiveShares,t[28]=n.policyMaxActiveSharesHint,t[29]=m,t[30]=h,t[31]=g):g=t[31];let _;t[32]===i?_=t[33]:(_=e=>i({maxActiveSites:e}),t[32]=i,t[33]=_);let v;t[34]!==r.maxActiveSites||t[35]!==n.policyMaxActiveSites||t[36]!==n.policyMaxActiveSitesHint||t[37]!==_?(v=(0,Z.jsx)(Q,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,onChange:_}),t[34]=r.maxActiveSites,t[35]=n.policyMaxActiveSites,t[36]=n.policyMaxActiveSitesHint,t[37]=_,t[38]=v):v=t[38];let y=!r.enabled,b;t[39]===i?b=t[40]:(b=e=>i({maxFileSizeMb:e}),t[39]=i,t[40]=b);let x;t[41]!==r.maxFileSizeMb||t[42]!==n.policyMaxFileSizeHint||t[43]!==n.policyMaxFileSizeMb||t[44]!==y||t[45]!==b?(x=(0,Z.jsx)(Q,{id:`share-max-file-mb`,label:n.policyMaxFileSizeMb,hint:n.policyMaxFileSizeHint,value:r.maxFileSizeMb,min:1,max:10240,disabled:y,onChange:b}),t[41]=r.maxFileSizeMb,t[42]=n.policyMaxFileSizeHint,t[43]=n.policyMaxFileSizeMb,t[44]=y,t[45]=b,t[46]=x):x=t[46];let S;t[47]!==g||t[48]!==v||t[49]!==x||t[50]!==u||t[51]!==p?(S=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[u,p,g,v,x]}),t[47]=g,t[48]=v,t[49]=x,t[50]=u,t[51]=p,t[52]=S):S=t[52];let C=!r.enabled,w;t[53]===i?w=t[54]:(w=e=>i({inlinePreviewMimes:e}),t[53]=i,t[54]=w);let T;t[55]!==r.inlinePreviewMimes||t[56]!==n||t[57]!==C||t[58]!==w?(T=(0,Z.jsx)(be,{t:n,values:r.inlinePreviewMimes,disabled:C,onChange:w}),t[55]=r.inlinePreviewMimes,t[56]=n,t[57]=C,t[58]=w,t[59]=T):T=t[59];let E;return t[60]!==S||t[61]!==T||t[62]!==s?(E=(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[s,S,T]}),t[60]=S,t[61]=T,t[62]=s,t[63]=E):E=t[63],E}function Q(e){let t=(0,de.c)(21),{id:n,label:r,hint:i,value:o,min:s,max:c,disabled:l,onChange:u}=e,d;t[0]!==n||t[1]!==r?(d=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=d):d=t[2];let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=a(_e(),`max-w-xs font-mono text-xs`),t[3]=f):f=t[3];let p;t[4]!==c||t[5]!==s||t[6]!==u?(p=e=>{let t=Number(e.target.value);Number.isFinite(t)&&u(Math.max(s,Math.min(c,Math.floor(t))))},t[4]=c,t[5]=s,t[6]=u,t[7]=p):p=t[7];let m;t[8]!==l||t[9]!==n||t[10]!==c||t[11]!==s||t[12]!==p||t[13]!==o?(m=(0,Z.jsx)(`input`,{id:n,type:`number`,min:s,max:c,disabled:l,className:f,value:o,onChange:p}),t[8]=l,t[9]=n,t[10]=c,t[11]=s,t[12]=p,t[13]=o,t[14]=m):m=t[14];let h;t[15]===i?h=t[16]:(h=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=h);let g;return t[17]!==d||t[18]!==m||t[19]!==h?(g=(0,Z.jsxs)(`div`,{children:[d,m,h]}),t[17]=d,t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function be(e){let t=(0,de.c)(25),{t:n,values:r,disabled:i,onChange:o}=e,s;t[0]!==o||t[1]!==r?(s=e=>{let t=e.trim();!t||r.includes(t)||r.length>=32||o([...r,t])},t[0]=o,t[1]=r,t[2]=s):s=t[2];let c=s,l;t[3]===n.policyInlinePreviewMimes?l=t[4]:(l=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.policyInlinePreviewMimes}),t[3]=n.policyInlinePreviewMimes,t[4]=l);let u;t[5]===n.policyInlinePreviewMimesHint?u=t[6]:(u=(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.policyInlinePreviewMimesHint}),t[5]=n.policyInlinePreviewMimesHint,t[6]=u);let d;t[7]!==i||t[8]!==o||t[9]!==r?(d=r.map(e=>(0,Z.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,Z.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,"aria-label":`Remove ${e}`,onClick:()=>o(r.filter(t=>t!==e)),children:`×`})]},e)),t[7]=i,t[8]=o,t[9]=r,t[10]=d):d=t[10];let f;t[11]===d?f=t[12]:(f=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d}),t[11]=d,t[12]=f);let p;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(p=a(_e(),`font-mono text-xs`),t[13]=p):p=t[13];let m=i||r.length>=32,h;t[14]===c?h=t[15]:(h=e=>{e.key===`Enter`&&(e.preventDefault(),c(e.target.value),e.target.value=``)},t[14]=c,t[15]=h);let g;t[16]!==n.policyMimePlaceholder||t[17]!==m||t[18]!==h?(g=(0,Z.jsx)(`input`,{className:p,placeholder:n.policyMimePlaceholder,disabled:m,onKeyDown:h}),t[16]=n.policyMimePlaceholder,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==l||t[21]!==u||t[22]!==f||t[23]!==g?(_=(0,Z.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[l,u,f,g]}),t[20]=l,t[21]=u,t[22]=f,t[23]=g,t[24]=_):_=t[24],_}function xe(e){let t=(0,de.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:o,selectKind:s,sessionKey:d,agentId:f}=e,m=s===void 0?`any`:s,g=c(u(we)),_=g.workspace,y=g.sharesSettings,b=T(Ce),{data:x}=p(l(Se)?`picker-agents-list`:null,S),C;bb0:{let e;t[0]===f?e=t[1]:(e=f?.trim(),t[0]=f,t[1]=e);let n=e;if(n){C=n;break bb0}let r;t[2]===b?r=t[3]:(r=b.trim(),t[2]=b,t[3]=r);let i=r;if(i){C=i;break bb0}if(x?.defaultId){C=x.defaultId;break bb0}if(x?.agents?.[0]?.id){C=x.agents[0].id;break bb0}C=``}let D=C,[A,j]=(0,K.useState)(D),F,I;t[4]===D?(F=t[5],I=t[6]):(F=()=>{j(D)},I=[D],t[4]=D,t[5]=F,t[6]=I),(0,K.useEffect)(F,I);let{tree:ee,loading:te,error:ne,loadRoot:B,loadChildren:ie,reset:V}=O(A,d??null),oe;t[7]===o?oe=t[8]:(oe=o?{path:o,isDirectory:!1}:null,t[7]=o,t[8]=oe);let[U,W]=(0,K.useState)(oe),ce;t[9]!==o||t[10]!==B||t[11]!==n||t[12]!==V||t[13]!==W?(ce=()=>{if(!n){V(),W(o?{path:o,isDirectory:!1}:null);return}B()},t[9]=o,t[10]=B,t[11]=n,t[12]=V,t[13]=W,t[14]=ce):ce=t[14];let le;t[15]!==o||t[16]!==B||t[17]!==n||t[18]!==A||t[19]!==V||t[20]!==d?(le=[n,A,d,B,V,o],t[15]=o,t[16]=B,t[17]=n,t[18]=A,t[19]=V,t[20]=d,t[21]=le):le=t[21],(0,K.useEffect)(ce,le);let G;t[22]===ie?G=t[23]:(G=e=>{ie(e)},t[22]=ie,t[23]=G);let ue=G,q=U!==null&&(m===`any`||m===`file`&&!U.isDirectory||m===`directory`&&U.isDirectory),J;bb1:{if(!U){J=y.pickerHintNone;break bb1}if(m===`file`&&U.isDirectory){J=y.pickerHintNeedsFile;break bb1}if(m===`directory`&&!U.isDirectory){J=y.pickerHintNeedsDirectory;break bb1}J=`${U.isDirectory?`📁`:`📄`} ${U.path}`}let Y=J,fe=x?.agents??[],X;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Z.jsx)(w,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=X):X=t[24];let pe;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(pe=a(`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]=pe):pe=t[25];let me;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,Z.jsx)(N,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=me):me=t[26];let he=g.cron.refresh,ge=g.cron.refresh,_e;t[27]===B?_e=t[28]:(_e=()=>void B(),t[27]=B,t[28]=_e);let ve=te&&`animate-spin`,ye;t[29]===ve?ye=t[30]:(ye=a(`size-4`,ve),t[29]=ve,t[30]=ye);let Q;t[31]===ye?Q=t[32]:(Q=(0,Z.jsx)(re,{className:ye,"aria-hidden":!0}),t[31]=ye,t[32]=Q);let be;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Z.jsx)(h,{className:`size-4`}),t[33]=be):be=t[33];let xe;t[34]!==ne||t[35]!==_.loadError?(xe=ne?(0,Z.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[_.loadError,`: `,ne]}):null,t[34]=ne,t[35]=_.loadError,t[36]=xe):xe=t[36];let $;t[37]!==ue||t[38]!==te||t[39]!==U?.path||t[40]!==W||t[41]!==_.emptyDir||t[42]!==_.title||t[43]!==ee?($=te&&ee.length===0?(0,Z.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,Z.jsx)(P,{className:`size-4 animate-spin`}),_.title,`…`]}):(0,Z.jsx)(ae,{tree:ee,selectedPath:U?.path??null,onSelectFile:e=>W({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>W({path:e,isDirectory:t}),onExpandDir:ue,onAction:void 0,emptyHint:_.emptyDir}),t[37]=ue,t[38]=te,t[39]=U?.path,t[40]=W,t[41]=_.emptyDir,t[42]=_.title,t[43]=ee,t[44]=$):$=t[44];let Te;t[45]!==xe||t[46]!==$?(Te=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[xe,$]}),t[45]=xe,t[46]=$,t[47]=Te):Te=t[47];let Ee;t[48]===Y?Ee=t[49]:(Ee=(0,Z.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:Y}),t[48]=Y,t[49]=Ee);let De;t[50]===r?De=t[51]:(De=()=>r(!1),t[50]=r,t[51]=De);let Oe;t[52]!==y.cancel||t[53]!==De?(Oe=(0,Z.jsx)(H,{type:`button`,variant:`ghost`,onClick:De,children:y.cancel}),t[52]=y.cancel,t[53]=De,t[54]=Oe):Oe=t[54];let ke=!q,Ae;t[55]!==i||t[56]!==r||t[57]!==A||t[58]!==U?(Ae=()=>{U&&(i({...U,agentId:A}),r(!1))},t[55]=i,t[56]=r,t[57]=A,t[58]=U,t[59]=Ae):Ae=t[59];let je;t[60]!==y.pickerConfirm||t[61]!==ke||t[62]!==Ae?(je=(0,Z.jsx)(H,{type:`button`,disabled:ke,onClick:Ae,children:y.pickerConfirm}),t[60]=y.pickerConfirm,t[61]=ke,t[62]=Ae,t[63]=je):je=t[63];let Me;t[64]!==Oe||t[65]!==je?(Me=(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Oe,je]}),t[64]=Oe,t[65]=je,t[66]=Me):Me=t[66];let Ne;return t[67]!==Ee||t[68]!==Me?(Ne=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[Ee,Me]}),t[67]=Ee,t[68]=Me,t[69]=Ne):Ne=t[69],(0,Z.jsx)(E,{open:n,onOpenChange:r,children:(0,Z.jsxs)(M,{children:[X,(0,Z.jsxs)(v,{className:pe,children:[(0,Z.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[me,(0,Z.jsx)(se,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:y.pickerTitle}),(0,Z.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:he,"aria-label":ge,disabled:te,onClick:_e,children:Q}),(0,Z.jsx)(k,{asChild:!0,children:(0,Z.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":_.close,children:be})})]}),fe.length>0?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,Z.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:y.pickerAgentLabel}),(0,Z.jsx)(R,{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:A,onChange:e=>{j(e.target.value),W(null)},children:fe.map(e=>(0,Z.jsxs)(z,{value:e.id,children:[L(e,g.agentsSettings),e.id===x?.defaultId?` ★`:``]},e.id))})]}):null,Te,Ne]})]})})}function Se(e){return e.token}function Ce(e){return e.agentId}function we(e){return e.language}var $=[`shares`,`policy`];function Te(e){let t=(e??``).trim();return $.includes(t)?t:`shares`}function Ee(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 De(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 Oe=[{value:36e5,key:`1h`},{value:216e5,key:`6h`},{value:864e5,key:`24h`},{value:2592e5,key:`3d`},{value:6048e5,key:`7d`}];function ke(){let e=(0,de.c)(24),t=u(je),n=c(t).sharesSettings,r=!!l(Ae),[a,o]=i(),s;e[0]===a?s=e[1]:(s=Te(a.get(`tab`)),e[0]=a,e[1]=s);let d=s,f;e[2]===o?f=e[3]:(f=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]=f);let p=f;if(!r)return(0,Z.jsx)(ce,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let m={shares:n.tabShares,policy:n.tabPolicy},h=$.map(e=>({id:e,label:m[e]})),g;e[4]!==n.subtitle||e[5]!==n.title?(g=(0,Z.jsx)(W,{title:n.title,subtitle:n.subtitle}),e[4]=n.subtitle,e[5]=n.title,e[6]=g):g=e[6];let _;e[7]!==d||e[8]!==p||e[9]!==n.tabsAria||e[10]!==h?(_=(0,Z.jsx)(ue,{items:h,activeTab:d,onChange:p,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[7]=d,e[8]=p,e[9]=n.tabsAria,e[10]=h,e[11]=_):_=e[11];let v;e[12]!==d||e[13]!==r||e[14]!==t||e[15]!==n?(v=d===`shares`?(0,Z.jsx)(Me,{t:n,language:t}):(0,Z.jsx)(ve,{hasToken:r}),e[12]=d,e[13]=r,e[14]=t,e[15]=n,e[16]=v):v=e[16];let y;e[17]!==d||e[18]!==v?(y=(0,Z.jsx)(le,{id:d,activeTab:d,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:v}),e[17]=d,e[18]=v,e[19]=y):y=e[19];let b;return e[20]!==g||e[21]!==_||e[22]!==y?(b=(0,Z.jsxs)(ce,{children:[g,_,y]}),e[20]=g,e[21]=_,e[22]=y,e[23]=b):b=e[23],b}function Ae(e){return e.token}function je(e){return e.language}function Me(e){let t=(0,de.c)(60),{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:o,error:s,isLoading:c,mutate:l}=p(`shares-list`,A,i),u;t[1]===o?.payload?.shares?u=t[2]:(u=o?.payload?.shares??[],t[1]=o?.payload?.shares,t[2]=u);let d=u,[f,m]=(0,K.useState)(!1),h;bb0:{if(f){h=d;break bb0}let e;t[3]===d?e=t[4]:(e=d.filter(Le),t[3]=d,t[4]=e),h=e}let g=h,_;t[5]===d?_=t[6]:(_=d.filter(Ie),t[5]=d,t[6]=_);let v=_.length,y;t[7]===d?y=t[8]:(y=d.filter(Fe),t[7]=d,t[8]=y);let b=y.length,x;t[9]===l?x=t[10]:(x=()=>void l(),t[9]=l,t[10]=x);let S;t[11]!==n||t[12]!==x?(S=(0,Z.jsx)(ze,{t:n,onCreated:x}),t[11]=n,t[12]=x,t[13]=S):S=t[13];let C=f?n.allSharesTitle:n.listTitle,w;t[14]===v?w=t[15]:(w=v>0&&(0,Z.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,v,`)`]}),t[14]=v,t[15]=w);let T;t[16]!==C||t[17]!==w?(T=(0,Z.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[C,w]}),t[16]=C,t[17]=w,t[18]=T):T=t[18];let E;t[19]===l?E=t[20]:(E=()=>void l(),t[19]=l,t[20]=E);let D=c&&`animate-spin`,O;t[21]===D?O=t[22]:(O=a(`size-3.5`,D),t[21]=D,t[22]=O);let k;t[23]===O?k=t[24]:(k=(0,Z.jsx)(re,{className:O}),t[23]=O,t[24]=k);let j;t[25]!==c||t[26]!==E||t[27]!==k?(j=(0,Z.jsx)(H,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:E,disabled:c,children:k}),t[25]=c,t[26]=E,t[27]=k,t[28]=j):j=t[28];let M;t[29]!==b||t[30]!==f||t[31]!==n.hideExpired||t[32]!==n.showExpired?(M=b>0&&(0,Z.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>m(Pe),children:f?n.hideExpired:n.showExpired}),t[29]=b,t[30]=f,t[31]=n.hideExpired,t[32]=n.showExpired,t[33]=M):M=t[33];let N;t[34]!==j||t[35]!==M?(N=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[j,M]}),t[34]=j,t[35]=M,t[36]=N):N=t[36];let P;t[37]!==T||t[38]!==N?(P=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[T,N]}),t[37]=T,t[38]=N,t[39]=P):P=t[39];let F;t[40]!==o||t[41]!==s||t[42]!==g||t[43]!==c||t[44]!==r||t[45]!==l||t[46]!==n?(F=c&&!o?(0,Z.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(Ne)}):s?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,Z.jsx)(`span`,{children:n.error}),(0,Z.jsx)(H,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void l(),children:n.retry})]}):g.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map(e=>(0,Z.jsx)(Ve,{share:e,t:n,language:r,onRevoked:()=>void l(),onExtended:()=>void l()},e.id))}),t[40]=o,t[41]=s,t[42]=g,t[43]=c,t[44]=r,t[45]=l,t[46]=n,t[47]=F):F=t[47];let I;t[48]!==b||t[49]!==l||t[50]!==f||t[51]!==n?(I=b>0&&f&&(0,Z.jsx)(He,{t:n,onCleaned:()=>void l()}),t[48]=b,t[49]=l,t[50]=f,t[51]=n,t[52]=I):I=t[52];let L;t[53]!==P||t[54]!==F||t[55]!==I?(L=(0,Z.jsxs)(G,{children:[P,F,I]}),t[53]=P,t[54]=F,t[55]=I,t[56]=L):L=t[56];let R;return t[57]!==L||t[58]!==S?(R=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[S,L]}),t[57]=L,t[58]=S,t[59]=R):R=t[59],R}function Ne(e,t){return(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(B,{className:`h-4 w-2/3`}),(0,Z.jsx)(B,{className:`mt-2 h-3 w-1/2`})]}),(0,Z.jsx)(B,{className:`h-7 w-20 rounded-md`})]})},t)}function Pe(e){return!e}function Fe(e){return e.expired||e.revoked}function Ie(e){return!e.expired&&!e.revoked}function Le(e){return!e.expired&&!e.revoked}var Re={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function ze({t:e,onCreated:t}){let[n,r]=(0,K.useReducer)(D,Re),{expanded:i,path:o,isDirectory:s,agentId:c,ttlMs:l,maxViews:u,description:d,directoryMode:f,creating:p,result:m,errorMsg:h,resultDialogOpen:_,pickerOpen:v}=n,y=(0,K.useCallback)(async()=>{if(o.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await x({path:o.trim(),ttlMs:l,maxViews:u,description:d.trim()||void 0,...c?{agentId:c}:{},...s?{kind:`directory`,directoryMode:f}:{}})).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}})}}},[o,s,c,l,u,d,f,t]),b=(0,K.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,Z.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:a(`flex min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm`,o?`text-fg`:`text-fg-subtle`),children:o?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:s?`📁`:`📄`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:o,children:o})]}):(0,Z.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,Z.jsxs)(H,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,Z.jsx)(g,{className:`size-4`}),o?e.pathBrowseChange:e.pathBrowse]})]})]}),s?(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,Z.jsxs)(R,{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:f,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,Z.jsx)(z,{value:`browse`,children:e.directoryModeBrowse}),(0,Z.jsx)(z,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,Z.jsx)(R,{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,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:Oe.map(t=>(0,Z.jsx)(z,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,Z.jsxs)(R,{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:u??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,Z.jsx)(z,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,Z.jsx)(z,{value:`1`,children:`1`}),(0,Z.jsx)(z,{value:`5`,children:`5`}),(0,Z.jsx)(z,{value:`10`,children:`10`}),(0,Z.jsx)(z,{value:`50`,children:`50`}),(0,Z.jsx)(z,{value:`100`,children:`100`})]})]})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,Z.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:d,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Z.jsxs)(H,{type:`button`,disabled:p||!o.trim(),onClick:()=>void y(),children:[p?(0,Z.jsx)(P,{className:`size-4 animate-spin`}):(0,Z.jsx)(oe,{className:`size-4`}),p?e.creating:e.createButton]}),(0,Z.jsx)(H,{type:`button`,variant:`ghost`,onClick:()=>{b(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),h&&(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h})]}),(0,Z.jsx)(I,{open:_,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:m}),(0,Z.jsx)(xe,{open:v,onOpenChange:e=>r({type:`patch`,patch:{pickerOpen:e}}),initialPath:o||void 0,selectKind:`any`,onConfirm:e=>r({type:`patch`,patch:{path:e.path,isDirectory:e.isDirectory,agentId:e.agentId,directoryMode:`browse`}})})]}):(0,Z.jsxs)(H,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,Z.jsx)(oe,{className:`size-4`}),e.createTitle]})}var Be={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function Ve({share:e,t,language:n,onRevoked:r,onExtended:i}){let[c,l]=(0,K.useReducer)(D,Be),{revokeOpen:u,revoking:d,linksOpen:f,urlCopied:p,copyFailed:h,extending:_}=c,v=!e.expired&&!e.revoked,x=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,S=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,w=(0,K.useCallback)(async()=>{l({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await U(e.id),r()}catch{}finally{l({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),T=(0,K.useCallback)(async()=>{if(l({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await s(e.shareUrl)){l({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>l({type:`patch`,patch:{copyFailed:!1}}),2500);return}l({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>l({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),E=(0,K.useCallback)(async()=>{l({type:`patch`,patch:{extending:!0}});try{await C(e.id,864e5),i()}catch{}finally{l({type:`patch`,patch:{extending:!1}})}},[e.id,i]),O=`share-links-${e.id}`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:a(`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":f,"aria-controls":O,onClick:()=>l({type:`patch`,patch:{linksOpen:!f}}),children:[(0,Z.jsx)(te,{className:a(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,f?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),(0,Z.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,Z.jsx)(`span`,{className:a(`text-xs font-medium`,S),children:x})]}),(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.workspaceRelativePath}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:Ee(e.fileSize)}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(F,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:De(e.expiresAt,n)]}),(0,Z.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,Z.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:v&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(H,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void T(),children:p?(0,Z.jsx)(o,{className:`size-3.5 text-emerald-500`}):(0,Z.jsx)(j,{className:`size-3.5`})}),(0,Z.jsx)(H,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void E(),disabled:_,title:t.extend,children:_?(0,Z.jsx)(P,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(F,{className:`size-3.5`})}),(0,Z.jsx)(H,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>l({type:`patch`,patch:{revokeOpen:!0}}),disabled:d,children:d?(0,Z.jsx)(P,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(y,{className:`size-3.5`})})]})})]}),v&&f?(0,Z.jsxs)(`div`,{id:O,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,Z.jsx)(b,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),h?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(m,{reachability:e.reachability})})]}):null]}),(0,Z.jsx)(ee,{open:u,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void w(),onCancel:()=>l({type:`patch`,patch:{revokeOpen:!1}})})]})}function He({t:e,onCleaned:t}){let[n,r]=(0,K.useState)(!1),[i,a]=(0,K.useState)(!1),o=(0,K.useCallback)(async()=>{r(!1),a(!0);try{await _(),t()}catch{}finally{a(!1)}},[t]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(H,{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,Z.jsx)(P,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(y,{className:`size-3.5`}),e.cleanExpired]})}),(0,Z.jsx)(ee,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{ke as SharesSettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{o as t,r as n}from"./locale-store-GfSwnwIZ.js";import{ai as r}from"./index-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{o as t,r as n}from"./locale-store-GfSwnwIZ.js";import{ai as r}from"./index-DSydVlxZ.js";var i=e({reloadSkills:()=>a});async function a(){let e=await t(n(`/api/skills/reload`),{method:`POST`});if(!e.ok)throw Error(await r(e))}export{i as n,a as t};
|