@xopcai/xopc 0.0.105 → 0.0.106
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/feishu/src/adapters/gateway-setup.js +2 -2
- package/dist/extensions/feishu/src/adapters/gateway-setup.js.map +1 -1
- package/dist/extensions/feishu/src/directory/directory-adapter.js +1 -1
- package/dist/extensions/feishu/src/directory/directory-adapter.js.map +1 -1
- package/dist/extensions/feishu/src/outbound/outbound-adapter.js +4 -3
- package/dist/extensions/feishu/src/outbound/outbound-adapter.js.map +1 -1
- package/dist/extensions/feishu/src/plugin.d.ts +6 -3
- package/dist/extensions/feishu/src/plugin.js +59 -40
- package/dist/extensions/feishu/src/plugin.js.map +1 -1
- package/dist/extensions/feishu/src/streaming/streaming-adapter.js +20 -16
- package/dist/extensions/feishu/src/streaming/streaming-adapter.js.map +1 -1
- package/dist/extensions/feishu/src/transport/socket-mode/monitor.js +1 -1
- package/dist/extensions/feishu/src/transport/webhook/monitor.js +1 -1
- package/dist/extensions/feishu/src/workflow-progress.d.ts +1 -1
- package/dist/extensions/feishu/src/workflow-progress.js +2 -2
- package/dist/extensions/feishu/src/workflow-progress.js.map +1 -1
- package/dist/extensions/telegram/src/adapters/gateway-setup.js +8 -6
- package/dist/extensions/telegram/src/adapters/gateway-setup.js.map +1 -1
- package/dist/extensions/telegram/src/command-handler.d.ts +1 -1
- package/dist/extensions/telegram/src/command-handler.js +11 -9
- package/dist/extensions/telegram/src/command-handler.js.map +1 -1
- package/dist/extensions/telegram/src/inbound-processor.js +1 -2
- package/dist/extensions/telegram/src/inbound-processor.js.map +1 -1
- package/dist/extensions/telegram/src/plugin.d.ts +1 -0
- package/dist/extensions/telegram/src/plugin.js +6 -6
- package/dist/extensions/telegram/src/plugin.js.map +1 -1
- package/dist/extensions/telegram/src/workflow-progress.d.ts +1 -1
- package/dist/extensions/telegram/src/workflow-progress.js.map +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/cli/gateway-qr-login.d.ts +4 -0
- package/dist/extensions/weixin/src/cli/gateway-qr-login.js +34 -5
- package/dist/extensions/weixin/src/cli/gateway-qr-login.js.map +1 -1
- package/dist/extensions/weixin/src/cli/qr-login.js +4 -3
- package/dist/extensions/weixin/src/cli/qr-login.js.map +1 -1
- package/dist/extensions/weixin/src/plugin.d.ts +1 -0
- package/dist/extensions/weixin/src/plugin.js +7 -6
- package/dist/extensions/weixin/src/plugin.js.map +1 -1
- package/dist/extensions/weixin/src/workflow-progress.d.ts +1 -1
- package/dist/extensions/weixin/src/workflow-progress.js.map +1 -1
- package/dist/gateway/static/root/assets/{agents-XzgIVKcI.js → agents-3eP0vqFO.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-B7Us3RMl.js → apps-page-CZ2ZKrko.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-BgeV6fzw.js → channels-settings-BbETa93K.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-page-DKGHEeAU.js → cron-page-DCtUkHMu.js} +1 -1
- package/dist/gateway/static/root/assets/{dist-DJDkNhu5.js → dist-OM9qGfm5.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DI1XJTJi.js → extension-debug-page-D-WHrr_w.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-SuafGTT_.js → extension-page-CCgjSoKn.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-cKmGax9v.js → extension-settings-page-BJH5a-Gn.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-config-api-CRiDcxtt.js → heartbeat-config-api-CVyP6pFj.js} +1 -1
- package/dist/gateway/static/root/assets/{index-50FVtgXU.js → index-CEZxETzw.js} +177 -177
- package/dist/gateway/static/root/assets/{logs-page-DM8o5-Bm.js → logs-page-R6Vv_Ja6.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-page-j53jtvq9.js → note-detail-page-BUDarLhh.js} +1 -1
- package/dist/gateway/static/root/assets/{note-time-Ck2H2Qpw.js → note-time-Cc2-T21g.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-CsWIw35Q.js → notes-page-EAHl16bq.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-BvmGNxiJ.js → schema-form-CrlOmEZt.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-CLPsbyOW.js → sessions-page-Ce_xuuSB.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-advanced-gate-DRdayl8P.js → settings-advanced-gate-BBAQxxew.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-BlIYg2gZ.js → settings-form-section-DjPD-ErC.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-CRGHT_bm.js → settings-page-KhQ9QgH0.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-BlT6Akvk.js → share-preview-page-BjvPht3V.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-Ce-RIH2y.js → skills-page-C0laq7l1.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-CJGTidqc.js → voice-api-key-field-DeGckWkl.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-page.utils-_sjXCMvi.js → workflow-page.utils-D4sqR0yX.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-o63aaARK.js → workflows-page-DFjM95g5.js} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/src/agent/mcp/bundle-mcp-config.js +16 -8
- package/dist/src/agent/mcp/bundle-mcp-config.js.map +1 -1
- package/dist/src/agent/mcp/bundle-mcp-policy.js +2 -2
- package/dist/src/agent/mcp/bundle-mcp-policy.js.map +1 -1
- package/dist/src/agent/mcp/bundle-mcp-runtime.js +1 -1
- package/dist/src/agent/mcp/mcp-http.js +1 -1
- package/dist/src/agent/mcp/mcp-http.js.map +1 -1
- package/dist/src/agent/mcp/mcp-transport-config.js +2 -6
- package/dist/src/agent/mcp/mcp-transport-config.js.map +1 -1
- package/dist/src/agent/workflow/index.js +2 -1
- package/dist/src/agent/workflow/runtime.d.ts +2 -2
- package/dist/src/agent/workflow/runtime.js +1 -14
- package/dist/src/agent/workflow/runtime.js.map +1 -1
- package/dist/src/agent/workflow/snapshot-empty.d.ts +2 -0
- package/dist/src/agent/workflow/snapshot-empty.js +19 -0
- package/dist/src/agent/workflow/snapshot-empty.js.map +1 -0
- package/dist/src/agent/workflow/snapshot.js +1 -1
- package/dist/src/agent/workflow/snapshot.js.map +1 -1
- package/dist/src/connectors/health.js +1 -1
- package/dist/src/connectors/install.js +1 -1
- package/dist/src/gateway/hono/routes/mcp.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/voice/stt/availability.d.ts +6 -0
- package/dist/src/voice/stt/availability.js +14 -6
- package/dist/src/voice/stt/availability.js.map +1 -1
- package/dist/src/voice/stt/index.js +2 -1
- package/dist/src/voice/stt/index.js.map +1 -1
- package/dist/src/voice/stt/mention.d.ts +2 -0
- package/dist/src/voice/stt/mention.js +20 -0
- package/dist/src/voice/stt/mention.js.map +1 -0
- package/dist/src/voice/stt/preflight.d.ts +1 -4
- package/dist/src/voice/stt/preflight.js +1 -18
- package/dist/src/voice/stt/preflight.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{Xr as r,qr as i,ui as a}from"./index-50FVtgXU.js";var o=t();e();var s=n();function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function l(e){let t=e[`x-order`];return typeof t==`number`&&!Number.isNaN(t)?t:999}function u(e){let t=e[`x-group`];return typeof t==`string`&&t.length>0?t:``}function d(e){return e[`x-hidden`]===!0}function f(e){let t=e.properties;if(!c(t))return[];let n=[];for(let[e,r]of Object.entries(t))c(r)&&(d(r)||n.push({key:e,sub:r,order:l(r),group:u(r),hidden:!1}));return n.sort((e,t)=>e.order-t.order||e.key.localeCompare(t.key)),n}function p(e){let t=new Map;for(let n of e){let e=n.group;t.has(e)||t.set(e,[]),t.get(e).push(n)}return t}function m(e){let t=(0,o.c)(38),{name:n,s:a,value:c,onChange:l,disabled:u}=e,d=typeof a.description==`string`?a.description:void 0,f=(typeof a[`x-placeholder`]==`string`?a[`x-placeholder`]:null)||d,p=a.format;if(Array.isArray(a.enum)&&a.enum.every(g)){let e;t[0]===d?e=t[1]:(e=d?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:d}):null,t[0]=d,t[1]=e);let r;t[2]===l?r=t[3]:(r=e=>l(e.target.value),t[2]=l,t[3]=r);let i;t[4]===a.enum?i=t[5]:(i=a.enum.map(h),t[4]=a.enum,t[5]=i);let o;t[6]!==u||t[7]!==n||t[8]!==r||t[9]!==i||t[10]!==c?(o=(0,s.jsx)(`select`,{name:n,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg`,value:c,disabled:u,onChange:r,children:i}),t[6]=u,t[7]=n,t[8]=r,t[9]=i,t[10]=c,t[11]=o):o=t[11];let f;return t[12]!==e||t[13]!==o?(f=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,o]}),t[12]=e,t[13]=o,t[14]=f):f=t[14],f}if(p===`password`){let e;t[15]===d?e=t[16]:(e=d?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:d}):null,t[15]=d,t[16]=e);let n;t[17]!==u||t[18]!==l||t[19]!==f||t[20]!==c?(n=(0,s.jsx)(r,{value:c,onChange:l,placeholder:f,labels:i,disabled:u,inputClassName:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`}),t[17]=u,t[18]=l,t[19]=f,t[20]=c,t[21]=n):n=t[21];let a;return t[22]!==e||t[23]!==n?(a=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,n]}),t[22]=e,t[23]=n,t[24]=a):a=t[24],a}let m;t[25]===d?m=t[26]:(m=d?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:d}):null,t[25]=d,t[26]=m);let _;t[27]===l?_=t[28]:(_=e=>l(e.target.value),t[27]=l,t[28]=_);let v;t[29]!==u||t[30]!==n||t[31]!==f||t[32]!==_||t[33]!==c?(v=(0,s.jsx)(`input`,{name:n,type:`text`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`,value:c,placeholder:f,disabled:u,onChange:_}),t[29]=u,t[30]=n,t[31]=f,t[32]=_,t[33]=c,t[34]=v):v=t[34];let y;return t[35]!==m||t[36]!==v?(y=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[m,v]}),t[35]=m,t[36]=v,t[37]=y):y=t[37],y}function h(e){return(0,s.jsx)(`option`,{value:e,children:e},e)}function g(e){return typeof e==`string`}function _(e){let t=(0,o.c)(11),{s:n,value:r,onChange:i,disabled:a}=e,c=typeof n.description==`string`?n.description:void 0,l;t[0]===c?l=t[1]:(l=c?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:c}):null,t[0]=c,t[1]=l);let u=Number.isFinite(r)?r:0,d;t[2]===i?d=t[3]:(d=e=>i(Number(e.target.value)),t[2]=i,t[3]=d);let f;t[4]!==a||t[5]!==u||t[6]!==d?(f=(0,s.jsx)(`input`,{type:`number`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg`,value:u,disabled:a,onChange:d}),t[4]=a,t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;return t[8]!==l||t[9]!==f?(p=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,f]}),t[8]=l,t[9]=f,t[10]=p):p=t[10],p}function v(e){let t=(0,o.c)(11),{s:n,value:r,onChange:i,disabled:a,labels:c}=e,l=(typeof n.description==`string`?n.description:void 0)??(typeof n.title==`string`&&n.title.length>0?n.title:c?.defaultBooleanLabel??`Enable`),u;t[0]===i?u=t[1]:(u=e=>i(e.target.checked),t[0]=i,t[1]=u);let d;t[2]!==a||t[3]!==u||t[4]!==r?(d=(0,s.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border border-edge`,checked:r,disabled:a,onChange:u}),t[2]=a,t[3]=u,t[4]=r,t[5]=d):d=t[5];let f;t[6]===l?f=t[7]:(f=(0,s.jsx)(`span`,{children:l}),t[6]=l,t[7]=f);let p;return t[8]!==d||t[9]!==f?(p=(0,s.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10],p}function y(e){let t=(0,o.c)(27),{s:n,value:r,onChange:i,disabled:a,labels:l}=e,u=typeof n.description==`string`?n.description:void 0,d=n.items,f=c(d)?d.type:void 0;if(!(f===`string`||Array.isArray(f)&&f.includes(`string`))){let e=l?.unsupportedArrayType??`Unsupported array type`,n;return t[0]===e?n=t[1]:(n=(0,s.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e}),t[0]=e,t[1]=n),n}let p,m,h,g,_;if(t[2]!==u||t[3]!==a||t[4]!==i||t[5]!==r){let e=r.map(String);p=t=>{let n=t.trim();!n||e.includes(n)||i([...e,n])},g=`flex flex-col gap-1.5`,t[11]===u?_=t[12]:(_=u?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:u}):null,t[11]=u,t[12]=_),m=`flex flex-wrap gap-1`,h=e.map(t=>(0,s.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-sm`,children:[t,(0,s.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,disabled:a,onClick:()=>i(e.filter(e=>e!==t)),children:`×`})]},t)),t[2]=u,t[3]=a,t[4]=i,t[5]=r,t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=_}else p=t[6],m=t[7],h=t[8],g=t[9],_=t[10];let v;t[13]!==m||t[14]!==h?(v=(0,s.jsx)(`div`,{className:m,children:h}),t[13]=m,t[14]=h,t[15]=v):v=t[15];let y=l?.arrayAddPlaceholder??`Add and press Enter`,b;t[16]===p?b=t[17]:(b=e=>{e.key===`Enter`&&(e.preventDefault(),p(e.target.value),e.target.value=``)},t[16]=p,t[17]=b);let x;t[18]!==a||t[19]!==y||t[20]!==b?(x=(0,s.jsx)(`input`,{className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm`,disabled:a,placeholder:y,onKeyDown:b}),t[18]=a,t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;return t[22]!==g||t[23]!==_||t[24]!==v||t[25]!==x?(S=(0,s.jsxs)(`div`,{className:g,children:[_,v,x]}),t[22]=g,t[23]=_,t[24]=v,t[25]=x,t[26]=S):S=t[26],S}function b(e){let t=(0,o.c)(66),{k:n,sub:r,value:i,onValue:a,disabled:l,labels:u}=e,d=r.type,f=(typeof r.title==`string`&&r.title.length>0?r.title:null)??n;if(d===`boolean`){let e;t[0]===f?e=t[1]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[0]=f,t[1]=e);let n=i===!0,o;t[2]===a?o=t[3]:(o=e=>a(e),t[2]=a,t[3]=o);let c;t[4]!==l||t[5]!==u||t[6]!==r||t[7]!==n||t[8]!==o?(c=(0,s.jsx)(v,{s:r,value:n,disabled:l,onChange:o,labels:u}),t[4]=l,t[5]=u,t[6]=r,t[7]=n,t[8]=o,t[9]=c):c=t[9];let d;return t[10]!==e||t[11]!==c?(d=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[10]=e,t[11]=c,t[12]=d):d=t[12],d}if(d===`number`||d===`integer`){let e;t[13]===f?e=t[14]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[13]=f,t[14]=e);let n=typeof i==`number`?i:0,o;t[15]!==l||t[16]!==a||t[17]!==r||t[18]!==n?(o=(0,s.jsx)(_,{s:r,value:n,disabled:l,onChange:a}),t[15]=l,t[16]=a,t[17]=r,t[18]=n,t[19]=o):o=t[19];let c;return t[20]!==e||t[21]!==o?(c=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,o]}),t[20]=e,t[21]=o,t[22]=c):c=t[22],c}if(d===`string`){let e;t[23]===f?e=t[24]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[23]=f,t[24]=e);let o=typeof i==`string`?i:``,c;t[25]!==l||t[26]!==n||t[27]!==a||t[28]!==r||t[29]!==o?(c=(0,s.jsx)(m,{name:n,s:r,value:o,disabled:l,onChange:a}),t[25]=l,t[26]=n,t[27]=a,t[28]=r,t[29]=o,t[30]=c):c=t[30];let u;return t[31]!==e||t[32]!==c?(u=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[31]=e,t[32]=c,t[33]=u):u=t[33],u}if(d===`array`){let e=r.items,n=c(e)?e.type:void 0;if(n===`string`||Array.isArray(n)&&n.includes(`string`)){let e;t[34]===f?e=t[35]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[34]=f,t[35]=e);let n;t[36]===i?n=t[37]:(n=Array.isArray(i)&&i.every(x)?i.map(String):[],t[36]=i,t[37]=n);let o;t[38]!==l||t[39]!==u||t[40]!==a||t[41]!==r||t[42]!==n?(o=(0,s.jsx)(y,{s:r,value:n,disabled:l,onChange:a,labels:u}),t[38]=l,t[39]=u,t[40]=a,t[41]=r,t[42]=n,t[43]=o):o=t[43];let c;return t[44]!==e||t[45]!==o?(c=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,o]}),t[44]=e,t[45]=o,t[46]=c):c=t[46],c}}if(d===`object`){let e;t[47]===i?e=t[48]:(e=c(i)?i:{},t[47]=i,t[48]=e);let n=e,o;t[49]===f?o=t[50]:(o=(0,s.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:f}),t[49]=f,t[50]=o);let d;t[51]!==l||t[52]!==u||t[53]!==n||t[54]!==a||t[55]!==r?(d=(0,s.jsx)(`div`,{className:`border-t border-edge p-3`,children:(0,s.jsx)(S,{schema:r,values:n,onChange:a,disabled:l,labels:u})}),t[51]=l,t[52]=u,t[53]=n,t[54]=a,t[55]=r,t[56]=d):d=t[56];let p;return t[57]!==o||t[58]!==d?(p=(0,s.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[o,d]}),t[57]=o,t[58]=d,t[59]=p):p=t[59],p}let p;t[60]!==u||t[61]!==d||t[62]!==f?(p=u?.unsupportedFieldType?.(f,typeof d==`string`?d:void 0)??`${f}: unsupported field type${typeof d==`string`?` (${d})`:``}`,t[60]=u,t[61]=d,t[62]=f,t[63]=p):p=t[63];let h;return t[64]===p?h=t[65]:(h=(0,s.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[64]=p,t[65]=h),h}function x(e){return typeof e==`string`||typeof e==`number`}function S(e){let t=(0,o.c)(28),{schema:n,values:r,onChange:i,disabled:l,className:u,labels:d}=e,m=l===void 0?!1:l,h;bb0:{if(n.type!==`object`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],h=e;break bb0}let e;t[1]===n?e=t[2]:(e=f(n),t[1]=n,t[2]=e),h=e}let g=h,_;bb1:{if(g.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=new Map,t[3]=e):e=t[3],_=e;break bb1}let e;t[4]===g?e=t[5]:(e=p(g),t[4]=g,t[5]=e),_=e}let v=_,y;t[6]!==i||t[7]!==r?(y=(e,t)=>{i({...r,[e]:t})},t[6]=i,t[7]=r,t[8]=y):y=t[8];let x=y;if(n.type!==`object`||!c(n.properties)||g.length===0)return null;let S,w;if(t[9]!==u||t[10]!==m||t[11]!==v||t[12]!==d||t[13]!==x||t[14]!==r){let e=Array.from(v.keys()).sort(C);t[17]===u?S=t[18]:(S=a(`flex flex-col gap-4`,u),t[17]=u,t[18]=S);let n;t[19]!==m||t[20]!==v||t[21]!==d||t[22]!==x||t[23]!==r?(n=e=>{let t=(v.get(e)??[]).map(e=>(0,s.jsx)(b,{k:e.key,sub:e.sub,value:r[e.key],onValue:t=>x(e.key,t),disabled:m,labels:d},e.key));return e===``?(0,s.jsx)(`div`,{children:t},`default`):(0,s.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[(0,s.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:e}),(0,s.jsx)(`div`,{className:`space-y-4 border-t border-edge p-3`,children:t})]},e)},t[19]=m,t[20]=v,t[21]=d,t[22]=x,t[23]=r,t[24]=n):n=t[24],w=e.map(n),t[9]=u,t[10]=m,t[11]=v,t[12]=d,t[13]=x,t[14]=r,t[15]=S,t[16]=w}else S=t[15],w=t[16];let T;return t[25]!==S||t[26]!==w?(T=(0,s.jsx)(`div`,{className:S,children:w}),t[25]=S,t[26]=w,t[27]=T):T=t[27],T}function C(e,t){return e===``?-1:t===``?1:e.localeCompare(t)}export{S as t};
|
|
1
|
+
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{Xr as r,qr as i,ui as a}from"./index-CEZxETzw.js";var o=t();e();var s=n();function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function l(e){let t=e[`x-order`];return typeof t==`number`&&!Number.isNaN(t)?t:999}function u(e){let t=e[`x-group`];return typeof t==`string`&&t.length>0?t:``}function d(e){return e[`x-hidden`]===!0}function f(e){let t=e.properties;if(!c(t))return[];let n=[];for(let[e,r]of Object.entries(t))c(r)&&(d(r)||n.push({key:e,sub:r,order:l(r),group:u(r),hidden:!1}));return n.sort((e,t)=>e.order-t.order||e.key.localeCompare(t.key)),n}function p(e){let t=new Map;for(let n of e){let e=n.group;t.has(e)||t.set(e,[]),t.get(e).push(n)}return t}function m(e){let t=(0,o.c)(38),{name:n,s:a,value:c,onChange:l,disabled:u}=e,d=typeof a.description==`string`?a.description:void 0,f=(typeof a[`x-placeholder`]==`string`?a[`x-placeholder`]:null)||d,p=a.format;if(Array.isArray(a.enum)&&a.enum.every(g)){let e;t[0]===d?e=t[1]:(e=d?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:d}):null,t[0]=d,t[1]=e);let r;t[2]===l?r=t[3]:(r=e=>l(e.target.value),t[2]=l,t[3]=r);let i;t[4]===a.enum?i=t[5]:(i=a.enum.map(h),t[4]=a.enum,t[5]=i);let o;t[6]!==u||t[7]!==n||t[8]!==r||t[9]!==i||t[10]!==c?(o=(0,s.jsx)(`select`,{name:n,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg`,value:c,disabled:u,onChange:r,children:i}),t[6]=u,t[7]=n,t[8]=r,t[9]=i,t[10]=c,t[11]=o):o=t[11];let f;return t[12]!==e||t[13]!==o?(f=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,o]}),t[12]=e,t[13]=o,t[14]=f):f=t[14],f}if(p===`password`){let e;t[15]===d?e=t[16]:(e=d?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:d}):null,t[15]=d,t[16]=e);let n;t[17]!==u||t[18]!==l||t[19]!==f||t[20]!==c?(n=(0,s.jsx)(r,{value:c,onChange:l,placeholder:f,labels:i,disabled:u,inputClassName:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`}),t[17]=u,t[18]=l,t[19]=f,t[20]=c,t[21]=n):n=t[21];let a;return t[22]!==e||t[23]!==n?(a=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,n]}),t[22]=e,t[23]=n,t[24]=a):a=t[24],a}let m;t[25]===d?m=t[26]:(m=d?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:d}):null,t[25]=d,t[26]=m);let _;t[27]===l?_=t[28]:(_=e=>l(e.target.value),t[27]=l,t[28]=_);let v;t[29]!==u||t[30]!==n||t[31]!==f||t[32]!==_||t[33]!==c?(v=(0,s.jsx)(`input`,{name:n,type:`text`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`,value:c,placeholder:f,disabled:u,onChange:_}),t[29]=u,t[30]=n,t[31]=f,t[32]=_,t[33]=c,t[34]=v):v=t[34];let y;return t[35]!==m||t[36]!==v?(y=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[m,v]}),t[35]=m,t[36]=v,t[37]=y):y=t[37],y}function h(e){return(0,s.jsx)(`option`,{value:e,children:e},e)}function g(e){return typeof e==`string`}function _(e){let t=(0,o.c)(11),{s:n,value:r,onChange:i,disabled:a}=e,c=typeof n.description==`string`?n.description:void 0,l;t[0]===c?l=t[1]:(l=c?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:c}):null,t[0]=c,t[1]=l);let u=Number.isFinite(r)?r:0,d;t[2]===i?d=t[3]:(d=e=>i(Number(e.target.value)),t[2]=i,t[3]=d);let f;t[4]!==a||t[5]!==u||t[6]!==d?(f=(0,s.jsx)(`input`,{type:`number`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg`,value:u,disabled:a,onChange:d}),t[4]=a,t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;return t[8]!==l||t[9]!==f?(p=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,f]}),t[8]=l,t[9]=f,t[10]=p):p=t[10],p}function v(e){let t=(0,o.c)(11),{s:n,value:r,onChange:i,disabled:a,labels:c}=e,l=(typeof n.description==`string`?n.description:void 0)??(typeof n.title==`string`&&n.title.length>0?n.title:c?.defaultBooleanLabel??`Enable`),u;t[0]===i?u=t[1]:(u=e=>i(e.target.checked),t[0]=i,t[1]=u);let d;t[2]!==a||t[3]!==u||t[4]!==r?(d=(0,s.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border border-edge`,checked:r,disabled:a,onChange:u}),t[2]=a,t[3]=u,t[4]=r,t[5]=d):d=t[5];let f;t[6]===l?f=t[7]:(f=(0,s.jsx)(`span`,{children:l}),t[6]=l,t[7]=f);let p;return t[8]!==d||t[9]!==f?(p=(0,s.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10],p}function y(e){let t=(0,o.c)(27),{s:n,value:r,onChange:i,disabled:a,labels:l}=e,u=typeof n.description==`string`?n.description:void 0,d=n.items,f=c(d)?d.type:void 0;if(!(f===`string`||Array.isArray(f)&&f.includes(`string`))){let e=l?.unsupportedArrayType??`Unsupported array type`,n;return t[0]===e?n=t[1]:(n=(0,s.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e}),t[0]=e,t[1]=n),n}let p,m,h,g,_;if(t[2]!==u||t[3]!==a||t[4]!==i||t[5]!==r){let e=r.map(String);p=t=>{let n=t.trim();!n||e.includes(n)||i([...e,n])},g=`flex flex-col gap-1.5`,t[11]===u?_=t[12]:(_=u?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:u}):null,t[11]=u,t[12]=_),m=`flex flex-wrap gap-1`,h=e.map(t=>(0,s.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-sm`,children:[t,(0,s.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,disabled:a,onClick:()=>i(e.filter(e=>e!==t)),children:`×`})]},t)),t[2]=u,t[3]=a,t[4]=i,t[5]=r,t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=_}else p=t[6],m=t[7],h=t[8],g=t[9],_=t[10];let v;t[13]!==m||t[14]!==h?(v=(0,s.jsx)(`div`,{className:m,children:h}),t[13]=m,t[14]=h,t[15]=v):v=t[15];let y=l?.arrayAddPlaceholder??`Add and press Enter`,b;t[16]===p?b=t[17]:(b=e=>{e.key===`Enter`&&(e.preventDefault(),p(e.target.value),e.target.value=``)},t[16]=p,t[17]=b);let x;t[18]!==a||t[19]!==y||t[20]!==b?(x=(0,s.jsx)(`input`,{className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm`,disabled:a,placeholder:y,onKeyDown:b}),t[18]=a,t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;return t[22]!==g||t[23]!==_||t[24]!==v||t[25]!==x?(S=(0,s.jsxs)(`div`,{className:g,children:[_,v,x]}),t[22]=g,t[23]=_,t[24]=v,t[25]=x,t[26]=S):S=t[26],S}function b(e){let t=(0,o.c)(66),{k:n,sub:r,value:i,onValue:a,disabled:l,labels:u}=e,d=r.type,f=(typeof r.title==`string`&&r.title.length>0?r.title:null)??n;if(d===`boolean`){let e;t[0]===f?e=t[1]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[0]=f,t[1]=e);let n=i===!0,o;t[2]===a?o=t[3]:(o=e=>a(e),t[2]=a,t[3]=o);let c;t[4]!==l||t[5]!==u||t[6]!==r||t[7]!==n||t[8]!==o?(c=(0,s.jsx)(v,{s:r,value:n,disabled:l,onChange:o,labels:u}),t[4]=l,t[5]=u,t[6]=r,t[7]=n,t[8]=o,t[9]=c):c=t[9];let d;return t[10]!==e||t[11]!==c?(d=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[10]=e,t[11]=c,t[12]=d):d=t[12],d}if(d===`number`||d===`integer`){let e;t[13]===f?e=t[14]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[13]=f,t[14]=e);let n=typeof i==`number`?i:0,o;t[15]!==l||t[16]!==a||t[17]!==r||t[18]!==n?(o=(0,s.jsx)(_,{s:r,value:n,disabled:l,onChange:a}),t[15]=l,t[16]=a,t[17]=r,t[18]=n,t[19]=o):o=t[19];let c;return t[20]!==e||t[21]!==o?(c=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,o]}),t[20]=e,t[21]=o,t[22]=c):c=t[22],c}if(d===`string`){let e;t[23]===f?e=t[24]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[23]=f,t[24]=e);let o=typeof i==`string`?i:``,c;t[25]!==l||t[26]!==n||t[27]!==a||t[28]!==r||t[29]!==o?(c=(0,s.jsx)(m,{name:n,s:r,value:o,disabled:l,onChange:a}),t[25]=l,t[26]=n,t[27]=a,t[28]=r,t[29]=o,t[30]=c):c=t[30];let u;return t[31]!==e||t[32]!==c?(u=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[31]=e,t[32]=c,t[33]=u):u=t[33],u}if(d===`array`){let e=r.items,n=c(e)?e.type:void 0;if(n===`string`||Array.isArray(n)&&n.includes(`string`)){let e;t[34]===f?e=t[35]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[34]=f,t[35]=e);let n;t[36]===i?n=t[37]:(n=Array.isArray(i)&&i.every(x)?i.map(String):[],t[36]=i,t[37]=n);let o;t[38]!==l||t[39]!==u||t[40]!==a||t[41]!==r||t[42]!==n?(o=(0,s.jsx)(y,{s:r,value:n,disabled:l,onChange:a,labels:u}),t[38]=l,t[39]=u,t[40]=a,t[41]=r,t[42]=n,t[43]=o):o=t[43];let c;return t[44]!==e||t[45]!==o?(c=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,o]}),t[44]=e,t[45]=o,t[46]=c):c=t[46],c}}if(d===`object`){let e;t[47]===i?e=t[48]:(e=c(i)?i:{},t[47]=i,t[48]=e);let n=e,o;t[49]===f?o=t[50]:(o=(0,s.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:f}),t[49]=f,t[50]=o);let d;t[51]!==l||t[52]!==u||t[53]!==n||t[54]!==a||t[55]!==r?(d=(0,s.jsx)(`div`,{className:`border-t border-edge p-3`,children:(0,s.jsx)(S,{schema:r,values:n,onChange:a,disabled:l,labels:u})}),t[51]=l,t[52]=u,t[53]=n,t[54]=a,t[55]=r,t[56]=d):d=t[56];let p;return t[57]!==o||t[58]!==d?(p=(0,s.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[o,d]}),t[57]=o,t[58]=d,t[59]=p):p=t[59],p}let p;t[60]!==u||t[61]!==d||t[62]!==f?(p=u?.unsupportedFieldType?.(f,typeof d==`string`?d:void 0)??`${f}: unsupported field type${typeof d==`string`?` (${d})`:``}`,t[60]=u,t[61]=d,t[62]=f,t[63]=p):p=t[63];let h;return t[64]===p?h=t[65]:(h=(0,s.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[64]=p,t[65]=h),h}function x(e){return typeof e==`string`||typeof e==`number`}function S(e){let t=(0,o.c)(28),{schema:n,values:r,onChange:i,disabled:l,className:u,labels:d}=e,m=l===void 0?!1:l,h;bb0:{if(n.type!==`object`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],h=e;break bb0}let e;t[1]===n?e=t[2]:(e=f(n),t[1]=n,t[2]=e),h=e}let g=h,_;bb1:{if(g.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=new Map,t[3]=e):e=t[3],_=e;break bb1}let e;t[4]===g?e=t[5]:(e=p(g),t[4]=g,t[5]=e),_=e}let v=_,y;t[6]!==i||t[7]!==r?(y=(e,t)=>{i({...r,[e]:t})},t[6]=i,t[7]=r,t[8]=y):y=t[8];let x=y;if(n.type!==`object`||!c(n.properties)||g.length===0)return null;let S,w;if(t[9]!==u||t[10]!==m||t[11]!==v||t[12]!==d||t[13]!==x||t[14]!==r){let e=Array.from(v.keys()).sort(C);t[17]===u?S=t[18]:(S=a(`flex flex-col gap-4`,u),t[17]=u,t[18]=S);let n;t[19]!==m||t[20]!==v||t[21]!==d||t[22]!==x||t[23]!==r?(n=e=>{let t=(v.get(e)??[]).map(e=>(0,s.jsx)(b,{k:e.key,sub:e.sub,value:r[e.key],onValue:t=>x(e.key,t),disabled:m,labels:d},e.key));return e===``?(0,s.jsx)(`div`,{children:t},`default`):(0,s.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[(0,s.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:e}),(0,s.jsx)(`div`,{className:`space-y-4 border-t border-edge p-3`,children:t})]},e)},t[19]=m,t[20]=v,t[21]=d,t[22]=x,t[23]=r,t[24]=n):n=t[24],w=e.map(n),t[9]=u,t[10]=m,t[11]=v,t[12]=d,t[13]=x,t[14]=r,t[15]=S,t[16]=w}else S=t[15],w=t[16];let T;return t[25]!==S||t[26]!==w?(T=(0,s.jsx)(`div`,{className:S,children:w}),t[25]=S,t[26]=w,t[27]=T):T=t[27],T}function C(e,t){return e===``?-1:t===``?1:e.localeCompare(t)}export{S as t};
|
package/dist/gateway/static/root/assets/{sessions-page-CLPsbyOW.js → sessions-page-Ce_xuuSB.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{i,o as a,t as o}from"./url-DPEStU4M.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{a as c,n as l}from"./fetch-CkvRO30i.js";import{i as u,r as d}from"./gateway-startup-retry-BkKyRDrF.js";import{Ba as f,Ci as p,Cr as ee,Dr as m,Er as h,Gi as g,Go as te,Hn as _,Ko as v,M as y,N as b,Or as x,P as S,Sn as C,So as w,Sr as T,Tr as E,Un as ne,Va as D,Vn as O,Yi as k,ao as A,ar as j,ci as M,cr as N,di as P,ei as F,es as I,fa as L,fi as R,fo as z,ir as B,ka as V,li as H,lr as re,mr as ie,nr as ae,or as U,pa as oe,po as W,pr as G,rr as se,sr as ce,ti as K,tr as le,ui as q,ur as ue,wa as J,xn as de,za as fe}from"./index-50FVtgXU.js";import{n as pe,t as Y}from"./settings-form-section-BlIYg2gZ.js";var X=e(t(),1),Z=n(),Q=r();function me(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 he(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ge(e){let t=(0,Z.c)(105),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:s,onAction:c}=e,l;t[0]!==i.unnamedSession||t[1]!==n.name?(l=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=l):l=t[2];let u=l,d;t[3]===n.name?d=t[4]:(d=n.name?.trim(),t[3]=n.name,t[4]=d);let f=!!d,ee=n.status===`archived`,m=n.status===`pinned`,h=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,g;t[5]===h?g=t[6]:(g=q(`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`,h),t[5]=h,t[6]=g);let _;t[7]===s?_=t[8]:(_=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},t[7]=s,t[8]=_);let y=r===`list`&&`sm:py-3`,b;t[9]===y?b=t[10]:(b=q(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,y),t[9]=y,t[10]=b);let x;t[11]===n.sourceChannel?x=t[12]:(x=(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]=x);let S;t[13]===m?S=t[14]:(S=m?(0,Q.jsx)(oe,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=m,t[14]=S);let C;t[15]===n.updatedAt?C=t[16]:(C=me(n.updatedAt),t[15]=n.updatedAt,t[16]=C);let w;t[17]===C?w=t[18]:(w=(0,Q.jsx)(`span`,{children:C}),t[17]=C,t[18]=w);let T;t[19]!==w||t[20]!==S?(T=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[S,w]}),t[19]=w,t[20]=S,t[21]=T):T=t[21];let E;t[22]!==T||t[23]!==b||t[24]!==x?(E=(0,Q.jsxs)(`div`,{className:b,children:[x,T]}),t[22]=T,t[23]=b,t[24]=x,t[25]=E):E=t[25];let D=r===`list`&&`sm:py-3`,O;t[26]===D?O=t[27]:(O=q(`min-w-0 flex-1 px-3 py-2`,D),t[26]=D,t[27]=O);let k=r===`list`&&`sm:items-start`,A;t[28]===k?A=t[29]:(A=q(`flex gap-3`,k),t[28]=k,t[29]=A);let j;t[30]!==o||t[31]!==a?(j=(0,Q.jsx)(ne,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=o,t[31]=a,t[32]=j):j=t[32];let M;t[33]===u?M=t[34]:(M=(0,Q.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:u,children:u}),t[33]=u,t[34]=M);let N;t[35]!==n.key||t[36]!==f?(N=f?(0,Q.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[35]=n.key,t[36]=f,t[37]=N):N=t[37];let I;t[38]!==M||t[39]!==N?(I=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[M,N]}),t[38]=M,t[39]=N,t[40]=I):I=t[40];let R;t[41]!==A||t[42]!==j||t[43]!==I?(R=(0,Q.jsxs)(`div`,{className:A,children:[j,I]}),t[41]=A,t[42]=j,t[43]=I,t[44]=R):R=t[44];let B;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Q.jsx)(J,{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 H;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,Q.jsx)(P,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=H):H=t[48];let re;t[49]===n.estimatedTokens?re=t[50]:(re=he(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=re);let ie;t[51]===re?ie=t[52]:(ie=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[H,re]}),t[51]=re,t[52]=ie);let ae;t[53]!==V||t[54]!==ie?(ae=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[V,ie]}),t[53]=V,t[54]=ie,t[55]=ae):ae=t[55];let U;t[56]===n.tags?U=t[57]:(U=n.tags.length>0?(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(ye),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]=U);let W;t[58]!==O||t[59]!==R||t[60]!==ae||t[61]!==U?(W=(0,Q.jsxs)(`div`,{className:O,children:[R,ae,U]}),t[58]=O,t[59]=R,t[60]=ae,t[61]=U,t[62]=W):W=t[62];let G;t[63]===c?G=t[64]:(G=()=>c(`continue`),t[63]=c,t[64]=G);let se;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsx)(J,{className:`size-4`,strokeWidth:1.75}),t[65]=se):se=t[65];let ce;t[66]!==i.continueChat||t[67]!==G?(ce=(0,Q.jsx)(`button`,{type:`button`,className:F,title:i.continueChat,"aria-label":i.continueChat,onClick:G,children:se}),t[66]=i.continueChat,t[67]=G,t[68]=ce):ce=t[68];let K;t[69]!==ee||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==c?(K=ee?(0,Q.jsx)(`button`,{type:`button`,className:F,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>c(`unarchive`),children:(0,Q.jsx)(v,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:F,title:i.archive,"aria-label":i.archive,onClick:()=>c(`archive`),children:(0,Q.jsx)(te,{className:`size-4`,strokeWidth:1.75})}),t[69]=ee,t[70]=i.archive,t[71]=i.unarchive,t[72]=c,t[73]=K):K=t[73];let le;t[74]!==m||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==c?(le=m?(0,Q.jsx)(`button`,{type:`button`,className:F,title:i.unpin,"aria-label":i.unpin,onClick:()=>c(`unpin`),children:(0,Q.jsx)(L,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:F,title:i.pin,"aria-label":i.pin,onClick:()=>c(`pin`),children:(0,Q.jsx)(oe,{className:`size-4`,strokeWidth:1.75})}),t[74]=m,t[75]=i.pin,t[76]=i.unpin,t[77]=c,t[78]=le):le=t[78];let ue;t[79]===c?ue=t[80]:(ue=()=>c(`export`),t[79]=c,t[80]=ue);let de;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Q.jsx)(z,{className:`size-4`,strokeWidth:1.75}),t[81]=de):de=t[81];let fe;t[82]!==i.export||t[83]!==ue?(fe=(0,Q.jsx)(`button`,{type:`button`,className:F,title:i.export,"aria-label":i.export,onClick:ue,children:de}),t[82]=i.export,t[83]=ue,t[84]=fe):fe=t[84];let pe;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(pe=q(F,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=pe):pe=t[85];let Y;t[86]===c?Y=t[87]:(Y=()=>c(`delete`),t[86]=c,t[87]=Y);let X;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Q.jsx)(p,{className:`size-4`,strokeWidth:1.75}),t[88]=X):X=t[88];let ge;t[89]!==i.delete||t[90]!==Y?(ge=(0,Q.jsx)(`button`,{type:`button`,className:pe,title:i.delete,"aria-label":i.delete,onClick:Y,children:X}),t[89]=i.delete,t[90]=Y,t[91]=ge):ge=t[91];let $;t[92]!==ce||t[93]!==K||t[94]!==le||t[95]!==fe||t[96]!==ge?($=(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:ve,onKeyDown:_e,children:[ce,K,le,fe,ge]}),t[92]=ce,t[93]=K,t[94]=le,t[95]=fe,t[96]=ge,t[97]=$):$=t[97];let be;return t[98]!==s||t[99]!==E||t[100]!==W||t[101]!==g||t[102]!==$||t[103]!==_?(be=(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,className:g,onClick:s,onKeyDown:_,children:[E,W,$]}),t[98]=s,t[99]=E,t[100]=W,t[101]=g,t[102]=$,t[103]=_,t[104]=be):be=t[104],be}function _e(e){return e.stopPropagation()}function ve(e){return e.stopPropagation()}function ye(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 be(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function xe(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:be(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Se(e){await l(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),d()}function Ce(){return q(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,M,`dark:border-edge`)}var we=y();function Te({hasToken:e}){let t=a(i(e=>e.language)).sessions.config,{data:n,isLoading:r}=u(e),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:xe(n.payload.config),[n]),[s,c]=(0,X.useReducer)(we,{form:null,baseline:null}),l=s.form,d=s.baseline,[f,p]=(0,X.useState)(!1),[ee,m]=(0,X.useState)(null),h=(0,X.useRef)(!1),g=(0,X.useRef)(null);b({enabled:e,parsed:o,dirty:h.current,trackedParsedRef:g,dispatch:c,onResetDirty:()=>{h.current=!1}});let te=l&&d&&JSON.stringify(l)!==JSON.stringify(d),_=(0,X.useCallback)(e=>{h.current=!0,c({type:`patch`,patch:e})},[]);return!e||!l?r?(0,Q.jsx)(Y,{children:(0,Q.jsx)(V,{className:`size-4 animate-spin text-fg-muted`})}):null:(0,Q.jsxs)(Y,{children:[(0,Q.jsx)(pe,{icon:W,title:t.title,subtitle:t.hint}),(0,Q.jsxs)(`div`,{className:`mb-4 flex justify-end gap-2`,children:[(0,Q.jsx)(H,{type:`button`,variant:`secondary`,disabled:!te||f,onClick:()=>c({type:`discard`}),children:t.discard}),(0,Q.jsx)(H,{type:`button`,variant:`primary`,disabled:!te||f,onClick:()=>{(async()=>{p(!0),m(null);try{await Se(l),h.current=!1,c({type:`saved`,value:l})}catch(e){m(e instanceof Error?e.message:t.saveError)}finally{p(!1)}})()},children:f?t.saving:t.save})]}),ee?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:ee}):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)(`select`,{className:Ce(),value:l.dmScope,onChange:e=>_({dmScope:e.target.value}),children:[(0,Q.jsx)(`option`,{value:`main`,children:t.dmScopeMain}),(0,Q.jsx)(`option`,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Q.jsx)(`option`,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Q.jsx)(`option`,{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:Ce(),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:Ce(),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 Ee(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 De(e){let t=(0,Z.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:c,onArchive:l,onUnarchive:u,onPin:d,onUnpin:f,onExport:p,onDelete:g}=e,te=i?.status===`archived`,_=i?.status===`pinned`,v;t[0]===c?v=t[1]:(v=e=>!e&&c(),t[0]=c,t[1]=v);let y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(E,{className:q(`xopc-dialog-overlay fixed inset-0 bg-scrim`,C)}),t[2]=y):y=t[2];let b;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(b=q(`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`,de,`dark:border-edge`),t[3]=b):b=t[3];let S;t[4]!==i||t[5]!==o||t[6]!==a?(S=i&&a?(0,Q.jsx)(ne,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=o,t[6]=a,t[7]=S):S=t[7];let w;t[8]!==s.unnamedSession||t[9]!==i?.name?(w=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=w):w=t[10];let D;t[11]===w?D=t[12]:(D=(0,Q.jsx)(x,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:w}),t[11]=w,t[12]=D);let O;t[13]!==S||t[14]!==D?(O=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[S,D]}),t[13]=S,t[14]=D,t[15]=O):O=t[15];let k;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Q.jsx)(R,{className:`size-5`,strokeWidth:1.75}),t[16]=k):k=t[16];let A;t[17]===s.close?A=t[18]:(A=(0,Q.jsx)(T,{asChild:!0,children:(0,Q.jsx)(H,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:k})}),t[17]=s.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]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(M=r?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.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:s.detailMessages}),(0,Q.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(Oe)})]}):null,t[22]=s.detailLoading,t[23]=s.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]!==s.detailExport||t[30]!==p?(P=(0,Q.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:s.detailExport}),t[29]=s.detailExport,t[30]=p,t[31]=P):P=t[31];let F;t[32]!==te||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==l||t[36]!==u?(F=te?(0,Q.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:s.unarchive}):(0,Q.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:l,children:s.archive}),t[32]=te,t[33]=s.archive,t[34]=s.unarchive,t[35]=l,t[36]=u,t[37]=F):F=t[37];let I;t[38]!==_||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==d||t[42]!==f?(I=_?(0,Q.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:s.unpin}):(0,Q.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:s.pin}),t[38]=_,t[39]=s.pin,t[40]=s.unpin,t[41]=d,t[42]=f,t[43]=I):I=t[43];let L;t[44]!==s.delete||t[45]!==g?(L=(0,Q.jsx)(H,{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:s.delete}),t[44]=s.delete,t[45]=g,t[46]=L):L=t[46];let z;t[47]!==P||t[48]!==F||t[49]!==I||t[50]!==L?(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,I,L]})}),t[47]=P,t[48]=F,t[49]=I,t[50]=L,t[51]=z):z=t[51];let B;t[52]!==j||t[53]!==N||t[54]!==z?(B=(0,Q.jsxs)(h,{children:[y,(0,Q.jsxs)(ee,{className:b,"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]!==v||t[58]!==B?(V=(0,Q.jsx)(m,{open:n,onOpenChange:v,children:B}),t[56]=n,t[57]=v,t[58]=B,t[59]=V):V=t[59],V}function Oe(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:Ee(e.content)})]},`${e.timestamp??``}-${e.role}-${Ee(e.content).slice(0,24)}`)}var ke=20;function Ae(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var je=new Set([`all`,`active`,`pinned`,`archived`]),Me=new Set([`grid`,`list`]),Ne=[`sessions`,`settings`];function Pe(e){return e&&Ne.includes(e)?e:`sessions`}function Fe(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function Ie(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function Le(e){let t=(0,Z.c)(11),{s:n,activeTab:r,onChange:i}=e,a=n.tabsAriaLabel,o;t[0]!==r||t[1]!==i?(o=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=Ne.indexOf(r);t<0||i(Ne[(t+(e.key===`ArrowRight`?1:-1)+Ne.length)%Ne.length])},t[0]=r,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==r||t[4]!==i||t[5]!==n?(s=Ne.map(e=>{let t=e===`sessions`?D:g,a=e===r;return(0,Q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a,"aria-controls":`sessions-panel-${e}`,id:`sessions-tab-${e}`,className:q(`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,K.press,a?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>i(e),children:[(0,Q.jsx)(t,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:Fe(n,e)})]},e)}),t[3]=r,t[4]=i,t[5]=n,t[6]=s):s=t[6];let c;return t[7]!==n.tabsAriaLabel||t[8]!==o||t[9]!==s?(c=(0,Q.jsx)(`nav`,{"aria-label":a,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,onKeyDown:o,children:s}),t[7]=n.tabsAriaLabel,t[8]=o,t[9]=s,t[10]=c):c=t[10],c}function Re(e){let t=(0,Z.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 border border-edge 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:Fe(n,r)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:Ie(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 ze(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:je.has(t)?t:`all`,viewMode:Me.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 Be(){let e=a(i(e=>e.language)),t=e.sessions,n=c(e=>e.token),r=!!n,{data:o,mutate:l}=s(r?[`gateway-chat-agents`,n]:null,ue,{revalidateOnFocus:!1}),u=o?.defaultId??`main`,d=o?.items??[],[p,g]=I(),v=Pe(p.get(`tab`)),y=(0,X.useCallback)(e=>{let t=new URLSearchParams(p);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),g(t,{replace:!0})},[p,g]),[b,T]=(0,X.useReducer)(S,p,ze),{searchInput:ne,debouncedSearch:M,statusFilter:P,viewMode:F,channelFilter:L,sessions:R,loading:z,error:V,hasMore:W,stats:J,detailOpen:pe,detailLoading:Y,detailSession:Z,confirmOpen:me,confirmKey:he}=b;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=ne.trim();M!==e&&T({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[ne,M]);let _e=p.toString(),ve=(0,X.useRef)(_e);if(ve.current!==_e){ve.current=_e;let e=p.get(`q`)??``,t=p.get(`status`),n=p.get(`view`),r=(p.get(`channel`)??``).trim(),i=je.has(t)?t:`all`,a=Me.has(n)?n:`grid`,o=e.trim();T({type:`patch`,patch:{...ne===e?{}:{searchInput:e},...M===o?{}:{debouncedSearch:o},...P===i?{}:{statusFilter:i},...F===a?{}:{viewMode:a},...L===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(p),t=M.trim();t?e.set(`q`,t):e.delete(`q`),P===`all`?e.delete(`status`):e.set(`status`,P),F===`grid`?e.delete(`view`):e.set(`view`,F),L?e.set(`channel`,L):e.delete(`channel`),e.toString()!==p.toString()&&g(e,{replace:!0})},[M,p,g,P,F,L]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=!1;return(async()=>{T({type:`patch`,patch:{loading:!0,error:null}});try{let t=await U({limit:ke,offset:0,...M?{search:M}:{},...P===`all`?{}:{status:P},...L?{channel:L}:{}});if(e)return;T({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||T({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||T({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,v,M,P,L,t.loadError]),(0,X.useEffect)(()=>{!r||v!==`sessions`||j().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,v]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=()=>void l();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,v,l]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||T({type:`patch`,patch:{sessions:R.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:Z&&Z.key===t.key?{...Z,name:t.name}:Z}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,v,R,Z]);let ye=(0,X.useCallback)(async()=>{if(!(!r||z||!W)){T({type:`patch`,patch:{loading:!0,error:null}});try{let e=await U({limit:ke,offset:R.length,...M?{search:M}:{},...P===`all`?{}:{status:P},...L?{channel:L}:{}});T({type:`patch`,patch:{sessions:[...R,...e.items],hasMore:e.hasMore}})}catch(e){T({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{T({type:`patch`,patch:{loading:!1}})}}},[r,z,W,R.length,M,P,L,t.loadError]),$=(0,X.useCallback)((e,t)=>{T({type:`patch`,patch:{sessions:R.map(n=>n.key===e?{...n,status:t}:n),detailSession:Z&&Z.key===e?{...Z,status:t}:Z}})},[R,Z]),be=(0,X.useCallback)(async e=>{T({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{T({type:`patch`,patch:{detailSession:await B(e)}})}catch{T({type:`patch`,patch:{detailOpen:!1}})}finally{T({type:`patch`,patch:{detailLoading:!1}})}},[]),xe=e=>{be(e)},Se=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){T({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await le(e),$(e,`archived`);break;case`unarchive`:await N(e),$(e,`active`);break;case`pin`:await ce(e),$(e,`pinned`);break;case`unpin`:await re(e),$(e,`active`);break;case`export`:{let t=await se(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=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ce=async e=>{try{await ae(e),T({type:`patch`,patch:{sessions:R.filter(t=>t.key!==e),detailSession:Z?.key===e?null:Z,...Z?.key===e?{detailOpen:!1}:{}}}),j().then(e=>T({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},Ee={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},Oe=[{key:`all`,label:t.filterAll,icon:D},{key:`active`,label:t.filterActive,icon:w},{key:`pinned`,label:t.filterPinned,icon:oe},{key:`archived`,label:t.filterArchived,icon:te}],Ne=(()=>{let e=Object.entries(J?.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:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-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)(Le,{s:t,activeTab:v,onChange:y}),(0,Q.jsx)(Re,{s:t,id:`settings`,activeTab:v,plain:!0,children:(0,Q.jsx)(Te,{hasToken:r})}),(0,Q.jsxs)(Re,{s:t,id:`sessions`,activeTab:v,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:Oe.map(({key:e,label:t,icon:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":P===e,onClick:()=>T({type:`patch`,patch:{statusFilter:e}}),className:q(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,K.transition,K.focusRingPanel,P===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)(k,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,value:ne,onChange:e=>T({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":M||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!L,onClick:()=>T({type:`patch`,patch:{channelFilter:``}}),className:q(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,K.transition,K.focusRingPanel,L?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),Ne.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":L===e,onClick:()=>T({type:`patch`,patch:{channelFilter:e}}),className:q(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,K.transition,K.focusRingPanel,L===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,J?.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:J.byChannel[e]})]},e))]}),J?(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[J.totalSessions,t.totalSessions],[J.activeSessions,t.activeSessions],[J.pinnedSessions,t.pinnedSessions],[J.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Q.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Q.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,V?(0,Q.jsx)(`div`,{className:`rounded-lg border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,children:V}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Ae(t.sessionCount,{count:R.length})}),(0,Q.jsxs)(`div`,{className:ie,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Q.jsx)(H,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":F===`grid`,onClick:()=>T({type:`patch`,patch:{viewMode:`grid`}}),className:q(G,`size-7 p-0`,F===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,F===`grid`&&`text-accent-fg`),children:(0,Q.jsx)(f,{className:`size-3.5`,strokeWidth:1.5})}),(0,Q.jsx)(H,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":F===`list`,onClick:()=>T({type:`patch`,patch:{viewMode:`list`}}),className:q(G,`size-9 p-0`,F===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,F===`list`&&`text-accent-fg`),children:(0,Q.jsx)(fe,{className:`size-3.5`,strokeWidth:1.5})})]})]}),z&&R.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))}):R.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)(A,{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)(H,{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:q(`grid min-w-0 gap-3`,F===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":M||void 0,children:R.map(e=>{let t=_(e,u);return(0,Q.jsx)(ge,{session:e,variant:F,labels:we,sessionAgentId:t,sessionAgentAvatar:O(t,d),onOpen:()=>xe(e.key),onAction:t=>void Se(e.key,t)},e.key)})}),W?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(H,{type:`button`,variant:`secondary`,disabled:z,onClick:()=>void ye(),children:t.loadMore})}):null]})]})]}),(0,Q.jsx)(De,{open:pe,loading:Y,session:Z,sessionAgentId:Z?_(Z,u):void 0,sessionAgentAvatar:Z?O(_(Z,u),d):void 0,labels:Ee,onClose:()=>{T({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>Z&&void Se(Z.key,`archive`),onUnarchive:()=>Z&&void Se(Z.key,`unarchive`),onPin:()=>Z&&void Se(Z.key,`pin`),onUnpin:()=>Z&&void Se(Z.key,`unpin`),onExport:()=>Z&&void Se(Z.key,`export`),onDelete:()=>Z&&T({type:`patch`,patch:{confirmKey:Z.key,confirmOpen:!0}})}),(0,Q.jsx)(m,{open:me,onOpenChange:e=>T({type:`patch`,patch:{confirmOpen:e}}),children:(0,Q.jsxs)(h,{children:[(0,Q.jsx)(E,{className:q(`xopc-dialog-overlay fixed inset-0 bg-scrim`,C)}),(0,Q.jsxs)(ee,{className:q(`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`,de),children:[(0,Q.jsx)(x,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:he?Ae(t.deleteSessionMessage,{name:R.find(e=>e.key===he)?.name?.trim()||e.chat.newSession}):``}),(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(H,{type:`button`,variant:`secondary`,onClick:()=>T({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Q.jsx)(H,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{he&&Ce(he),T({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Q.jsx)(`div`,{className:`mx-auto w-full max-w-2xl px-4 py-16 text-center text-sm text-fg-muted sm:px-8 lg:max-w-app-main`,children:t.needToken})}export{Be 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{i,o as a,t as o}from"./url-DPEStU4M.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{a as c,n as l}from"./fetch-CkvRO30i.js";import{i as u,r as d}from"./gateway-startup-retry-BkKyRDrF.js";import{Ba as f,Ci as p,Cr as ee,Dr as m,Er as h,Gi as g,Go as te,Hn as _,Ko as v,M as y,N as b,Or as x,P as S,Sn as C,So as w,Sr as T,Tr as E,Un as ne,Va as D,Vn as O,Yi as k,ao as A,ar as j,ci as M,cr as N,di as P,ei as F,es as I,fa as L,fi as R,fo as z,ir as B,ka as V,li as H,lr as re,mr as ie,nr as ae,or as U,pa as oe,po as W,pr as G,rr as se,sr as ce,ti as K,tr as le,ui as q,ur as ue,wa as J,xn as de,za as fe}from"./index-CEZxETzw.js";import{n as pe,t as Y}from"./settings-form-section-DjPD-ErC.js";var X=e(t(),1),Z=n(),Q=r();function me(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 he(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ge(e){let t=(0,Z.c)(105),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:s,onAction:c}=e,l;t[0]!==i.unnamedSession||t[1]!==n.name?(l=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=l):l=t[2];let u=l,d;t[3]===n.name?d=t[4]:(d=n.name?.trim(),t[3]=n.name,t[4]=d);let f=!!d,ee=n.status===`archived`,m=n.status===`pinned`,h=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,g;t[5]===h?g=t[6]:(g=q(`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`,h),t[5]=h,t[6]=g);let _;t[7]===s?_=t[8]:(_=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},t[7]=s,t[8]=_);let y=r===`list`&&`sm:py-3`,b;t[9]===y?b=t[10]:(b=q(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,y),t[9]=y,t[10]=b);let x;t[11]===n.sourceChannel?x=t[12]:(x=(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]=x);let S;t[13]===m?S=t[14]:(S=m?(0,Q.jsx)(oe,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=m,t[14]=S);let C;t[15]===n.updatedAt?C=t[16]:(C=me(n.updatedAt),t[15]=n.updatedAt,t[16]=C);let w;t[17]===C?w=t[18]:(w=(0,Q.jsx)(`span`,{children:C}),t[17]=C,t[18]=w);let T;t[19]!==w||t[20]!==S?(T=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[S,w]}),t[19]=w,t[20]=S,t[21]=T):T=t[21];let E;t[22]!==T||t[23]!==b||t[24]!==x?(E=(0,Q.jsxs)(`div`,{className:b,children:[x,T]}),t[22]=T,t[23]=b,t[24]=x,t[25]=E):E=t[25];let D=r===`list`&&`sm:py-3`,O;t[26]===D?O=t[27]:(O=q(`min-w-0 flex-1 px-3 py-2`,D),t[26]=D,t[27]=O);let k=r===`list`&&`sm:items-start`,A;t[28]===k?A=t[29]:(A=q(`flex gap-3`,k),t[28]=k,t[29]=A);let j;t[30]!==o||t[31]!==a?(j=(0,Q.jsx)(ne,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=o,t[31]=a,t[32]=j):j=t[32];let M;t[33]===u?M=t[34]:(M=(0,Q.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:u,children:u}),t[33]=u,t[34]=M);let N;t[35]!==n.key||t[36]!==f?(N=f?(0,Q.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[35]=n.key,t[36]=f,t[37]=N):N=t[37];let I;t[38]!==M||t[39]!==N?(I=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[M,N]}),t[38]=M,t[39]=N,t[40]=I):I=t[40];let R;t[41]!==A||t[42]!==j||t[43]!==I?(R=(0,Q.jsxs)(`div`,{className:A,children:[j,I]}),t[41]=A,t[42]=j,t[43]=I,t[44]=R):R=t[44];let B;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Q.jsx)(J,{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 H;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,Q.jsx)(P,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=H):H=t[48];let re;t[49]===n.estimatedTokens?re=t[50]:(re=he(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=re);let ie;t[51]===re?ie=t[52]:(ie=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[H,re]}),t[51]=re,t[52]=ie);let ae;t[53]!==V||t[54]!==ie?(ae=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[V,ie]}),t[53]=V,t[54]=ie,t[55]=ae):ae=t[55];let U;t[56]===n.tags?U=t[57]:(U=n.tags.length>0?(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(ye),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]=U);let W;t[58]!==O||t[59]!==R||t[60]!==ae||t[61]!==U?(W=(0,Q.jsxs)(`div`,{className:O,children:[R,ae,U]}),t[58]=O,t[59]=R,t[60]=ae,t[61]=U,t[62]=W):W=t[62];let G;t[63]===c?G=t[64]:(G=()=>c(`continue`),t[63]=c,t[64]=G);let se;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsx)(J,{className:`size-4`,strokeWidth:1.75}),t[65]=se):se=t[65];let ce;t[66]!==i.continueChat||t[67]!==G?(ce=(0,Q.jsx)(`button`,{type:`button`,className:F,title:i.continueChat,"aria-label":i.continueChat,onClick:G,children:se}),t[66]=i.continueChat,t[67]=G,t[68]=ce):ce=t[68];let K;t[69]!==ee||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==c?(K=ee?(0,Q.jsx)(`button`,{type:`button`,className:F,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>c(`unarchive`),children:(0,Q.jsx)(v,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:F,title:i.archive,"aria-label":i.archive,onClick:()=>c(`archive`),children:(0,Q.jsx)(te,{className:`size-4`,strokeWidth:1.75})}),t[69]=ee,t[70]=i.archive,t[71]=i.unarchive,t[72]=c,t[73]=K):K=t[73];let le;t[74]!==m||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==c?(le=m?(0,Q.jsx)(`button`,{type:`button`,className:F,title:i.unpin,"aria-label":i.unpin,onClick:()=>c(`unpin`),children:(0,Q.jsx)(L,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:F,title:i.pin,"aria-label":i.pin,onClick:()=>c(`pin`),children:(0,Q.jsx)(oe,{className:`size-4`,strokeWidth:1.75})}),t[74]=m,t[75]=i.pin,t[76]=i.unpin,t[77]=c,t[78]=le):le=t[78];let ue;t[79]===c?ue=t[80]:(ue=()=>c(`export`),t[79]=c,t[80]=ue);let de;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Q.jsx)(z,{className:`size-4`,strokeWidth:1.75}),t[81]=de):de=t[81];let fe;t[82]!==i.export||t[83]!==ue?(fe=(0,Q.jsx)(`button`,{type:`button`,className:F,title:i.export,"aria-label":i.export,onClick:ue,children:de}),t[82]=i.export,t[83]=ue,t[84]=fe):fe=t[84];let pe;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(pe=q(F,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=pe):pe=t[85];let Y;t[86]===c?Y=t[87]:(Y=()=>c(`delete`),t[86]=c,t[87]=Y);let X;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Q.jsx)(p,{className:`size-4`,strokeWidth:1.75}),t[88]=X):X=t[88];let ge;t[89]!==i.delete||t[90]!==Y?(ge=(0,Q.jsx)(`button`,{type:`button`,className:pe,title:i.delete,"aria-label":i.delete,onClick:Y,children:X}),t[89]=i.delete,t[90]=Y,t[91]=ge):ge=t[91];let $;t[92]!==ce||t[93]!==K||t[94]!==le||t[95]!==fe||t[96]!==ge?($=(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:ve,onKeyDown:_e,children:[ce,K,le,fe,ge]}),t[92]=ce,t[93]=K,t[94]=le,t[95]=fe,t[96]=ge,t[97]=$):$=t[97];let be;return t[98]!==s||t[99]!==E||t[100]!==W||t[101]!==g||t[102]!==$||t[103]!==_?(be=(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,className:g,onClick:s,onKeyDown:_,children:[E,W,$]}),t[98]=s,t[99]=E,t[100]=W,t[101]=g,t[102]=$,t[103]=_,t[104]=be):be=t[104],be}function _e(e){return e.stopPropagation()}function ve(e){return e.stopPropagation()}function ye(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 be(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function xe(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:be(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Se(e){await l(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),d()}function Ce(){return q(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,M,`dark:border-edge`)}var we=y();function Te({hasToken:e}){let t=a(i(e=>e.language)).sessions.config,{data:n,isLoading:r}=u(e),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:xe(n.payload.config),[n]),[s,c]=(0,X.useReducer)(we,{form:null,baseline:null}),l=s.form,d=s.baseline,[f,p]=(0,X.useState)(!1),[ee,m]=(0,X.useState)(null),h=(0,X.useRef)(!1),g=(0,X.useRef)(null);b({enabled:e,parsed:o,dirty:h.current,trackedParsedRef:g,dispatch:c,onResetDirty:()=>{h.current=!1}});let te=l&&d&&JSON.stringify(l)!==JSON.stringify(d),_=(0,X.useCallback)(e=>{h.current=!0,c({type:`patch`,patch:e})},[]);return!e||!l?r?(0,Q.jsx)(Y,{children:(0,Q.jsx)(V,{className:`size-4 animate-spin text-fg-muted`})}):null:(0,Q.jsxs)(Y,{children:[(0,Q.jsx)(pe,{icon:W,title:t.title,subtitle:t.hint}),(0,Q.jsxs)(`div`,{className:`mb-4 flex justify-end gap-2`,children:[(0,Q.jsx)(H,{type:`button`,variant:`secondary`,disabled:!te||f,onClick:()=>c({type:`discard`}),children:t.discard}),(0,Q.jsx)(H,{type:`button`,variant:`primary`,disabled:!te||f,onClick:()=>{(async()=>{p(!0),m(null);try{await Se(l),h.current=!1,c({type:`saved`,value:l})}catch(e){m(e instanceof Error?e.message:t.saveError)}finally{p(!1)}})()},children:f?t.saving:t.save})]}),ee?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:ee}):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)(`select`,{className:Ce(),value:l.dmScope,onChange:e=>_({dmScope:e.target.value}),children:[(0,Q.jsx)(`option`,{value:`main`,children:t.dmScopeMain}),(0,Q.jsx)(`option`,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Q.jsx)(`option`,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Q.jsx)(`option`,{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:Ce(),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:Ce(),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 Ee(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 De(e){let t=(0,Z.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:c,onArchive:l,onUnarchive:u,onPin:d,onUnpin:f,onExport:p,onDelete:g}=e,te=i?.status===`archived`,_=i?.status===`pinned`,v;t[0]===c?v=t[1]:(v=e=>!e&&c(),t[0]=c,t[1]=v);let y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(E,{className:q(`xopc-dialog-overlay fixed inset-0 bg-scrim`,C)}),t[2]=y):y=t[2];let b;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(b=q(`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`,de,`dark:border-edge`),t[3]=b):b=t[3];let S;t[4]!==i||t[5]!==o||t[6]!==a?(S=i&&a?(0,Q.jsx)(ne,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=o,t[6]=a,t[7]=S):S=t[7];let w;t[8]!==s.unnamedSession||t[9]!==i?.name?(w=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=w):w=t[10];let D;t[11]===w?D=t[12]:(D=(0,Q.jsx)(x,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:w}),t[11]=w,t[12]=D);let O;t[13]!==S||t[14]!==D?(O=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[S,D]}),t[13]=S,t[14]=D,t[15]=O):O=t[15];let k;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Q.jsx)(R,{className:`size-5`,strokeWidth:1.75}),t[16]=k):k=t[16];let A;t[17]===s.close?A=t[18]:(A=(0,Q.jsx)(T,{asChild:!0,children:(0,Q.jsx)(H,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:k})}),t[17]=s.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]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(M=r?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.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:s.detailMessages}),(0,Q.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(Oe)})]}):null,t[22]=s.detailLoading,t[23]=s.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]!==s.detailExport||t[30]!==p?(P=(0,Q.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:s.detailExport}),t[29]=s.detailExport,t[30]=p,t[31]=P):P=t[31];let F;t[32]!==te||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==l||t[36]!==u?(F=te?(0,Q.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:s.unarchive}):(0,Q.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:l,children:s.archive}),t[32]=te,t[33]=s.archive,t[34]=s.unarchive,t[35]=l,t[36]=u,t[37]=F):F=t[37];let I;t[38]!==_||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==d||t[42]!==f?(I=_?(0,Q.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:s.unpin}):(0,Q.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:s.pin}),t[38]=_,t[39]=s.pin,t[40]=s.unpin,t[41]=d,t[42]=f,t[43]=I):I=t[43];let L;t[44]!==s.delete||t[45]!==g?(L=(0,Q.jsx)(H,{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:s.delete}),t[44]=s.delete,t[45]=g,t[46]=L):L=t[46];let z;t[47]!==P||t[48]!==F||t[49]!==I||t[50]!==L?(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,I,L]})}),t[47]=P,t[48]=F,t[49]=I,t[50]=L,t[51]=z):z=t[51];let B;t[52]!==j||t[53]!==N||t[54]!==z?(B=(0,Q.jsxs)(h,{children:[y,(0,Q.jsxs)(ee,{className:b,"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]!==v||t[58]!==B?(V=(0,Q.jsx)(m,{open:n,onOpenChange:v,children:B}),t[56]=n,t[57]=v,t[58]=B,t[59]=V):V=t[59],V}function Oe(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:Ee(e.content)})]},`${e.timestamp??``}-${e.role}-${Ee(e.content).slice(0,24)}`)}var ke=20;function Ae(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var je=new Set([`all`,`active`,`pinned`,`archived`]),Me=new Set([`grid`,`list`]),Ne=[`sessions`,`settings`];function Pe(e){return e&&Ne.includes(e)?e:`sessions`}function Fe(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function Ie(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function Le(e){let t=(0,Z.c)(11),{s:n,activeTab:r,onChange:i}=e,a=n.tabsAriaLabel,o;t[0]!==r||t[1]!==i?(o=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=Ne.indexOf(r);t<0||i(Ne[(t+(e.key===`ArrowRight`?1:-1)+Ne.length)%Ne.length])},t[0]=r,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==r||t[4]!==i||t[5]!==n?(s=Ne.map(e=>{let t=e===`sessions`?D:g,a=e===r;return(0,Q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a,"aria-controls":`sessions-panel-${e}`,id:`sessions-tab-${e}`,className:q(`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,K.press,a?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>i(e),children:[(0,Q.jsx)(t,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:Fe(n,e)})]},e)}),t[3]=r,t[4]=i,t[5]=n,t[6]=s):s=t[6];let c;return t[7]!==n.tabsAriaLabel||t[8]!==o||t[9]!==s?(c=(0,Q.jsx)(`nav`,{"aria-label":a,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,onKeyDown:o,children:s}),t[7]=n.tabsAriaLabel,t[8]=o,t[9]=s,t[10]=c):c=t[10],c}function Re(e){let t=(0,Z.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 border border-edge 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:Fe(n,r)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:Ie(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 ze(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:je.has(t)?t:`all`,viewMode:Me.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 Be(){let e=a(i(e=>e.language)),t=e.sessions,n=c(e=>e.token),r=!!n,{data:o,mutate:l}=s(r?[`gateway-chat-agents`,n]:null,ue,{revalidateOnFocus:!1}),u=o?.defaultId??`main`,d=o?.items??[],[p,g]=I(),v=Pe(p.get(`tab`)),y=(0,X.useCallback)(e=>{let t=new URLSearchParams(p);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),g(t,{replace:!0})},[p,g]),[b,T]=(0,X.useReducer)(S,p,ze),{searchInput:ne,debouncedSearch:M,statusFilter:P,viewMode:F,channelFilter:L,sessions:R,loading:z,error:V,hasMore:W,stats:J,detailOpen:pe,detailLoading:Y,detailSession:Z,confirmOpen:me,confirmKey:he}=b;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=ne.trim();M!==e&&T({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[ne,M]);let _e=p.toString(),ve=(0,X.useRef)(_e);if(ve.current!==_e){ve.current=_e;let e=p.get(`q`)??``,t=p.get(`status`),n=p.get(`view`),r=(p.get(`channel`)??``).trim(),i=je.has(t)?t:`all`,a=Me.has(n)?n:`grid`,o=e.trim();T({type:`patch`,patch:{...ne===e?{}:{searchInput:e},...M===o?{}:{debouncedSearch:o},...P===i?{}:{statusFilter:i},...F===a?{}:{viewMode:a},...L===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(p),t=M.trim();t?e.set(`q`,t):e.delete(`q`),P===`all`?e.delete(`status`):e.set(`status`,P),F===`grid`?e.delete(`view`):e.set(`view`,F),L?e.set(`channel`,L):e.delete(`channel`),e.toString()!==p.toString()&&g(e,{replace:!0})},[M,p,g,P,F,L]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=!1;return(async()=>{T({type:`patch`,patch:{loading:!0,error:null}});try{let t=await U({limit:ke,offset:0,...M?{search:M}:{},...P===`all`?{}:{status:P},...L?{channel:L}:{}});if(e)return;T({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||T({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||T({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,v,M,P,L,t.loadError]),(0,X.useEffect)(()=>{!r||v!==`sessions`||j().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,v]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=()=>void l();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,v,l]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||T({type:`patch`,patch:{sessions:R.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:Z&&Z.key===t.key?{...Z,name:t.name}:Z}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,v,R,Z]);let ye=(0,X.useCallback)(async()=>{if(!(!r||z||!W)){T({type:`patch`,patch:{loading:!0,error:null}});try{let e=await U({limit:ke,offset:R.length,...M?{search:M}:{},...P===`all`?{}:{status:P},...L?{channel:L}:{}});T({type:`patch`,patch:{sessions:[...R,...e.items],hasMore:e.hasMore}})}catch(e){T({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{T({type:`patch`,patch:{loading:!1}})}}},[r,z,W,R.length,M,P,L,t.loadError]),$=(0,X.useCallback)((e,t)=>{T({type:`patch`,patch:{sessions:R.map(n=>n.key===e?{...n,status:t}:n),detailSession:Z&&Z.key===e?{...Z,status:t}:Z}})},[R,Z]),be=(0,X.useCallback)(async e=>{T({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{T({type:`patch`,patch:{detailSession:await B(e)}})}catch{T({type:`patch`,patch:{detailOpen:!1}})}finally{T({type:`patch`,patch:{detailLoading:!1}})}},[]),xe=e=>{be(e)},Se=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){T({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await le(e),$(e,`archived`);break;case`unarchive`:await N(e),$(e,`active`);break;case`pin`:await ce(e),$(e,`pinned`);break;case`unpin`:await re(e),$(e,`active`);break;case`export`:{let t=await se(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=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ce=async e=>{try{await ae(e),T({type:`patch`,patch:{sessions:R.filter(t=>t.key!==e),detailSession:Z?.key===e?null:Z,...Z?.key===e?{detailOpen:!1}:{}}}),j().then(e=>T({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},Ee={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},Oe=[{key:`all`,label:t.filterAll,icon:D},{key:`active`,label:t.filterActive,icon:w},{key:`pinned`,label:t.filterPinned,icon:oe},{key:`archived`,label:t.filterArchived,icon:te}],Ne=(()=>{let e=Object.entries(J?.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:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-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)(Le,{s:t,activeTab:v,onChange:y}),(0,Q.jsx)(Re,{s:t,id:`settings`,activeTab:v,plain:!0,children:(0,Q.jsx)(Te,{hasToken:r})}),(0,Q.jsxs)(Re,{s:t,id:`sessions`,activeTab:v,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:Oe.map(({key:e,label:t,icon:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":P===e,onClick:()=>T({type:`patch`,patch:{statusFilter:e}}),className:q(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,K.transition,K.focusRingPanel,P===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)(k,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,value:ne,onChange:e=>T({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":M||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!L,onClick:()=>T({type:`patch`,patch:{channelFilter:``}}),className:q(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,K.transition,K.focusRingPanel,L?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),Ne.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":L===e,onClick:()=>T({type:`patch`,patch:{channelFilter:e}}),className:q(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,K.transition,K.focusRingPanel,L===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,J?.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:J.byChannel[e]})]},e))]}),J?(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[J.totalSessions,t.totalSessions],[J.activeSessions,t.activeSessions],[J.pinnedSessions,t.pinnedSessions],[J.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Q.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Q.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,V?(0,Q.jsx)(`div`,{className:`rounded-lg border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,children:V}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Ae(t.sessionCount,{count:R.length})}),(0,Q.jsxs)(`div`,{className:ie,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Q.jsx)(H,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":F===`grid`,onClick:()=>T({type:`patch`,patch:{viewMode:`grid`}}),className:q(G,`size-7 p-0`,F===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,F===`grid`&&`text-accent-fg`),children:(0,Q.jsx)(f,{className:`size-3.5`,strokeWidth:1.5})}),(0,Q.jsx)(H,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":F===`list`,onClick:()=>T({type:`patch`,patch:{viewMode:`list`}}),className:q(G,`size-9 p-0`,F===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,F===`list`&&`text-accent-fg`),children:(0,Q.jsx)(fe,{className:`size-3.5`,strokeWidth:1.5})})]})]}),z&&R.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))}):R.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)(A,{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)(H,{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:q(`grid min-w-0 gap-3`,F===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":M||void 0,children:R.map(e=>{let t=_(e,u);return(0,Q.jsx)(ge,{session:e,variant:F,labels:we,sessionAgentId:t,sessionAgentAvatar:O(t,d),onOpen:()=>xe(e.key),onAction:t=>void Se(e.key,t)},e.key)})}),W?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(H,{type:`button`,variant:`secondary`,disabled:z,onClick:()=>void ye(),children:t.loadMore})}):null]})]})]}),(0,Q.jsx)(De,{open:pe,loading:Y,session:Z,sessionAgentId:Z?_(Z,u):void 0,sessionAgentAvatar:Z?O(_(Z,u),d):void 0,labels:Ee,onClose:()=>{T({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>Z&&void Se(Z.key,`archive`),onUnarchive:()=>Z&&void Se(Z.key,`unarchive`),onPin:()=>Z&&void Se(Z.key,`pin`),onUnpin:()=>Z&&void Se(Z.key,`unpin`),onExport:()=>Z&&void Se(Z.key,`export`),onDelete:()=>Z&&T({type:`patch`,patch:{confirmKey:Z.key,confirmOpen:!0}})}),(0,Q.jsx)(m,{open:me,onOpenChange:e=>T({type:`patch`,patch:{confirmOpen:e}}),children:(0,Q.jsxs)(h,{children:[(0,Q.jsx)(E,{className:q(`xopc-dialog-overlay fixed inset-0 bg-scrim`,C)}),(0,Q.jsxs)(ee,{className:q(`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`,de),children:[(0,Q.jsx)(x,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:he?Ae(t.deleteSessionMessage,{name:R.find(e=>e.key===he)?.name?.trim()||e.chat.newSession}):``}),(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(H,{type:`button`,variant:`secondary`,onClick:()=>T({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Q.jsx)(H,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{he&&Ce(he),T({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Q.jsx)(`div`,{className:`mx-auto w-full max-w-2xl px-4 py-16 text-center text-sm text-fg-muted sm:px-8 lg:max-w-app-main`,children:t.needToken})}export{Be as SessionsPage};
|