@xopcai/xopc 0.0.104 → 0.0.105

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.
Files changed (113) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/agents-XzgIVKcI.js +396 -0
  4. package/dist/gateway/static/root/assets/{apps-page-L-IwQTe0.js → apps-page-B7Us3RMl.js} +1 -1
  5. package/dist/gateway/static/root/assets/channels-settings-BgeV6fzw.js +1 -0
  6. package/dist/gateway/static/root/assets/cron-page-DKGHEeAU.js +1 -0
  7. package/dist/gateway/static/root/assets/{dist-C6vclgEL.js → dist-DJDkNhu5.js} +1 -1
  8. package/dist/gateway/static/root/assets/{extension-debug-page-D4JYAbsX.js → extension-debug-page-DI1XJTJi.js} +1 -1
  9. package/dist/gateway/static/root/assets/{extension-page-_T62gi6e.js → extension-page-SuafGTT_.js} +1 -1
  10. package/dist/gateway/static/root/assets/{extension-settings-page-CkJbjyM-.js → extension-settings-page-cKmGax9v.js} +1 -1
  11. package/dist/gateway/static/root/assets/{fetch-B5aiIguv.js → fetch-CkvRO30i.js} +1 -1
  12. package/dist/gateway/static/root/assets/{gateway-startup-retry-DqmLXhs6.js → gateway-startup-retry-BkKyRDrF.js} +1 -1
  13. package/dist/gateway/static/root/assets/{heartbeat-config-api-HwJV1K_Y.js → heartbeat-config-api-CRiDcxtt.js} +1 -1
  14. package/dist/gateway/static/root/assets/index-50FVtgXU.js +4845 -0
  15. package/dist/gateway/static/root/assets/{logs-page-DsjtTjBy.js → logs-page-DM8o5-Bm.js} +2 -2
  16. package/dist/gateway/static/root/assets/{note-detail-page-B2V7RhgD.js → note-detail-page-j53jtvq9.js} +54 -54
  17. package/dist/gateway/static/root/assets/{note-time-BG8GCTr4.js → note-time-Ck2H2Qpw.js} +1 -1
  18. package/dist/gateway/static/root/assets/{notes-page-xrcVBQ6Z.js → notes-page-CsWIw35Q.js} +1 -1
  19. package/dist/gateway/static/root/assets/{schema-form-S-QUvhul.js → schema-form-BvmGNxiJ.js} +1 -1
  20. package/dist/gateway/static/root/assets/sessions-page-CLPsbyOW.js +1 -0
  21. package/dist/gateway/static/root/assets/{settings-advanced-gate-DujQl9c7.js → settings-advanced-gate-DRdayl8P.js} +1 -1
  22. package/dist/gateway/static/root/assets/{settings-form-section-r1V7dRV6.js → settings-form-section-BlIYg2gZ.js} +1 -1
  23. package/dist/gateway/static/root/assets/settings-page-CRGHT_bm.js +3 -0
  24. package/dist/gateway/static/root/assets/{share-preview-page-DOFy0FNt.js → share-preview-page-BlT6Akvk.js} +1 -1
  25. package/dist/gateway/static/root/assets/skills-page-Ce-RIH2y.js +2 -0
  26. package/dist/gateway/static/root/assets/{theme-store-Bo3j5Ovv.js → theme-store-DYgVdRB4.js} +1 -1
  27. package/dist/gateway/static/root/assets/url-DPEStU4M.js +3 -0
  28. package/dist/gateway/static/root/assets/{voice-api-key-field-AjmUAlEQ.js → voice-api-key-field-CJGTidqc.js} +1 -1
  29. package/dist/gateway/static/root/assets/{workflow-page.utils-DLEJ92gK.js → workflow-page.utils-_sjXCMvi.js} +1 -1
  30. package/dist/gateway/static/root/assets/workflows-page-o63aaARK.js +27 -0
  31. package/dist/gateway/static/root/index.html +5 -5
  32. package/dist/package.js +1 -1
  33. package/dist/src/agent/context/workspace-seed.js +1 -1
  34. package/dist/src/agent/inbound/turn-dispatcher.d.ts +2 -0
  35. package/dist/src/agent/inbound/turn-dispatcher.js +1 -0
  36. package/dist/src/agent/inbound/turn-dispatcher.js.map +1 -1
  37. package/dist/src/agent/prompt/memory/index.js +30 -2
  38. package/dist/src/agent/prompt/memory/index.js.map +1 -1
  39. package/dist/src/agent/service/direct-turn-helpers.d.ts +2 -0
  40. package/dist/src/agent/service/direct-turn-helpers.js +5 -2
  41. package/dist/src/agent/service/direct-turn-helpers.js.map +1 -1
  42. package/dist/src/agent/service/process-direct-streaming.d.ts +2 -0
  43. package/dist/src/agent/service/process-direct-streaming.js +15 -1
  44. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  45. package/dist/src/agent/service.js +2 -1
  46. package/dist/src/agent/service.js.map +1 -1
  47. package/dist/src/agent/service.types.d.ts +3 -0
  48. package/dist/src/agent/skills/hub-pull.js +1 -1
  49. package/dist/src/agent/source-context/index.d.ts +2 -0
  50. package/dist/src/agent/source-context/index.js +3 -0
  51. package/dist/src/agent/source-context/injector.d.ts +3 -0
  52. package/dist/src/agent/source-context/injector.js +36 -0
  53. package/dist/src/agent/source-context/injector.js.map +1 -0
  54. package/dist/src/agent/source-context/types.d.ts +19 -0
  55. package/dist/src/agent/source-context/types.js +10 -0
  56. package/dist/src/agent/source-context/types.js.map +1 -0
  57. package/dist/src/agent/tools/factory.js +5 -5
  58. package/dist/src/agent/tools/index.js +3 -3
  59. package/dist/src/agent/tools/session-search-tool.js +1 -1
  60. package/dist/src/agent/tools/shell.js +1 -1
  61. package/dist/src/agent/tools/web-extract.js +2 -2
  62. package/dist/src/agent/tools/web.js +1 -1
  63. package/dist/src/browser/actions/extension-registry-bridge.js +1 -1
  64. package/dist/src/browser/actions/registry.js +2 -2
  65. package/dist/src/browser/cdp-local-launcher.js +1 -1
  66. package/dist/src/browser/index.js +3 -3
  67. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  68. package/dist/src/browser/providers/cloakbrowser.js +1 -1
  69. package/dist/src/cli/commands/browser-cli-helpers.js +1 -1
  70. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  71. package/dist/src/config/paths.d.ts +1 -0
  72. package/dist/src/config/paths.js +5 -1
  73. package/dist/src/config/paths.js.map +1 -1
  74. package/dist/src/document-understanding/extract.d.ts +13 -0
  75. package/dist/src/document-understanding/extract.js +63 -0
  76. package/dist/src/document-understanding/extract.js.map +1 -0
  77. package/dist/src/gateway/hono/routes/notes.js +46 -27
  78. package/dist/src/gateway/hono/routes/notes.js.map +1 -1
  79. package/dist/src/gateway/service.js +11 -0
  80. package/dist/src/gateway/service.js.map +1 -1
  81. package/dist/src/mcp/channel-bridge.js +1 -1
  82. package/dist/src/notes/agent-context.d.ts +40 -0
  83. package/dist/src/notes/agent-context.js +383 -0
  84. package/dist/src/notes/agent-context.js.map +1 -0
  85. package/dist/src/notes/index.d.ts +2 -0
  86. package/dist/src/notes/index.js +2 -1
  87. package/dist/src/notes/service.d.ts +5 -0
  88. package/dist/src/notes/service.js +22 -0
  89. package/dist/src/notes/service.js.map +1 -1
  90. package/dist/src/notes/store.js +2 -0
  91. package/dist/src/notes/store.js.map +1 -1
  92. package/dist/src/share/share-thumbnail.js +1 -1
  93. package/dist/src/storage/sqlite/index.d.ts +1 -0
  94. package/dist/src/storage/sqlite/index.js +2 -1
  95. package/dist/src/storage/sqlite/migrations/005_add_note_agent_contexts.sql +10 -0
  96. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  97. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  98. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  99. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  100. package/dist/src/storage/sqlite/note-agent-context-repository.d.ts +10 -0
  101. package/dist/src/storage/sqlite/note-agent-context-repository.js +35 -0
  102. package/dist/src/storage/sqlite/note-agent-context-repository.js.map +1 -0
  103. package/dist/src/storage/sqlite/schema.js +1 -1
  104. package/package.json +3 -3
  105. package/dist/gateway/static/root/assets/agents-CvsBrBfi.js +0 -396
  106. package/dist/gateway/static/root/assets/channels-settings-D95KuPeP.js +0 -1
  107. package/dist/gateway/static/root/assets/cron-page-CfkWXDAI.js +0 -1
  108. package/dist/gateway/static/root/assets/index-DvTb6wNR.js +0 -4845
  109. package/dist/gateway/static/root/assets/sessions-page-CrQer6Au.js +0 -1
  110. package/dist/gateway/static/root/assets/settings-page-C9nrONQ2.js +0 -3
  111. package/dist/gateway/static/root/assets/skills-page-DmTsrs_a.js +0 -2
  112. package/dist/gateway/static/root/assets/url-WgQIjFZu.js +0 -3
  113. package/dist/gateway/static/root/assets/workflows-page-BnjjKrM1.js +0 -27
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-WgQIjFZu.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{a as c,n as l}from"./fetch-B5aiIguv.js";import{i as u,r as d}from"./gateway-startup-retry-DqmLXhs6.js";import{$n as f,$r as p,Bn as m,Cr as ee,Da as h,Er as g,La as te,M as _,N as v,P as y,Qo as b,Qr as x,Ra as S,Sa as C,Tr as w,Ui as T,Uo as E,Vn as ne,Wo as D,ar as O,bn as re,bo as k,br as A,ci as j,cr as M,da as N,do as P,dr as F,er as I,fr as L,ir as R,li as z,nr as ie,oi as B,or as ae,qi as oe,ro as se,rr as V,si as H,sr as ce,tr as le,ua as ue,ui as U,uo as de,wr as W,xi as G,xr as K,yn as q,za as fe,zn as J}from"./index-DvTb6wNR.js";import{n as pe,t as Y}from"./settings-form-section-r1V7dRV6.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,p=n.status===`archived`,m=n.status===`pinned`,ee=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,h;t[5]===ee?h=t[6]:(h=j(`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`,ee),t[5]=ee,t[6]=h);let g;t[7]===s?g=t[8]:(g=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},t[7]=s,t[8]=g);let te=r===`list`&&`sm:py-3`,_;t[9]===te?_=t[10]:(_=j(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,te),t[9]=te,t[10]=_);let v;t[11]===n.sourceChannel?v=t[12]:(v=(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]=v);let y;t[13]===m?y=t[14]:(y=m?(0,Q.jsx)(N,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=m,t[14]=y);let b;t[15]===n.updatedAt?b=t[16]:(b=me(n.updatedAt),t[15]=n.updatedAt,t[16]=b);let S;t[17]===b?S=t[18]:(S=(0,Q.jsx)(`span`,{children:b}),t[17]=b,t[18]=S);let w;t[19]!==S||t[20]!==y?(w=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[y,S]}),t[19]=S,t[20]=y,t[21]=w):w=t[21];let T;t[22]!==w||t[23]!==_||t[24]!==v?(T=(0,Q.jsxs)(`div`,{className:_,children:[v,w]}),t[22]=w,t[23]=_,t[24]=v,t[25]=T):T=t[25];let O=r===`list`&&`sm:py-3`,re;t[26]===O?re=t[27]:(re=j(`min-w-0 flex-1 px-3 py-2`,O),t[26]=O,t[27]=re);let k=r===`list`&&`sm:items-start`,A;t[28]===k?A=t[29]:(A=j(`flex gap-3`,k),t[28]=k,t[29]=A);let M;t[30]!==o||t[31]!==a?(M=(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]=M):M=t[32];let P;t[33]===u?P=t[34]:(P=(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]=P);let F;t[35]!==n.key||t[36]!==f?(F=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]=F):F=t[37];let I;t[38]!==P||t[39]!==F?(I=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[P,F]}),t[38]=P,t[39]=F,t[40]=I):I=t[40];let L;t[41]!==A||t[42]!==M||t[43]!==I?(L=(0,Q.jsxs)(`div`,{className:A,children:[M,I]}),t[41]=A,t[42]=M,t[43]=I,t[44]=L):L=t[44];let R;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Q.jsx)(C,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=R):R=t[45];let ie;t[46]===n.messageCount?ie=t[47]:(ie=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[R,n.messageCount]}),t[46]=n.messageCount,t[47]=ie);let B;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Q.jsx)(z,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=B):B=t[48];let ae;t[49]===n.estimatedTokens?ae=t[50]:(ae=he(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=ae);let oe;t[51]===ae?oe=t[52]:(oe=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[B,ae]}),t[51]=ae,t[52]=oe);let se;t[53]!==ie||t[54]!==oe?(se=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[ie,oe]}),t[53]=ie,t[54]=oe,t[55]=se):se=t[55];let V;t[56]===n.tags?V=t[57]:(V=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]=V);let H;t[58]!==re||t[59]!==L||t[60]!==se||t[61]!==V?(H=(0,Q.jsxs)(`div`,{className:re,children:[L,se,V]}),t[58]=re,t[59]=L,t[60]=se,t[61]=V,t[62]=H):H=t[62];let ce;t[63]===c?ce=t[64]:(ce=()=>c(`continue`),t[63]=c,t[64]=ce);let le;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,Q.jsx)(C,{className:`size-4`,strokeWidth:1.75}),t[65]=le):le=t[65];let U;t[66]!==i.continueChat||t[67]!==ce?(U=(0,Q.jsx)(`button`,{type:`button`,className:x,title:i.continueChat,"aria-label":i.continueChat,onClick:ce,children:le}),t[66]=i.continueChat,t[67]=ce,t[68]=U):U=t[68];let W;t[69]!==p||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==c?(W=p?(0,Q.jsx)(`button`,{type:`button`,className:x,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>c(`unarchive`),children:(0,Q.jsx)(D,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:x,title:i.archive,"aria-label":i.archive,onClick:()=>c(`archive`),children:(0,Q.jsx)(E,{className:`size-4`,strokeWidth:1.75})}),t[69]=p,t[70]=i.archive,t[71]=i.unarchive,t[72]=c,t[73]=W):W=t[73];let K;t[74]!==m||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==c?(K=m?(0,Q.jsx)(`button`,{type:`button`,className:x,title:i.unpin,"aria-label":i.unpin,onClick:()=>c(`unpin`),children:(0,Q.jsx)(ue,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:x,title:i.pin,"aria-label":i.pin,onClick:()=>c(`pin`),children:(0,Q.jsx)(N,{className:`size-4`,strokeWidth:1.75})}),t[74]=m,t[75]=i.pin,t[76]=i.unpin,t[77]=c,t[78]=K):K=t[78];let q;t[79]===c?q=t[80]:(q=()=>c(`export`),t[79]=c,t[80]=q);let fe;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,Q.jsx)(de,{className:`size-4`,strokeWidth:1.75}),t[81]=fe):fe=t[81];let J;t[82]!==i.export||t[83]!==q?(J=(0,Q.jsx)(`button`,{type:`button`,className:x,title:i.export,"aria-label":i.export,onClick:q,children:fe}),t[82]=i.export,t[83]=q,t[84]=J):J=t[84];let pe;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(pe=j(x,`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)(G,{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]!==U||t[93]!==W||t[94]!==K||t[95]!==J||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:[U,W,K,J,ge]}),t[92]=U,t[93]=W,t[94]=K,t[95]=J,t[96]=ge,t[97]=$):$=t[97];let be;return t[98]!==s||t[99]!==T||t[100]!==H||t[101]!==h||t[102]!==$||t[103]!==g?(be=(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,className:h,onClick:s,onKeyDown:g,children:[T,H,$]}),t[98]=s,t[99]=T,t[100]=H,t[101]=h,t[102]=$,t[103]=g,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 j(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,B,`dark:border-edge`)}var we=_();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),[m,ee]=(0,X.useState)(null),g=(0,X.useRef)(!1),te=(0,X.useRef)(null);v({enabled:e,parsed:o,dirty:g.current,trackedParsedRef:te,dispatch:c,onResetDirty:()=>{g.current=!1}});let _=l&&d&&JSON.stringify(l)!==JSON.stringify(d),y=(0,X.useCallback)(e=>{g.current=!0,c({type:`patch`,patch:e})},[]);return!e||!l?r?(0,Q.jsx)(Y,{children:(0,Q.jsx)(h,{className:`size-4 animate-spin text-fg-muted`})}):null:(0,Q.jsxs)(Y,{children:[(0,Q.jsx)(pe,{icon:P,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:!_||f,onClick:()=>c({type:`discard`}),children:t.discard}),(0,Q.jsx)(H,{type:`button`,variant:`primary`,disabled:!_||f,onClick:()=>{(async()=>{p(!0),ee(null);try{await Se(l),g.current=!1,c({type:`saved`,value:l})}catch(e){ee(e instanceof Error?e.message:t.saveError)}finally{p(!1)}})()},children:f?t.saving:t.save})]}),m?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:m}):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=>y({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();y({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();y({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:m}=e,h=i?.status===`archived`,te=i?.status===`pinned`,_;t[0]===c?_=t[1]:(_=e=>!e&&c(),t[0]=c,t[1]=_);let v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(ee,{className:j(`xopc-dialog-overlay fixed inset-0 bg-scrim`,re)}),t[2]=v):v=t[2];let y;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(y=j(`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`,q,`dark:border-edge`),t[3]=y):y=t[3];let b;t[4]!==i||t[5]!==o||t[6]!==a?(b=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]=b):b=t[7];let x;t[8]!==s.unnamedSession||t[9]!==i?.name?(x=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=x):x=t[10];let S;t[11]===x?S=t[12]:(S=(0,Q.jsx)(g,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:x}),t[11]=x,t[12]=S);let C;t[13]!==b||t[14]!==S?(C=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[b,S]}),t[13]=b,t[14]=S,t[15]=C):C=t[15];let T;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Q.jsx)(U,{className:`size-5`,strokeWidth:1.75}),t[16]=T):T=t[16];let E;t[17]===s.close?E=t[18]:(E=(0,Q.jsx)(A,{asChild:!0,children:(0,Q.jsx)(H,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:T})}),t[17]=s.close,t[18]=E);let D;t[19]!==C||t[20]!==E?(D=(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:[C,E]}),t[19]=C,t[20]=E,t[21]=D):D=t[21];let O;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(O=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]=O):O=t[26];let k;t[27]===O?k=t[28]:(k=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:O}),t[27]=O,t[28]=k);let M;t[29]!==s.detailExport||t[30]!==p?(M=(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]=M):M=t[31];let N;t[32]!==h||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==l||t[36]!==u?(N=h?(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]=h,t[33]=s.archive,t[34]=s.unarchive,t[35]=l,t[36]=u,t[37]=N):N=t[37];let P;t[38]!==te||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==d||t[42]!==f?(P=te?(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]=te,t[39]=s.pin,t[40]=s.unpin,t[41]=d,t[42]=f,t[43]=P):P=t[43];let F;t[44]!==s.delete||t[45]!==m?(F=(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:m,children:s.delete}),t[44]=s.delete,t[45]=m,t[46]=F):F=t[46];let I;t[47]!==M||t[48]!==N||t[49]!==P||t[50]!==F?(I=(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:[M,N,P,F]})}),t[47]=M,t[48]=N,t[49]=P,t[50]=F,t[51]=I):I=t[51];let L;t[52]!==D||t[53]!==k||t[54]!==I?(L=(0,Q.jsxs)(W,{children:[v,(0,Q.jsxs)(K,{className:y,"aria-describedby":void 0,children:[D,k,I]})]}),t[52]=D,t[53]=k,t[54]=I,t[55]=L):L=t[55];let R;return t[56]!==n||t[57]!==_||t[58]!==L?(R=(0,Q.jsx)(w,{open:n,onOpenChange:_,children:L}),t[56]=n,t[57]=_,t[58]=L,t[59]=R):R=t[59],R}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`?fe:T,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:j(`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`,p.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,M,{revalidateOnFocus:!1}),u=o?.defaultId??`main`,d=o?.items??[],[h,_]=b(),v=Pe(h.get(`tab`)),x=(0,X.useCallback)(e=>{let t=new URLSearchParams(h);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),_(t,{replace:!0})},[h,_]),[C,T]=(0,X.useReducer)(y,h,ze),{searchInput:ne,debouncedSearch:D,statusFilter:A,viewMode:P,channelFilter:z,sessions:B,loading:ue,error:U,hasMore:de,stats:G,detailOpen:pe,detailLoading:Y,detailSession:Z,confirmOpen:me,confirmKey:he}=C;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=ne.trim();D!==e&&T({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[ne,D]);let _e=h.toString(),ve=(0,X.useRef)(_e);if(ve.current!==_e){ve.current=_e;let e=h.get(`q`)??``,t=h.get(`status`),n=h.get(`view`),r=(h.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},...D===o?{}:{debouncedSearch:o},...A===i?{}:{statusFilter:i},...P===a?{}:{viewMode:a},...z===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(h),t=D.trim();t?e.set(`q`,t):e.delete(`q`),A===`all`?e.delete(`status`):e.set(`status`,A),P===`grid`?e.delete(`view`):e.set(`view`,P),z?e.set(`channel`,z):e.delete(`channel`),e.toString()!==h.toString()&&_(e,{replace:!0})},[D,h,_,A,P,z]),(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 R({limit:ke,offset:0,...D?{search:D}:{},...A===`all`?{}:{status:A},...z?{channel:z}:{}});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,D,A,z,t.loadError]),(0,X.useEffect)(()=>{!r||v!==`sessions`||V().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:B.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,B,Z]);let ye=(0,X.useCallback)(async()=>{if(!(!r||ue||!de)){T({type:`patch`,patch:{loading:!0,error:null}});try{let e=await R({limit:ke,offset:B.length,...D?{search:D}:{},...A===`all`?{}:{status:A},...z?{channel:z}:{}});T({type:`patch`,patch:{sessions:[...B,...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,ue,de,B.length,D,A,z,t.loadError]),$=(0,X.useCallback)((e,t)=>{T({type:`patch`,patch:{sessions:B.map(n=>n.key===e?{...n,status:t}:n),detailSession:Z&&Z.key===e?{...Z,status:t}:Z}})},[B,Z]),be=(0,X.useCallback)(async e=>{T({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{T({type:`patch`,patch:{detailSession:await ie(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 f(e),$(e,`archived`);break;case`unarchive`:await ae(e),$(e,`active`);break;case`pin`:await O(e),$(e,`pinned`);break;case`unpin`:await ce(e),$(e,`active`);break;case`export`:{let t=await le(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}V().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ce=async e=>{try{await I(e),T({type:`patch`,patch:{sessions:B.filter(t=>t.key!==e),detailSession:Z?.key===e?null:Z,...Z?.key===e?{detailOpen:!1}:{}}}),V().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:fe},{key:`active`,label:t.filterActive,icon:k},{key:`pinned`,label:t.filterPinned,icon:N},{key:`archived`,label:t.filterArchived,icon:E}],Ne=(()=>{let e=Object.entries(G?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Q.jsxs)(`div`,{className:`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:x}),(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":A===e,onClick:()=>T({type:`patch`,patch:{statusFilter:e}}),className:j(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,p.transition,p.focusRingPanel,A===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(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)(oe,{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":D||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!z,onClick:()=>T({type:`patch`,patch:{channelFilter:``}}),className:j(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,p.transition,p.focusRingPanel,z?`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":z===e,onClick:()=>T({type:`patch`,patch:{channelFilter:e}}),className:j(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,p.transition,p.focusRingPanel,z===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,G?.byChannel?.[e]==null?null:(0,Q.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:G.byChannel[e]})]},e))]}),G?(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[G.totalSessions,t.totalSessions],[G.activeSessions,t.activeSessions],[G.pinnedSessions,t.pinnedSessions],[G.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Q.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Q.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,U?(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:U}):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:B.length})}),(0,Q.jsxs)(`div`,{className:L,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Q.jsx)(H,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":P===`grid`,onClick:()=>T({type:`patch`,patch:{viewMode:`grid`}}),className:j(F,`size-7 p-0`,P===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,P===`grid`&&`text-accent-fg`),children:(0,Q.jsx)(S,{className:`size-3.5`,strokeWidth:1.5})}),(0,Q.jsx)(H,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":P===`list`,onClick:()=>T({type:`patch`,patch:{viewMode:`list`}}),className:j(F,`size-9 p-0`,P===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,P===`list`&&`text-accent-fg`),children:(0,Q.jsx)(te,{className:`size-3.5`,strokeWidth:1.5})})]})]}),ue&&B.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))}):B.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)(se,{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:j(`grid min-w-0 gap-3`,P===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":D||void 0,children:B.map(e=>{let t=m(e,u);return(0,Q.jsx)(ge,{session:e,variant:P,labels:we,sessionAgentId:t,sessionAgentAvatar:J(t,d),onOpen:()=>xe(e.key),onAction:t=>void Se(e.key,t)},e.key)})}),de?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(H,{type:`button`,variant:`secondary`,disabled:ue,onClick:()=>void ye(),children:t.loadMore})}):null]})]})]}),(0,Q.jsx)(De,{open:pe,loading:Y,session:Z,sessionAgentId:Z?m(Z,u):void 0,sessionAgentAvatar:Z?J(m(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)(w,{open:me,onOpenChange:e=>T({type:`patch`,patch:{confirmOpen:e}}),children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(ee,{className:j(`xopc-dialog-overlay fixed inset-0 bg-scrim`,re)}),(0,Q.jsxs)(K,{className:j(`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`,q),children:[(0,Q.jsx)(g,{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:B.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};