@xopcai/xopc 0.0.407 → 0.0.408

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 (156) 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/{agent-avatar-dicebear-CPNoFyoV.js → agent-avatar-dicebear-B0em9Xfs.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BB0O3b4I.js → agent-defaults-settings-panel-CtE1h2xU.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agents-Y7XtlqVm.js → agents-DAgFeHEb.js} +3 -3
  6. package/dist/gateway/static/root/assets/{app-management-settings-panel-BOAkMTQ7.js → app-management-settings-panel-B1qR8ElB.js} +1 -1
  7. package/dist/gateway/static/root/assets/{appearance-settings-BWPt4-vh.js → appearance-settings-GA819R2q.js} +1 -1
  8. package/dist/gateway/static/root/assets/{apps-page-Ln5N1PK3.js → apps-page-DZptDZ7h.js} +1 -1
  9. package/dist/gateway/static/root/assets/{archive-plugin-CNjE6PYZ.js → archive-plugin-BjWaZIHe.js} +1 -1
  10. package/dist/gateway/static/root/assets/{automations-page-BsP4j7Nw.js → automations-page-IkrLEkMb.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automations-workspace-lq17XY3n.js → automations-workspace-qfEjk_ws.js} +1 -1
  12. package/dist/gateway/static/root/assets/{binary-plugins-AFWJskT6.js → binary-plugins-DKy1DC62.js} +1 -1
  13. package/dist/gateway/static/root/assets/{block-editor-SQ53S4oy.js → block-editor-4E-OdmNm.js} +1 -1
  14. package/dist/gateway/static/root/assets/{browser-automation-inputs-C2SC9h-c.js → browser-automation-inputs-Bs-AkQ1q.js} +1 -1
  15. package/dist/gateway/static/root/assets/{browser-automations-page-kRoqj1qn.js → browser-automations-page-D0Vbe1Q_.js} +1 -1
  16. package/dist/gateway/static/root/assets/{browser-settings-page-dZhjL3oj.js → browser-settings-page-BXCNNpQd.js} +1 -1
  17. package/dist/gateway/static/root/assets/{capabilities-page-Dnp_ilKR.js → capabilities-page-DMtxaYgt.js} +2 -2
  18. package/dist/gateway/static/root/assets/{capabilities-settings-panel-BA9kBBqE.js → capabilities-settings-panel-BlWrMG6Z.js} +1 -1
  19. package/dist/gateway/static/root/assets/{capability-header-actions-Cq5XWEDs.js → capability-header-actions-BMffrHhT.js} +1 -1
  20. package/dist/gateway/static/root/assets/channels-C96r2Rqq.js +1 -0
  21. package/dist/gateway/static/root/assets/{chat-terminal-dock-BC4EyhTx.js → chat-terminal-dock-vb3kBSeI.js} +1 -1
  22. package/dist/gateway/static/root/assets/{computer-settings-page-MxcoTOP1.js → computer-settings-page-75SDQxQW.js} +1 -1
  23. package/dist/gateway/static/root/assets/{connector-service-page-tSQ3a_Ti.js → connector-service-page-DmJ9dIql.js} +1 -1
  24. package/dist/gateway/static/root/assets/{connectors-page-h5FTgews.js → connectors-page-Bua_nhSH.js} +1 -1
  25. package/dist/gateway/static/root/assets/{date-picker-CavoWXMc.js → date-picker-BEDH1AbM.js} +1 -1
  26. package/dist/gateway/static/root/assets/dependency-picker-LwWL5fo8.js +1 -0
  27. package/dist/gateway/static/root/assets/{desktop-pet-B-RDVNqR.js → desktop-pet-Bb-s29ag.js} +1 -1
  28. package/dist/gateway/static/root/assets/{desktop-pet-settings-rttWyUzY.js → desktop-pet-settings-Btt-DzyT.js} +1 -1
  29. package/dist/gateway/static/root/assets/{device-pairing-wizard-6hqiv1ui.js → device-pairing-wizard-_UWo9-4N.js} +1 -1
  30. package/dist/gateway/static/root/assets/{directory-picker-path-field-1rEGI8IE.js → directory-picker-path-field-CkGfC105.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-debug-page-BaswNoXz.js → extension-debug-page-Cm0F3rcI.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-page-uCMJMnc_.js → extension-page-B72a-tnZ.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-settings-page-DiczmHyl.js → extension-settings-page-BEDAm_Ib.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-settings-DH5MOwxf.js → gateway-settings-BapgXAhB.js} +1 -1
  35. package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-B62h4sJ4.js → highlighted-body-KQOG7T2V-BWjkqT5j.js} +1 -1
  36. package/dist/gateway/static/root/assets/{home-page-BsjMhloP.js → home-page-DNGjF6h4.js} +2 -2
  37. package/dist/gateway/static/root/assets/{image-generation-api-Di7HnFSL.js → image-generation-api-Bi1-Hvtr.js} +1 -1
  38. package/dist/gateway/static/root/assets/{imports-page-DpKfYZMT.js → imports-page-b4VDs6Bd.js} +1 -1
  39. package/dist/gateway/static/root/assets/{index-BUv4J0JN.js → index-Cgd4fGVP.js} +16 -16
  40. package/dist/gateway/static/root/assets/index-gYRNcY2Q.css +1 -0
  41. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D1Q1kTMI.js → keyboard-shortcuts-settings-Cf29ltoI.js} +1 -1
  42. package/dist/gateway/static/root/assets/{local-app-workbench-page-CnaLbgJb.js → local-app-workbench-page-dgUxHhW8.js} +1 -1
  43. package/dist/gateway/static/root/assets/{local-apps-page-CSO0RkyG.js → local-apps-page-D3k9GjgF.js} +1 -1
  44. package/dist/gateway/static/root/assets/{logs-page-DruO5LTf.js → logs-page-BUlU7t8l.js} +1 -1
  45. package/dist/gateway/static/root/assets/{management-settings-Dw3tQKNe.js → management-settings-2L7XFZXc.js} +1 -1
  46. package/dist/gateway/static/root/assets/markdown-view-ixUWAmoy.css +1 -0
  47. package/dist/gateway/static/root/assets/{media-plugins-CrHXsih_.js → media-plugins-Bl1Xga_v.js} +1 -1
  48. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-Bi62iXra.js +1 -0
  49. package/dist/gateway/static/root/assets/{note-detail-panel-DCZ6Vgd_.js → note-detail-panel-ogBu93h0.js} +3 -3
  50. package/dist/gateway/static/root/assets/note-image-lightbox-Dxvo_WsE.js +1 -0
  51. package/dist/gateway/static/root/assets/{notes-page-Bqy9Rh_j.js → notes-page-CNdoxzIZ.js} +1 -1
  52. package/dist/gateway/static/root/assets/{page-context-capture-button-DQHbuYER.js → page-context-capture-button-Bq4Xpop5.js} +1 -1
  53. package/dist/gateway/static/root/assets/{personal-page-C--WEB5c.js → personal-page-7P2leCsB.js} +1 -1
  54. package/dist/gateway/static/root/assets/{personal-settings-panel-Cwgc13ls.js → personal-settings-panel-D6n6TObP.js} +1 -1
  55. package/dist/gateway/static/root/assets/{plugin-details-dialog-DxkFHaU-.js → plugin-details-dialog-JTxDbMI4.js} +1 -1
  56. package/dist/gateway/static/root/assets/{preview-open-alternatives-BW7P2akd.js → preview-open-alternatives-6XU-2lVI.js} +1 -1
  57. package/dist/gateway/static/root/assets/{product-open-page-BnlpaYs-.js → product-open-page-BpB0klIl.js} +1 -1
  58. package/dist/gateway/static/root/assets/{product-preview-content-DkXx1Vt8.js → product-preview-content-DxQaoQew.js} +1 -1
  59. package/dist/gateway/static/root/assets/project-detail-page-LilHE2OV.js +1 -0
  60. package/dist/gateway/static/root/assets/{projects-page-CJ0s-bI5.js → projects-page-D4Jxhuhq.js} +1 -1
  61. package/dist/gateway/static/root/assets/{remote-access-hub-yItNjAR3.js → remote-access-hub-Cy71CCQq.js} +1 -1
  62. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BGRbt79f.js → runtime-tools-settings-panel-CrbjrokA.js} +1 -1
  63. package/dist/gateway/static/root/assets/{schema-form-B9VP7ldU.js → schema-form-DITi2cne.js} +1 -1
  64. package/dist/gateway/static/root/assets/{sessions-page-3O5S9efw.js → sessions-page-D1THmRXE.js} +1 -1
  65. package/dist/gateway/static/root/assets/settings-advanced-gate-CjRLXfoo.js +1 -0
  66. package/dist/gateway/static/root/assets/{settings-form-section-BA2RkU1S.js → settings-form-section-Cl0eF4hl.js} +1 -1
  67. package/dist/gateway/static/root/assets/{settings-page-BUT0FzfI.js → settings-page-1jcGeVtB.js} +1 -1
  68. package/dist/gateway/static/root/assets/{setup-status-panel-1oWs6iPS.js → setup-status-panel-CFhDHkyK.js} +1 -1
  69. package/dist/gateway/static/root/assets/{share-preview-page-CVNey8Lq.js → share-preview-page-By4IKKgg.js} +1 -1
  70. package/dist/gateway/static/root/assets/{shares-settings-Bb6YoDmU.js → shares-settings-q2sa1VvF.js} +1 -1
  71. package/dist/gateway/static/root/assets/{skill-api-BWi0G9Ii.js → skill-api-BxCyuPhf.js} +1 -1
  72. package/dist/gateway/static/root/assets/{skill-reload-api-DspV2olR.js → skill-reload-api-CIHSQxr1.js} +1 -1
  73. package/dist/gateway/static/root/assets/{skills-page-SbNv1vpY.js → skills-page-BQaej_2C.js} +1 -1
  74. package/dist/gateway/static/root/assets/{style-DlOTU5bN.js → style-Dt_oHNvB.js} +1 -1
  75. package/dist/gateway/static/root/assets/{system-settings-panel-DbS1qtOh.js → system-settings-panel-C9ejxax1.js} +1 -1
  76. package/dist/gateway/static/root/assets/{task-detail-page-uSwizzx8.js → task-detail-page-SipLlGGk.js} +1 -1
  77. package/dist/gateway/static/root/assets/{task-expandable-content-D0ahXP9o.js → task-expandable-content-BMCvE36l.js} +1 -1
  78. package/dist/gateway/static/root/assets/{tracing-settings-page-BMhVvXXd.js → tracing-settings-page-bn9vnLrf.js} +1 -1
  79. package/dist/gateway/static/root/assets/{tunnel-api-CO9rJLFh.js → tunnel-api-BeTAD8BN.js} +1 -1
  80. package/dist/gateway/static/root/assets/{usage-page-DVzIDec4.js → usage-page-BPuc6leN.js} +1 -1
  81. package/dist/gateway/static/root/assets/{use-autosave-DqPaXiX2.js → use-autosave-DwcmmxWR.js} +1 -1
  82. package/dist/gateway/static/root/assets/{user-model-page-BYZCHCzG.js → user-model-page-YWSqv_kR.js} +1 -1
  83. package/dist/gateway/static/root/assets/{voice-api-key-field-C_iOzfIt.js → voice-api-key-field-Bk947X8N.js} +1 -1
  84. package/dist/gateway/static/root/assets/{work-discovery-overlay-n59s18s0.js → work-discovery-overlay-mjj7w_wU.js} +1 -1
  85. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Lp6Vumxc.js → workflow-run-setup-panel-xQUvtVUU.js} +1 -1
  86. package/dist/gateway/static/root/assets/{workflows-page-B5BqN1Y1.js → workflows-page-DbKRAEWP.js} +1 -1
  87. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-QSDUy0uF.js → xopc-cloud-account-card-C4jQM6Uo.js} +1 -1
  88. package/dist/gateway/static/root/index.html +4 -4
  89. package/dist/package.js +1 -1
  90. package/dist/src/agent/agent-manager.js +1 -1
  91. package/dist/src/agent/background-review/run-background-review.js +1 -1
  92. package/dist/src/agent/external-tools/cliProvider.js +2 -2
  93. package/dist/src/agent/external-tools/composio-provider.js +2 -2
  94. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  95. package/dist/src/agent/service.js +1 -1
  96. package/dist/src/agent/skills/index.js +1 -1
  97. package/dist/src/agent/skills/managed-store.js +1 -1
  98. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  99. package/dist/src/agent/tools/personal-read-tool.js +1 -1
  100. package/dist/src/agent/tools/xopc-use-tool.js +2 -2
  101. package/dist/src/agent-catalog/capabilities.js +2 -2
  102. package/dist/src/agent-catalog/migrations/legacy-config-cutover.js +1 -1
  103. package/dist/src/agent-catalog/repository.js +1 -1
  104. package/dist/src/automations/capabilities/drafts.js +1 -1
  105. package/dist/src/bootstrap/application-state.js +1 -1
  106. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  107. package/dist/src/capabilities/runtime/dispatcher.js +1 -1
  108. package/dist/src/capabilities/runtime/product.js +1 -1
  109. package/dist/src/cli/commands/agents.js +1 -1
  110. package/dist/src/cli/commands/models.js +1 -1
  111. package/dist/src/cli/commands/onboard/model.js +1 -1
  112. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  113. package/dist/src/config/agent-profile.js +1 -1
  114. package/dist/src/execution-environments/local-worktree-manager.js +1 -1
  115. package/dist/src/extensions/agent-plugins/cli-authorization.js +7 -3
  116. package/dist/src/extensions/agent-plugins/mcp-adapter.js +3 -1
  117. package/dist/src/extensions/agent-plugins/node-runtime.d.ts +5 -0
  118. package/dist/src/extensions/agent-plugins/node-runtime.js +14 -0
  119. package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
  120. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  121. package/dist/src/gateway/agents-admin.js +2 -2
  122. package/dist/src/gateway/hono/routes/agents.js +1 -1
  123. package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
  124. package/dist/src/gateway/hono/routes/notes.js +2 -2
  125. package/dist/src/gateway/hono/routes/projects.js +2 -2
  126. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  127. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  128. package/dist/src/gateway/image-generation-setup.js +1 -1
  129. package/dist/src/gateway/service.js +4 -4
  130. package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
  131. package/dist/src/home-intelligence/host.js +2 -2
  132. package/dist/src/imports/importService.js +1 -1
  133. package/dist/src/local-apps/service.js +1 -1
  134. package/dist/src/personal-agent/communication.d.ts +1 -1
  135. package/dist/src/personal-agent/communication.js +1 -0
  136. package/dist/src/personal-agent/service.js +1 -1
  137. package/dist/src/runtime-tools/archive.js +1 -1
  138. package/dist/src/session/client-history.js +3 -0
  139. package/dist/src/session/session-context-for-llm.js +4 -0
  140. package/dist/src/session/task-allocation-status.d.ts +2 -0
  141. package/dist/src/session/task-allocation-status.js +14 -0
  142. package/dist/src/tasks/capabilities/read.js +2 -2
  143. package/dist/src/tasks/capabilities/write.js +1 -1
  144. package/dist/src/tasks/task-allocation-repository.js +8 -5
  145. package/dist/src/tui/backends/embedded-backend.js +1 -1
  146. package/dist/src/voice/realtime/persona-context.js +1 -1
  147. package/package.json +1 -1
  148. package/dist/gateway/static/root/assets/channels-BZCzeWtD.js +0 -1
  149. package/dist/gateway/static/root/assets/dependency-picker-Cl-3upFX.js +0 -1
  150. package/dist/gateway/static/root/assets/index-Cr4I4q1J.css +0 -1
  151. package/dist/gateway/static/root/assets/markdown-view-Ct4sKkUf.css +0 -1
  152. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-CNzdVIcE.js +0 -1
  153. package/dist/gateway/static/root/assets/note-image-lightbox-BXNZw7lJ.js +0 -1
  154. package/dist/gateway/static/root/assets/project-detail-page-CtyCpIx8.js +0 -1
  155. package/dist/gateway/static/root/assets/settings-advanced-gate-BE-SKsf6.js +0 -1
  156. /package/dist/gateway/static/root/assets/{markdown-view-vQSMUUY_.js → markdown-view-B35a4o1v.js} +0 -0
@@ -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{f as i,g as a,t as o}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./external-link-DjqjBmc3.js";import{t as u}from"./messages-D__oW2yE.js";import{t as d}from"./cn-0WouolD0.js";import{c as f,n as p}from"./locale-store-D_migb9R.js";import{a as m,i as h,o as g,r as _,s as v,t as y}from"./dist-BGTk37IG.js";import{t as b}from"./copy-to-clipboard-HOJ79TWv.js";import{i as x}from"./vendor-swr-BIWyz7Rc.js";import{n as S,r as C}from"./gateway-config-swr-CTXr917C.js";import{$l as w,$t as T,Dd as E,Df as D,F as O,Fs as k,G as A,Gf as j,I as M,Jl as N,Ka as P,L as F,Mu as I,Ps as L,Vd as R,Ys as z,Yu as B,_o as V,bs as H,cl as U,du as W,en as ee,fo as te,kf as G,nn as ne,on as re,pu as K,rr as ie,ud as ae,vf as q,yu as J}from"./index-BUv4J0JN.js";import{n as oe,r as se,t as ce}from"./settings-page-layout-Dx5S-Msc.js";import{n as Y,r as le,t as ue}from"./settings-form-section-BA2RkU1S.js";import{_ as X,a as de,b as fe,c as pe,h as me,i as he,n as ge,o as _e,r as ve,s as ye,t as be,v as xe,y as Se}from"./tunnel-api-CO9rJLFh.js";import{t as Ce}from"./settings-advanced-gate-BE-SKsf6.js";var Z=e(t(),1),Q=n(),$=r();function we(e){switch(e){case`active`:return`text-emerald-700 dark:text-emerald-400`;case`connecting`:return`text-amber-700 dark:text-amber-400`;default:return`text-fg-muted`}}function Te(e){let t=(0,Q.c)(11),{label:n,kind:r}=e,i;t[0]===r?i=t[1]:(i=d(`inline-flex items-center gap-1.5 text-xs font-medium`,we(r)),t[0]=r,t[1]=i);let a=r===`active`&&`bg-emerald-500`,o=r===`connecting`&&`bg-amber-500`,s;t[2]!==a||t[3]!==o?(s=d(`size-1.5 rounded-full bg-fg-subtle/50`,a,o),t[2]=a,t[3]=o,t[4]=s):s=t[4];let c;t[5]===s?c=t[6]:(c=(0,$.jsx)(`span`,{className:s,"aria-hidden":!0}),t[5]=s,t[6]=c);let l;return t[7]!==n||t[8]!==i||t[9]!==c?(l=(0,$.jsxs)(`span`,{className:i,children:[c,n]}),t[7]=n,t[8]=i,t[9]=c,t[10]=l):l=t[10],l}function Ee(e){let t=(0,Q.c)(31),{onOpenTab:n}=e,r=p(Oe),i;t[0]===r?i=t[1]:(i=u(r),t[0]=r,t[1]=i);let a=i.remoteAccess.guide,o=!!f(De),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s={refreshInterval:3e4},t[2]=s):s=t[2];let{data:c}=x(o?`exposure-status`:null,Se,s),l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:15e3},t[3]=l):l=t[3];let{data:m}=x(o?`tunnel-status`:null,ge,l),h=C(o);if(!o)return null;let g=c?.tailscale.active===!0,_=m?.state,v=m?.enabled&&_===`connected`,y=m?.enabled&&(_===`connecting`||_===`reconnecting`||!!m?.startProgress||!!m?.frpcDownload),b=h.data?.payload?.config,S=!!(b&&typeof b==`object`&&!Array.isArray(b)&&b.gateway?.publicUrl),T=g?`active`:`off`,E=g?a.statusActive:a.statusOff,D;t[4]!==a.tailscaleCardTitle||t[5]!==T||t[6]!==E?(D={tab:`tailscale`,icon:R,title:a.tailscaleCardTitle,kind:T,statusLabel:E},t[4]=a.tailscaleCardTitle,t[5]=T,t[6]=E,t[7]=D):D=t[7];let O=v?`active`:y?`connecting`:`off`,k=v?a.statusActive:y?a.statusConnecting:a.statusOff,A;t[8]!==a.publicCardTitle||t[9]!==O||t[10]!==k?(A={tab:`public`,icon:B,title:a.publicCardTitle,kind:O,statusLabel:k},t[8]=a.publicCardTitle,t[9]=O,t[10]=k,t[11]=A):A=t[11];let j=S?`active`:`off`,M=S?a.statusActive:a.statusOff,N;t[12]!==a.reverseProxyCardTitle||t[13]!==j||t[14]!==M?(N={tab:`reverse-proxy`,icon:K,title:a.reverseProxyCardTitle,kind:j,statusLabel:M},t[12]=a.reverseProxyCardTitle,t[13]=j,t[14]=M,t[15]=N):N=t[15];let P;t[16]!==a.sshCardStatus||t[17]!==a.sshCardTitle?(P={tab:`ssh`,icon:w,title:a.sshCardTitle,kind:`off`,statusLabel:a.sshCardStatus},t[16]=a.sshCardStatus,t[17]=a.sshCardTitle,t[18]=P):P=t[18];let F;t[19]!==a.lanCardStatus||t[20]!==a.lanCardTitle?(F={tab:`lan`,icon:J,title:a.lanCardTitle,kind:`off`,statusLabel:a.lanCardStatus},t[19]=a.lanCardStatus,t[20]=a.lanCardTitle,t[21]=F):F=t[21];let I;t[22]!==N||t[23]!==P||t[24]!==F||t[25]!==D||t[26]!==A?(I=[D,A,N,P,F],t[22]=N,t[23]=P,t[24]=F,t[25]=D,t[26]=A,t[27]=I):I=t[27];let L=I,z;return t[28]!==L||t[29]!==n?(z=(0,$.jsx)(`div`,{className:`grid gap-1 rounded-xl bg-surface-hover/20 p-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:L.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:d(`flex items-start gap-3 rounded-lg bg-surface-base/45 px-2 py-3 text-left transition-colors`,`hover:bg-surface-hover/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center text-fg-muted`,children:(0,$.jsx)(t,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(Te,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[28]=L,t[29]=n,t[30]=z):z=t[30],z}function De(e){return e.conversationId}function Oe(e){return e.language}function ke(e){let t=(0,Q.c)(21),{title:n,description:r,recommended:i,icon:a,onOpen:o,recommendedLabel:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=d(`group flex w-full items-start gap-3 px-3 py-4 text-left transition-colors`,`hover:bg-surface-hover/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=c):c=t[0];let l;t[1]===a?l=t[2]:(l=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/70 text-fg-muted`,children:(0,$.jsx)(a,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=a,t[2]=l);let u;t[3]===n?u=t[4]:(u=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=u);let f;t[5]!==i||t[6]!==s?(f=i&&s?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:s}):null,t[5]=i,t[6]=s,t[7]=f):f=t[7];let p;t[8]!==u||t[9]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[u,f]}),t[8]=u,t[9]=f,t[10]=p):p=t[10];let m;t[11]===r?m=t[12]:(m=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=m);let h;t[13]!==p||t[14]!==m?(h=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[p,m]}),t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(D,{className:`mt-2 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":!0}),t[16]=g):g=t[16];let _;return t[17]!==o||t[18]!==l||t[19]!==h?(_=(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:c,children:[l,h,g]}),t[17]=o,t[18]=l,t[19]=h,t[20]=_):_=t[20],_}function Ae(e){let t=(0,Q.c)(78),{onOpenTab:n}=e,r=p(Ne),i;t[0]===r?i=t[1]:(i=u(r),t[0]=r,t[1]=i);let a=i.remoteAccess,o=a.guide,s=!!f(Me),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:l}=x(s?`exposure-status`:null,Se,c),d;t[3]===l?.conflicts?d=t[4]:(d=l?.conflicts??[],t[3]=l?.conflicts,t[4]=d);let m=d;if(!s){let e;return t[5]===o.needToken?e=t[6]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.needToken}),t[5]=o.needToken,t[6]=e),e}let h;t[7]===n?h=t[8]:(h=(0,$.jsx)(Ee,{onOpenTab:n}),t[7]=n,t[8]=h);let g;t[9]!==m||t[10]!==o.conflictsHint||t[11]!==o.conflictsTitle?(g=m.length>0?(0,$.jsxs)(`div`,{className:`rounded-xl bg-amber-500/10 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:o.conflictsTitle}),(0,$.jsx)(`p`,{className:`mt-1`,children:o.conflictsHint}),(0,$.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-xs`,children:m.map(je)})]}):null,t[9]=m,t[10]=o.conflictsHint,t[11]=o.conflictsTitle,t[12]=g):g=t[12];let _;t[13]===o.pickMethod?_=t[14]:(_=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o.pickMethod}),t[13]=o.pickMethod,t[14]=_);let v;t[15]===n?v=t[16]:(v=()=>n(`tailscale`),t[15]=n,t[16]=v);let y;t[17]!==o.recommended||t[18]!==o.tailscaleCardDesc||t[19]!==o.tailscaleCardTitle||t[20]!==v?(y=(0,$.jsx)(ke,{icon:R,title:o.tailscaleCardTitle,description:o.tailscaleCardDesc,recommended:!0,recommendedLabel:o.recommended,onOpen:v}),t[17]=o.recommended,t[18]=o.tailscaleCardDesc,t[19]=o.tailscaleCardTitle,t[20]=v,t[21]=y):y=t[21];let b;t[22]===n?b=t[23]:(b=()=>n(`public`),t[22]=n,t[23]=b);let S;t[24]!==o.publicCardDesc||t[25]!==o.publicCardTitle||t[26]!==b?(S=(0,$.jsx)(ke,{icon:B,title:o.publicCardTitle,description:o.publicCardDesc,onOpen:b}),t[24]=o.publicCardDesc,t[25]=o.publicCardTitle,t[26]=b,t[27]=S):S=t[27];let C;t[28]===n?C=t[29]:(C=()=>n(`reverse-proxy`),t[28]=n,t[29]=C);let T;t[30]!==o.reverseProxyCardDesc||t[31]!==o.reverseProxyCardTitle||t[32]!==C?(T=(0,$.jsx)(ke,{icon:K,title:o.reverseProxyCardTitle,description:o.reverseProxyCardDesc,onOpen:C}),t[30]=o.reverseProxyCardDesc,t[31]=o.reverseProxyCardTitle,t[32]=C,t[33]=T):T=t[33];let E;t[34]===n?E=t[35]:(E=()=>n(`ssh`),t[34]=n,t[35]=E);let D;t[36]!==o.sshCardDesc||t[37]!==o.sshCardTitle||t[38]!==E?(D=(0,$.jsx)(ke,{icon:w,title:o.sshCardTitle,description:o.sshCardDesc,onOpen:E}),t[36]=o.sshCardDesc,t[37]=o.sshCardTitle,t[38]=E,t[39]=D):D=t[39];let O;t[40]!==a.advanced.proxyBody||t[41]!==a.advanced.proxyTitle||t[42]!==T||t[43]!==D?(O=(0,$.jsxs)(A,{title:a.advanced.proxyTitle,summary:a.advanced.proxyBody,children:[T,D]}),t[40]=a.advanced.proxyBody,t[41]=a.advanced.proxyTitle,t[42]=T,t[43]=D,t[44]=O):O=t[44];let k;t[45]===n?k=t[46]:(k=()=>n(`lan`),t[45]=n,t[46]=k);let j;t[47]!==o.lanCardDesc||t[48]!==o.lanCardTitle||t[49]!==k?(j=(0,$.jsx)(ke,{icon:J,title:o.lanCardTitle,description:o.lanCardDesc,onOpen:k}),t[47]=o.lanCardDesc,t[48]=o.lanCardTitle,t[49]=k,t[50]=j):j=t[50];let M;t[51]!==S||t[52]!==O||t[53]!==j||t[54]!==y?(M=(0,$.jsxs)(`div`,{className:`mt-2 flex max-w-3xl flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[y,S,O,j]}),t[51]=S,t[52]=O,t[53]=j,t[54]=y,t[55]=M):M=t[55];let N;t[56]!==M||t[57]!==_?(N=(0,$.jsxs)(`div`,{children:[_,M]}),t[56]=M,t[57]=_,t[58]=N):N=t[58];let P;t[59]===o.oneAtATimeHint?P=t[60]:(P=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.oneAtATimeHint}),t[59]=o.oneAtATimeHint,t[60]=P);let F;t[61]===a.advanced.proxyTitle?F=t[62]:(F=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.advanced.proxyTitle}),t[61]=a.advanced.proxyTitle,t[62]=F);let I;t[63]===a.advanced.proxyBody?I=t[64]:(I=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.advanced.proxyBody}),t[63]=a.advanced.proxyBody,t[64]=I);let L;t[65]!==r||t[66]!==a.advanced.proxyDocs?(L=(0,$.jsx)(fe,{language:r,label:a.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[65]=r,t[66]=a.advanced.proxyDocs,t[67]=L):L=t[67];let z;t[68]!==F||t[69]!==I||t[70]!==L?(z=(0,$.jsxs)(`div`,{className:`max-w-3xl rounded-xl bg-surface-hover/20 px-4 py-4`,children:[F,I,L]}),t[68]=F,t[69]=I,t[70]=L,t[71]=z):z=t[71];let V;return t[72]!==N||t[73]!==P||t[74]!==z||t[75]!==h||t[76]!==g?(V=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[h,g,N,P,z]}),t[72]=N,t[73]=P,t[74]=z,t[75]=h,t[76]=g,t[77]=V):V=t[77],V}function je(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function Me(e){return e.conversationId}function Ne(e){return e.language}function Pe(){let e=(0,Q.c)(16),t=p(Fe),n;e[0]===t?n=e[1]:(n=u(t),e[0]=t,e[1]=n);let r=n.remoteAccess.lan,i;e[2]!==r.subtitle||e[3]!==r.title?(i=(0,$.jsx)(Y,{icon:J,title:r.title,subtitle:r.subtitle}),e[2]=r.subtitle,e[3]=r.title,e[4]=i):i=e[4];let a;e[5]===r.body?a=e[6]:(a=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.body}),e[5]=r.body,e[6]=a);let s;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),e[7]=s):s=e[7];let c;e[8]===r.link?c=e[9]:(c=(0,$.jsxs)(o,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[r.link,s]}),e[8]=r.link,e[9]=c);let d;e[10]!==a||e[11]!==c?(d=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[a,c]}),e[10]=a,e[11]=c,e[12]=d):d=e[12];let f;return e[13]!==i||e[14]!==d?(f=(0,$.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,$.jsxs)(ue,{children:[i,d]})}),e[13]=i,e[14]=d,e[15]=f):f=e[15],f}function Fe(e){return e.language}function Ie(e){let t=(0,Q.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=p(Le),a;t[0]===i?a=t[1]:(a=u(i),t[0]=i,t[1]=a);let o=a.remoteAccess.ssh,[s,l]=(0,Z.useState)(!1),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=async()=>{await b(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(l(!0),setTimeout(()=>l(!1),2e3))},t[2]=d):d=t[2];let f=d,m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg bg-surface-base/55 px-3 py-2 text-xs text-fg-muted`,children:`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`}),t[3]=m):m=t[3];let h,g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>void f(),g=(0,$.jsx)(c,{className:`mr-1 size-4`}),t[4]=h,t[5]=g):(h=t[4],g=t[5]);let _=s?o.copied:o.copy,v;t[6]===_?v=t[7]:(v=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(U,{type:`button`,variant:`ghost`,onClick:h,children:[g,_]})}),t[6]=_,t[7]=v);let y;t[8]!==r||t[9]!==o.hint?(y=r?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:o.hint}):null,t[8]=r,t[9]=o.hint,t[10]=y):y=t[10];let x;t[11]!==v||t[12]!==y?(x=(0,$.jsxs)($.Fragment,{children:[m,v,y]}),t[11]=v,t[12]=y,t[13]=x):x=t[13];let S=x;if(r){let e;t[14]!==o.subtitle||t[15]!==o.title?(e=(0,$.jsx)(Y,{icon:w,title:o.title,subtitle:o.subtitle}),t[14]=o.subtitle,t[15]=o.title,t[16]=e):e=t[16];let n;t[17]===S?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:S}),t[17]=S,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(ue,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let C;t[22]!==o.subtitle||t[23]!==o.title?(C=(0,$.jsx)(Y,{icon:w,title:o.title,subtitle:o.subtitle}),t[22]=o.subtitle,t[23]=o.title,t[24]=C):C=t[24];let T;t[25]===S?T=t[26]:(T=(0,$.jsx)(`div`,{className:`mt-4`,children:S}),t[25]=S,t[26]=T);let E;return t[27]!==C||t[28]!==T?(E=(0,$.jsxs)(ue,{children:[C,T]}),t[27]=C,t[28]=T,t[29]=E):E=t[29],E}function Le(e){return e.language}function Re(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Ie,{embedded:!0}),e[0]=t):t=e[0],t}var ze=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Be(e){return e&&ze.includes(e)?e:`guide`}function Ve(e){let t=(0,Q.c)(32),{showLabel:n,hideLabel:r,icon:i,hint:a,children:o,className:s,defaultOpen:c,advancedOnly:l}=e,u=l===void 0?!1:l,[f,p]=(0,Z.useState)(c??!1),m;t[0]===s?m=t[1]:(m=d(`rounded-xl bg-surface-hover/20`,s),t[0]=s,t[1]=m);let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>p(He),t[2]=h):h=t[2];let g=f&&`rotate-180`,_;t[3]===g?_=t[4]:(_=d(`size-4 shrink-0 text-fg-muted transition-transform duration-200 motion-reduce:transition-none`,g),t[3]=g,t[4]=_);let v;t[5]===_?v=t[6]:(v=(0,$.jsx)(G,{className:_,"aria-hidden":!0}),t[5]=_,t[6]=v);let y;t[7]===i?y=t[8]:(y=i?(0,$.jsx)(i,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}):null,t[7]=i,t[8]=y);let b=f?r:n,x;t[9]===b?x=t[10]:(x=(0,$.jsx)(`span`,{children:b}),t[9]=b,t[10]=x);let S;t[11]!==f||t[12]!==v||t[13]!==y||t[14]!==x?(S=(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":f,onClick:h,className:`flex w-full items-center gap-2 rounded-2xl px-4 py-3.5 text-left text-sm font-medium text-fg transition-colors hover:text-fg`,children:[v,y,x]}),t[11]=f,t[12]=v,t[13]=y,t[14]=x,t[15]=S):S=t[15];let C=f?`grid-rows-[1fr] opacity-100`:`grid-rows-[0fr] opacity-0`,w;t[16]===C?w=t[17]:(w=d(`grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none`,C),t[16]=C,t[17]=w);let T;t[18]===a?T=t[19]:(T=a?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[18]=a,t[19]=T);let E;t[20]!==o||t[21]!==T?(E=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-4 pt-1`,children:[T,o]})}),t[20]=o,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==w||t[24]!==E?(D=(0,$.jsx)(`div`,{className:w,children:E}),t[23]=w,t[24]=E,t[25]=D):D=t[25];let O;t[26]!==S||t[27]!==D||t[28]!==m?(O=(0,$.jsxs)(`section`,{className:m,children:[S,D]}),t[26]=S,t[27]=D,t[28]=m,t[29]=O):O=t[29];let k=O;if(u){let e;return t[30]===k?e=t[31]:(e=(0,$.jsx)(Ce,{children:k}),t[30]=k,t[31]=e),e}return k}function He(e){return!e}function Ue(e){let t=(0,Q.c)(40),{open:n,title:r,intro:i,bullets:a,checkboxLabel:o,confirmLabel:s,cancelLabel:c,onConfirm:l,onCancel:u}=e,[f,p]=(0,Z.useState)(!1),b;t[0]===u?b=t[1]:(b=e=>{e||(p(!1),u())},t[0]=u,t[1]=b);let x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(m,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,k)}),t[2]=x):x=t[2];let S;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=d(`xopc-dialog-content fixed left-1/2 top-1/2 max-h-[min(90vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-overlay p-6 shadow-popover outline-none dark:border-edge`,L),t[3]=S):S=t[3];let C;t[4]===r?C=t[5]:(C=(0,$.jsx)(v,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=C);let w;t[6]===i?w=t[7]:(w=(0,$.jsx)(h,{className:`mt-2 text-sm text-fg-muted`,children:i}),t[6]=i,t[7]=w);let T;t[8]===a?T=t[9]:(T=a.map(We),t[8]=a,t[9]=T);let E;t[10]===T?E=t[11]:(E=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:T}),t[10]=T,t[11]=E);let D;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>p(e.target.checked),t[12]=D):D=t[12];let O;t[13]===f?O=t[14]:(O=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:f,onChange:D}),t[13]=f,t[14]=O);let A;t[15]===o?A=t[16]:(A=(0,$.jsx)(`span`,{children:o}),t[15]=o,t[16]=A);let j;t[17]!==A||t[18]!==O?(j=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[O,A]}),t[17]=A,t[18]=O,t[19]=j):j=t[19];let M;t[20]!==c||t[21]!==u?(M=(0,$.jsx)(U,{type:`button`,variant:`secondary`,onClick:u,children:c}),t[20]=c,t[21]=u,t[22]=M):M=t[22];let N=!f,P;t[23]!==s||t[24]!==l||t[25]!==N?(P=(0,$.jsx)(U,{type:`button`,disabled:N,onClick:l,children:s}),t[23]=s,t[24]=l,t[25]=N,t[26]=P):P=t[26];let F;t[27]!==M||t[28]!==P?(F=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[M,P]}),t[27]=M,t[28]=P,t[29]=F):F=t[29];let I;t[30]!==j||t[31]!==F||t[32]!==C||t[33]!==w||t[34]!==E?(I=(0,$.jsxs)(g,{children:[x,(0,$.jsxs)(_,{className:S,onOpenAutoFocus:Ge,children:[C,w,E,j,F]})]}),t[30]=j,t[31]=F,t[32]=C,t[33]=w,t[34]=E,t[35]=I):I=t[35];let R;return t[36]!==n||t[37]!==b||t[38]!==I?(R=(0,$.jsx)(y,{open:n,onOpenChange:b,children:I}),t[36]=n,t[37]=b,t[38]=I,t[39]=R):R=t[39],R}function We(e){return(0,$.jsx)(`li`,{children:e},e)}function Ge(e){return e.preventDefault()}function Ke(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var qe=[`preparing_frpc`,`registering`,`starting_frpc`];function Je(e){return e?e===`reconnecting_frpc`?qe.indexOf(`starting_frpc`):qe.indexOf(e):-1}function Ye(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=qe.indexOf(e),i=Je(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Xe(e,t,n){let r=n.startProgress;return Ye(t,n)===`active`?t===`preparing_frpc`&&n.frpcDownload?n.frpcDownload.phase===`extracting`?e.frpcExtracting:n.frpcDownload.percent==null?e.frpcDownloading:e.frpcDownloadingPercent.replace(`{{percent}}`,String(n.frpcDownload.percent)):t===`registering`&&r?.publicUrl?e.stepRegisterDetail:t===`starting_frpc`?r?.phase===`reconnecting_frpc`?e.stepReconnectDetail:e.stepFrpcDetail:null:null}function Ze(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function Qe(e){if(!e)return null;let t=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function $e(e){let t=(0,Q.c)(31),{status:n,t:r}=e,[,i]=(0,Z.useState)(0),a;t[0]!==i||t[1]!==n.state?(a=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>i(et),1e3);return()=>window.clearInterval(e)},t[0]=i,t[1]=n.state,t[2]=a):a=t[2];let o=n.startProgress?.startedAt,c;if(t[3]!==n.state||t[4]!==o?(c=[n.state,o],t[3]=n.state,t[4]=o,t[5]=c):c=t[5],(0,Z.useEffect)(a,c),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let l,u,f,p,m;if(t[6]!==n||t[7]!==r){let e=Qe(n.startProgress?.startedAt);l=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,u=`mt-3 space-y-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`;let i;t[13]===r.startProgressTitle?i=t[14]:(i=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.startProgressTitle}),t[13]=r.startProgressTitle,t[14]=i);let a;t[15]===r.startProgressHint?a=t[16]:(a=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.startProgressHint}),t[15]=r.startProgressHint,t[16]=a),t[17]!==i||t[18]!==a?(f=(0,$.jsxs)(`div`,{children:[i,a]}),t[17]=i,t[18]=a,t[19]=f):f=t[19];let o=qe.map(e=>{let t=Ye(e,n),i=Xe(r,e,n);return(0,$.jsxs)(`li`,{className:`flex gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-subtle`,"aria-hidden":!0,children:t===`done`?(0,$.jsx)(s,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(ae,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(q,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:d(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:Ze(r,e)}),i?(0,$.jsx)(`div`,{className:`mt-0.5 text-fg-muted`,children:i}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload&&n.frpcDownload.phase===`downloading`?(0,$.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-panel`,children:(0,$.jsx)(`div`,{className:d(`h-full rounded-full bg-accent transition-[width] duration-300`,n.frpcDownload.percent==null&&`w-1/3 animate-pulse`),style:n.frpcDownload.percent==null?void 0:{width:`${n.frpcDownload.percent}%`}})}),n.frpcDownload.bytesReceived!=null&&n.frpcDownload.totalBytes?(0,$.jsxs)(`p`,{className:`text-fg-subtle`,children:[Ke(n.frpcDownload.bytesReceived),` /`,` `,Ke(n.frpcDownload.totalBytes)]}):null]}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload?.url?(0,$.jsxs)(`p`,{className:`mt-2 text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`font-sans`,children:[r.frpcDownloadingUrlLabel,`: `]}),(0,$.jsx)(`a`,{href:n.frpcDownload.url,target:`_blank`,rel:`noopener noreferrer`,className:`break-all font-mono text-[11px] text-accent hover:underline`,children:n.frpcDownload.url})]}):null]})]},e)});t[20]===o?p=t[21]:(p=(0,$.jsx)(`ol`,{className:`space-y-2`,children:o}),t[20]=o,t[21]=p),m=e&&n.startProgress?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.startProgressElapsed.replace(`{{elapsed}}`,e)}):null,t[6]=n,t[7]=r,t[8]=l,t[9]=u,t[10]=f,t[11]=p,t[12]=m}else l=t[8],u=t[9],f=t[10],p=t[11],m=t[12];let h;t[22]!==l||t[23]!==r.publicUrlPendingNotice?(h=l?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=l,t[23]=r.publicUrlPendingNotice,t[24]=h):h=t[24];let g;return t[25]!==u||t[26]!==f||t[27]!==p||t[28]!==m||t[29]!==h?(g=(0,$.jsxs)(`div`,{className:u,children:[f,p,m,h]}),t[25]=u,t[26]=f,t[27]=p,t[28]=m,t[29]=h,t[30]=g):g=t[30],g}function et(e){return e+1}function tt(e,t){return t.state===`connected`?e.statusConnected:t.state===`error`?e.statusError:t.startProgress?.phase===`reconnecting_frpc`?e.statusReconnecting:t.startProgress?.phase===`starting_frpc`?e.statusStartingFrpc:t.startProgress?.phase===`registering`?e.statusRegistering:t.startProgress?.phase===`preparing_frpc`||t.frpcDownload?e.statusPreparingFrpc:t.state===`connecting`||t.state===`reconnecting`?e.statusConnecting:e.statusOff}function nt(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function rt(e){switch(e){case`connected`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`progress`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;case`error`:return`bg-red-500/15 text-red-700 dark:text-red-400`;default:return`bg-surface-hover text-fg-muted`}}function it(e){if(!e)return`—`;let t=Date.now()-new Date(e).getTime();if(t<0)return`—`;let n=Math.floor(t/6e4);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function at(e){let t=(0,Q.c)(61),{t:n,status:r,isLoading:i,statusErr:a,starting:o,stopping:s,showConsentExpired:c,copyLabels:l,startDisabled:u,startDisabledReason:f,stepLabel:p,onStart:m,onStop:h}=e,g=u===void 0?!1:u,_,v,y,b,x,S,C;t[0]!==r||t[1]!==o?(C=nt(r),_=r.enabled||o,v=o||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=d(le(),`space-y-4`),t[9]=S):S=t[9],x=`flex flex-wrap items-start justify-between gap-3`,b=`flex items-center gap-2`,y=d(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,rt(C)),t[0]=r,t[1]=o,t[2]=_,t[3]=v,t[4]=y,t[5]=b,t[6]=x,t[7]=S,t[8]=C):(_=t[2],v=t[3],y=t[4],b=t[5],x=t[6],S=t[7],C=t[8]);let w=C===`connected`&&`bg-emerald-500`,T=C===`progress`&&`bg-amber-500 animate-pulse`,E=C===`error`&&`bg-red-500`,D=C===`off`&&`bg-fg-subtle`,O;t[10]!==w||t[11]!==T||t[12]!==E||t[13]!==D?(O=d(`size-1.5 rounded-full`,w,T,E,D),t[10]=w,t[11]=T,t[12]=E,t[13]=D,t[14]=O):O=t[14];let k;t[15]===O?k=t[16]:(k=(0,$.jsx)(`span`,{className:O,"aria-hidden":!0}),t[15]=O,t[16]=k);let A;t[17]!==i||t[18]!==r||t[19]!==n?(A=i&&!r.enabled?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block h-3 w-16 animate-pulse rounded-full bg-surface-hover/70 motion-reduce:animate-none`}):tt(n,r),t[17]=i,t[18]=r,t[19]=n,t[20]=A):A=t[20];let j;t[21]!==k||t[22]!==A||t[23]!==y?(j=(0,$.jsxs)(`span`,{className:y,children:[k,A]}),t[21]=k,t[22]=A,t[23]=y,t[24]=j):j=t[24];let M;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(M=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,it(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=M):M=t[28];let F;t[29]!==j||t[30]!==M||t[31]!==b?(F=(0,$.jsxs)(`div`,{className:b,children:[j,M]}),t[29]=j,t[30]=M,t[31]=b,t[32]=F):F=t[32];let L;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(R,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=L):L=t[33];let z;t[34]!==F||t[35]!==x?(z=(0,$.jsxs)(`div`,{className:x,children:[F,L]}),t[34]=F,t[35]=x,t[36]=z):z=t[36];let B;t[37]===a?B=t[38]:(B=a?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a instanceof Error?a.message:String(a)}):null,t[37]=a,t[38]=B);let V;t[39]!==c||t[40]!==n.consentExpiredBanner?(V=c?(0,$.jsx)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=c,t[40]=n.consentExpiredBanner,t[41]=V):V=t[41];let H;t[42]!==_||t[43]!==l||t[44]!==m||t[45]!==h||t[46]!==v||t[47]!==r||t[48]!==g||t[49]!==f||t[50]!==o||t[51]!==p||t[52]!==s||t[53]!==n?(H=_?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,$.jsx)(P,{label:n.publicUrlLabel,text:r.publicUrl,labels:l})}):null,v?(0,$.jsx)($e,{status:r,t:n}):null,r.lastError&&r.state===`error`?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:r.lastError}):null,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.enabled?(0,$.jsxs)(U,{type:`button`,variant:`secondary`,disabled:s,onClick:h,children:[s?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(U,{type:`button`,disabled:o,onClick:m,children:[o?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):(0,$.jsx)(I,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:p}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.emptyStateTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.emptyStateBody})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg bg-amber-500/10 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(N,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),g&&f?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:f}):null,(0,$.jsxs)(U,{type:`button`,disabled:o||g,onClick:m,className:`w-full sm:w-auto`,children:[o?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):(0,$.jsx)(I,{className:`size-4`}),n.start]})]}),t[42]=_,t[43]=l,t[44]=m,t[45]=h,t[46]=v,t[47]=r,t[48]=g,t[49]=f,t[50]=o,t[51]=p,t[52]=s,t[53]=n,t[54]=H):H=t[54];let W;return t[55]!==z||t[56]!==B||t[57]!==V||t[58]!==H||t[59]!==S?(W=(0,$.jsxs)(`section`,{className:S,children:[z,B,V,H]}),t[55]=z,t[56]=B,t[57]=V,t[58]=H,t[59]=S,t[60]=W):W=t[60],W}var ot={reconfiguring:!1};function st(e){let t=(0,Q.c)(89),{t:n,brokerSecretReady:r,brokerSecretConfiguredInConfig:i,brokerSecretMaskedValue:a,brokerSecretDraft:o,savingBrokerSecret:c,authorizingBrokerSecret:u,brokerSecretAuthorizationUrl:f,brokerSecretNotice:p,copyFailedLabel:m,onDraftChange:h,onSave:g,onAuthorize:_,onClear:v,sectionRef:y}=e,b=(0,Z.useId)(),x=r,S=!x,[C,w]=(0,Z.useReducer)(V,ot),{reconfiguring:T}=C,D;t[0]!==i||t[1]!==o||t[2]!==T?(D=i&&!T&&!o.trim(),t[0]=i,t[1]=o,t[2]=T,t[3]=D):D=t[3];let O=D,k;t[4]!==n.copied||t[5]!==n.copyKey||t[6]!==n.hideKey||t[7]!==n.showKey?(k={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[4]=n.copied,t[5]=n.copyKey,t[6]=n.hideKey,t[7]=n.showKey,t[8]=k):k=t[8];let A=k,j;t[9]===o?j=t[10]:(j=o.trim().length>0&&!re(o.trim()),t[9]=o,t[10]=j);let M=j,N;t[11]===h?N=t[12]:(N=()=>{w({type:`patch`,patch:{reconfiguring:!1}}),h(``)},t[11]=h,t[12]=N);let P=N,F=S&&`ring-1 ring-amber-500/30`,I;t[13]===F?I=t[14]:(I=d(F),t[13]=F,t[14]=I);let L=x?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:S?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,R;t[15]===L?R=t[16]:(R=d(`flex size-9 shrink-0 items-center justify-center rounded-lg`,L),t[15]=L,t[16]=R);let B;t[17]===x?B=t[18]:(B=x?(0,$.jsx)(s,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(E,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=x,t[18]=B);let H;t[19]!==R||t[20]!==B?(H=(0,$.jsx)(`span`,{className:R,children:B}),t[19]=R,t[20]=B,t[21]=H):H=t[21];let W=x?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,ee;t[22]===W?ee=t[23]:(ee=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:W}),t[22]=W,t[23]=ee);let te=x?n.brokerSecretReadyHint:n.brokerSecretHint,G;t[24]===te?G=t[25]:(G=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:te}),t[24]=te,t[25]=G);let ne;t[26]!==S||t[27]!==n.brokerSecretMissingHint?(ne=S?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[26]=S,t[27]=n.brokerSecretMissingHint,t[28]=ne):ne=t[28];let K;t[29]!==ee||t[30]!==G||t[31]!==ne?(K=(0,$.jsxs)(`div`,{children:[ee,G,ne]}),t[29]=ee,t[30]=G,t[31]=ne,t[32]=K):K=t[32];let ie;t[33]!==u||t[34]!==S||t[35]!==_||t[36]!==T||t[37]!==c||t[38]!==n.brokerSecretAuthorize||t[39]!==n.brokerSecretAuthorizing||t[40]!==n.brokerSecretConsoleLink?(ie=S||T?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(U,{type:`button`,disabled:c||u,onClick:_,children:[u?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):null,u?n.brokerSecretAuthorizing:n.brokerSecretAuthorize]}),(0,$.jsxs)(`a`,{href:be,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n.brokerSecretConsoleLink,(0,$.jsx)(l,{className:`size-3`,"aria-hidden":!0})]})]}):null,t[33]=u,t[34]=S,t[35]=_,t[36]=T,t[37]=c,t[38]=n.brokerSecretAuthorize,t[39]=n.brokerSecretAuthorizing,t[40]=n.brokerSecretConsoleLink,t[41]=ie):ie=t[41];let q;t[42]!==u||t[43]!==f||t[44]!==n.brokerSecretOpenAuthorization?(q=u&&f?(0,$.jsxs)(`a`,{href:f,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,children:[n.brokerSecretOpenAuthorization,(0,$.jsx)(l,{className:`size-3`,"aria-hidden":!0})]}):null,t[42]=u,t[43]=f,t[44]=n.brokerSecretOpenAuthorization,t[45]=q):q=t[45];let J;t[46]!==i||t[47]!==o||t[48]!==a||t[49]!==M||t[50]!==P||t[51]!==m||t[52]!==b||t[53]!==S||t[54]!==v||t[55]!==h||t[56]!==g||t[57]!==T||t[58]!==c||t[59]!==A||t[60]!==O||t[61]!==n.brokerSecretCancelReconfigure||t[62]!==n.brokerSecretClear||t[63]!==n.brokerSecretMaskedHelp||t[64]!==n.brokerSecretNotInConfigFile||t[65]!==n.brokerSecretPlaceholder||t[66]!==n.brokerSecretReconfigure||t[67]!==n.brokerSecretRevealFailed||t[68]!==n.brokerSecretSave||t[69]!==n.brokerSecretSaveAndContinue||t[70]!==n.brokerSecretTitle?(J=O?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:b,children:n.brokerSecretTitle}),(0,$.jsx)(z,{id:b,value:a,labels:A,reveal:ct,loadFailedLabel:m||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(U,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>{w({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(U,{type:`button`,variant:`ghost`,disabled:c,onClick:v,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:b,children:n.brokerSecretTitle}),(0,$.jsx)(z,{id:b,value:o,onChange:h,placeholder:n.brokerSecretPlaceholder,labels:A,disabled:c}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(U,{type:`button`,disabled:c||!M,onClick:g,children:[c?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):null,S?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),i?(0,$.jsx)(U,{type:`button`,variant:`ghost`,disabled:c,onClick:v,children:n.brokerSecretClear}):null,T?(0,$.jsx)(U,{type:`button`,variant:`ghost`,disabled:c,onClick:P,children:n.brokerSecretCancelReconfigure}):null]})]}),t[46]=i,t[47]=o,t[48]=a,t[49]=M,t[50]=P,t[51]=m,t[52]=b,t[53]=S,t[54]=v,t[55]=h,t[56]=g,t[57]=T,t[58]=c,t[59]=A,t[60]=O,t[61]=n.brokerSecretCancelReconfigure,t[62]=n.brokerSecretClear,t[63]=n.brokerSecretMaskedHelp,t[64]=n.brokerSecretNotInConfigFile,t[65]=n.brokerSecretPlaceholder,t[66]=n.brokerSecretReconfigure,t[67]=n.brokerSecretRevealFailed,t[68]=n.brokerSecretSave,t[69]=n.brokerSecretSaveAndContinue,t[70]=n.brokerSecretTitle,t[71]=J):J=t[71];let oe;t[72]===p?oe=t[73]:(oe=p?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:p}):null,t[72]=p,t[73]=oe);let se;t[74]!==K||t[75]!==ie||t[76]!==q||t[77]!==J||t[78]!==oe?(se=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[K,ie,q,J,oe]}),t[74]=K,t[75]=ie,t[76]=q,t[77]=J,t[78]=oe,t[79]=se):se=t[79];let ce;t[80]!==H||t[81]!==se?(ce=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[H,se]}),t[80]=H,t[81]=se,t[82]=ce):ce=t[82];let Y;t[83]!==ce||t[84]!==I?(Y=(0,$.jsx)(ue,{className:I,children:ce}),t[83]=ce,t[84]=I,t[85]=Y):Y=t[85];let le;return t[86]!==y||t[87]!==Y?(le=(0,$.jsx)(`div`,{ref:y,id:`tunnel-broker-secret-setup`,children:Y}),t[86]=y,t[87]=Y,t[88]=le):le=t[88],le}function ct(){return _e().then(lt)}function lt(e){return e.registrationSecret??null}var ut={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null};function dt({embedded:e=!1}){let t=p(e=>e.language),n=u(t).tunnelSettings,r=!!f(e=>e.conversationId),[i,a]=(0,Z.useReducer)(V,ut),{actionError:o,starting:s,stopping:c,savingAutoStart:l,consentOpen:m,autoStartConfirmOpen:h,releaseConfirmOpen:g,releasing:_,brokerSecretDraft:v,savingBrokerSecret:y,authorizingBrokerSecret:b,brokerSecretAuthorizationUrl:w,brokerSecretNotice:E}=i,D=(0,Z.useRef)(null),{data:k}=C(r),{data:A,error:j,isLoading:N,mutate:P}=x(r?`tunnel-status`:null,ge,{refreshInterval:e=>s?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),I=(0,Z.useMemo)(()=>{let e=k?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)&&t.autoStart===!0)return!0}return A?.config?.autoStart===!0},[k,A?.config?.autoStart]),L=(0,Z.useMemo)(()=>{let e=k?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.registrationSecret;if(typeof e==`string`)return e}}return``},[k]),z=re(L),B=A?.registrationSecret?.configured??z;(0,Z.useEffect)(()=>{let e=()=>{P()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[P]);let H=(0,Z.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),W=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{actionError:null}}),a({type:`patch`,patch:{starting:!0}});try{await ye(),await P(),S()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{starting:!1}})}},[P]),G=(0,Z.useCallback)(()=>{if(!B){a({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),D.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(A?.consentRequired){a({type:`patch`,patch:{consentOpen:!0}});return}W()},[B,A?.consentRequired,W,n.brokerSecretRequiredBeforeStart]),K=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{consentOpen:!1}}),a({type:`patch`,patch:{actionError:null}});try{await de(),await Promise.all([P(),W()])}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[P,W]),ie=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{actionError:null}}),a({type:`patch`,patch:{stopping:!0}});try{await pe(),await P(),S()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{stopping:!1}})}},[P]),q=(0,Z.useCallback)(async e=>{a({type:`patch`,patch:{savingAutoStart:!0}}),a({type:`patch`,patch:{actionError:null}});try{await ve({autoStart:e}),S()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingAutoStart:!1}})}},[]),J=(0,Z.useCallback)(()=>{if(I){q(!1);return}if(A?.consentRequired){a({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!A?.canAutoStart){a({type:`patch`,patch:{actionError:n.autoStartHint}});return}a({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[q,A?.canAutoStart,A?.consentRequired,n,I]),oe=(0,Z.useCallback)(async()=>{let e=v.trim();if(e){a({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await ve({registrationSecret:e}),a({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),S(),await P(),a({type:`patch`,patch:{actionError:null}})}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[v,P,n.brokerSecretSaved]),se=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await ve({registrationSecret:null}),a({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),S(),await P()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingBrokerSecret:!1}})}},[P,n.brokerSecretCleared]),ce=(0,Z.useCallback)(async()=>{let e=F(),t=null,r=null;a({type:`patch`,patch:{authorizingBrokerSecret:!0,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null,actionError:null}});try{for(t=(await ne(`xopc-tunnel`)).sessionId;;){await new Promise(e=>window.setTimeout(e,1e3));let i=await ee(t);if(i.authUrl&&i.authUrl!==r&&(r=i.authUrl,a({type:`patch`,patch:{brokerSecretAuthorizationUrl:i.authUrl}}),await M(i.authUrl,e)),i.status===`failed`||i.status===`cancelled`)throw Error(i.error??i.message??`OAuth authorization failed`);if(i.status===`completed`){await he(),await Promise.all([P(),S()]),a({type:`patch`,patch:{brokerSecretNotice:n.brokerSecretSaved,brokerSecretDraft:``}});return}}}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{O(e),t&&T(t).catch(()=>void 0),a({type:`patch`,patch:{authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null}})}},[P,n.brokerSecretSaved]),Y=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await pe({release:!0}),await P(),S()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{releasing:!1}})}},[P]),le=(0,Z.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:u(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!r)return(0,$.jsx)(`div`,{className:e?void 0:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let X=A??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:I,brokerUrl:`https://frp.xopc.ai/api`}},me=A?.consentRequired&&(X.enabled||I||A?.consent?.acceptedAt),_e=(0,$.jsx)(st,{t:n,brokerSecretReady:B,brokerSecretConfiguredInConfig:z,brokerSecretMaskedValue:z?L:``,brokerSecretDraft:v,savingBrokerSecret:y,authorizingBrokerSecret:b,brokerSecretAuthorizationUrl:w,brokerSecretNotice:E,copyFailedLabel:u(t).clipboard.copyFailed,onDraftChange:e=>a({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void oe(),onAuthorize:()=>void ce(),onClear:()=>void se(),sectionRef:D}),be=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ue,{open:m,title:n.consentTitle,intro:n.consentIntro,bullets:H,checkboxLabel:n.consentCheckbox,confirmLabel:me?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void K(),onCancel:()=>a({type:`patch`,patch:{consentOpen:!1}})},m?`consent-open`:`consent-closed`),(0,$.jsx)(te,{open:h,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{a({type:`patch`,patch:{autoStartConfirmOpen:!1}}),q(!0)},onCancel:()=>a({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(te,{open:g,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void Y(),onCancel:()=>a({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o}):null,_e,(0,$.jsx)(at,{t:n,status:X,isLoading:N,statusErr:j,starting:s,stopping:c,showConsentExpired:!!me,copyLabels:le,startDisabled:!B,startDisabledReason:B?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:G,onStop:()=>void ie()}),(0,$.jsxs)(Ve,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:d(`flex items-center gap-3 text-sm text-fg`,!I&&!A?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:I,disabled:l||!I&&!A?.canAutoStart,onChange:J}),n.autoStart]}),!A?.canAutoStart&&!I?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,X.subdomain||X.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[(0,$.jsxs)(U,{type:`button`,variant:`secondary`,disabled:_||c,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>a({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[_?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(Ve,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-base/45 p-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(R,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(fe,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),be]}):(0,$.jsxs)(`div`,{className:e?`flex w-full flex-col gap-6`:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[e?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o}):null,_e,(0,$.jsx)(at,{t:n,status:X,isLoading:N,statusErr:j,starting:s,stopping:c,showConsentExpired:!!me,copyLabels:le,startDisabled:!B,startDisabledReason:B?void 0:n.brokerSecretRequiredBeforeStart,onStart:G,onStop:()=>void ie()}),X.subdomain||X.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(U,{type:`button`,variant:`secondary`,disabled:_||c,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>a({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[_?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):null,n.release]})}):null,X.subdomain||X.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(ue,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:d(`flex items-center gap-3 text-sm text-fg`,!I&&!A?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:I,disabled:l||!I&&!A?.canAutoStart,onChange:J}),n.autoStart]}),!A?.canAutoStart&&!I?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n.autoStartHint}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-panel/80 px-3 py-2 text-xs text-fg-subtle shadow-surface`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(R,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(fe,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),be]})}function ft(e,t){return e.tabs[t]}function pt(e,t){return e.tabIntro[t]}function mt(e){switch(e){case`tailscale`:return`tailscale-serve`;case`public`:return`public-tunnel`;case`reverse-proxy`:return`reverse-proxy`;case`ssh`:return`ssh-tunnel`;case`lan`:return`lan`;default:return}}function ht(e){let t=(0,Q.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(Ae,{onOpenTab:r}),t[0]=r,t[1]=e),e}case`tailscale`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(xe,{embedded:!0}),t[2]=e):e=t[2],e}case`public`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(dt,{embedded:!0}),t[3]=e):e=t[3],e}case`reverse-proxy`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Re,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Pe,{}),t[6]=e):e=t[6],e}}}function gt(){let e=(0,Q.c)(3),t=i(),n=p(vt),r=u(n).remoteAccess,o=!!f(_t),[s,c]=a(),l=ie(),d=Be(s.get(`tab`)),m=s.get(`intent`)===`mobile-pairing`,h;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(h={refreshInterval:2e3},e[0]=h):h=e[0];let g=x(m?`device-pairing-readiness`:null,me,h),_;e[1]===c?_=e[2]:(_=e=>{c(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[1]=c,e[2]=_);let v=_,y=pt(r,d),b=ze.filter(e=>l||e!==`ssh`&&e!==`reverse-proxy`||e===d).map(e=>({id:e,label:ft(r,e)}));return(0,$.jsxs)(se,{children:[(0,$.jsx)(oe,{title:r.pageTitle,meta:(0,$.jsx)(fe,{language:n,label:r.docsLink,section:mt(d),className:`mt-1`})}),o?(0,$.jsxs)($.Fragment,{children:[m?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl bg-accent-soft px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(W,{className:`mt-0.5 size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.mobilePairingFlow.title}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:g.data?.ready?r.mobilePairingFlow.ready:r.mobilePairingFlow.hint})]})]}),(0,$.jsxs)(U,{variant:`primary`,disabled:!g.data?.ready,onClick:()=>t(`/settings/devices?startDevicePairing=mobile`),children:[g.data?.ready?r.mobilePairingFlow.continue:r.mobilePairingFlow.waiting,(0,$.jsx)(j,{className:`size-4`,"aria-hidden":!0})]})]}):null,(0,$.jsx)(H,{items:b,activeTab:d,onChange:v,ariaLabel:r.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(ce,{id:d,activeTab:d,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:ft(r,d),hint:d===`public`?void 0:y,showHeading:!1,framed:!1,children:(0,$.jsx)(ht,{tab:d,onOpenTab:v})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.guide.needToken})]})}function _t(e){return e.conversationId}function vt(e){return e.language}export{gt as RemoteAccessHub};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,g as a,t as o}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./external-link-DjqjBmc3.js";import{t as u}from"./messages-D__oW2yE.js";import{t as d}from"./cn-0WouolD0.js";import{c as f,n as p}from"./locale-store-D_migb9R.js";import{a as m,i as h,o as g,r as _,s as v,t as y}from"./dist-BGTk37IG.js";import{t as b}from"./copy-to-clipboard-HOJ79TWv.js";import{i as x}from"./vendor-swr-BIWyz7Rc.js";import{n as S,r as C}from"./gateway-config-swr-CTXr917C.js";import{$l as w,$t as T,Dd as E,Df as D,F as O,Fs as k,G as A,Gf as j,I as M,Jl as N,Ka as P,L as F,Mu as I,Ps as L,Vd as R,Ys as z,Yu as B,_o as V,bs as H,cl as U,du as W,en as ee,fo as te,kf as G,nn as ne,on as re,pu as K,rr as ie,ud as ae,vf as q,yu as J}from"./index-Cgd4fGVP.js";import{n as oe,r as se,t as ce}from"./settings-page-layout-Dx5S-Msc.js";import{n as Y,r as le,t as ue}from"./settings-form-section-Cl0eF4hl.js";import{_ as X,a as de,b as fe,c as pe,h as me,i as he,n as ge,o as _e,r as ve,s as ye,t as be,v as xe,y as Se}from"./tunnel-api-BeTAD8BN.js";import{t as Ce}from"./settings-advanced-gate-CjRLXfoo.js";var Z=e(t(),1),Q=n(),$=r();function we(e){switch(e){case`active`:return`text-emerald-700 dark:text-emerald-400`;case`connecting`:return`text-amber-700 dark:text-amber-400`;default:return`text-fg-muted`}}function Te(e){let t=(0,Q.c)(11),{label:n,kind:r}=e,i;t[0]===r?i=t[1]:(i=d(`inline-flex items-center gap-1.5 text-xs font-medium`,we(r)),t[0]=r,t[1]=i);let a=r===`active`&&`bg-emerald-500`,o=r===`connecting`&&`bg-amber-500`,s;t[2]!==a||t[3]!==o?(s=d(`size-1.5 rounded-full bg-fg-subtle/50`,a,o),t[2]=a,t[3]=o,t[4]=s):s=t[4];let c;t[5]===s?c=t[6]:(c=(0,$.jsx)(`span`,{className:s,"aria-hidden":!0}),t[5]=s,t[6]=c);let l;return t[7]!==n||t[8]!==i||t[9]!==c?(l=(0,$.jsxs)(`span`,{className:i,children:[c,n]}),t[7]=n,t[8]=i,t[9]=c,t[10]=l):l=t[10],l}function Ee(e){let t=(0,Q.c)(31),{onOpenTab:n}=e,r=p(Oe),i;t[0]===r?i=t[1]:(i=u(r),t[0]=r,t[1]=i);let a=i.remoteAccess.guide,o=!!f(De),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s={refreshInterval:3e4},t[2]=s):s=t[2];let{data:c}=x(o?`exposure-status`:null,Se,s),l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:15e3},t[3]=l):l=t[3];let{data:m}=x(o?`tunnel-status`:null,ge,l),h=C(o);if(!o)return null;let g=c?.tailscale.active===!0,_=m?.state,v=m?.enabled&&_===`connected`,y=m?.enabled&&(_===`connecting`||_===`reconnecting`||!!m?.startProgress||!!m?.frpcDownload),b=h.data?.payload?.config,S=!!(b&&typeof b==`object`&&!Array.isArray(b)&&b.gateway?.publicUrl),T=g?`active`:`off`,E=g?a.statusActive:a.statusOff,D;t[4]!==a.tailscaleCardTitle||t[5]!==T||t[6]!==E?(D={tab:`tailscale`,icon:R,title:a.tailscaleCardTitle,kind:T,statusLabel:E},t[4]=a.tailscaleCardTitle,t[5]=T,t[6]=E,t[7]=D):D=t[7];let O=v?`active`:y?`connecting`:`off`,k=v?a.statusActive:y?a.statusConnecting:a.statusOff,A;t[8]!==a.publicCardTitle||t[9]!==O||t[10]!==k?(A={tab:`public`,icon:B,title:a.publicCardTitle,kind:O,statusLabel:k},t[8]=a.publicCardTitle,t[9]=O,t[10]=k,t[11]=A):A=t[11];let j=S?`active`:`off`,M=S?a.statusActive:a.statusOff,N;t[12]!==a.reverseProxyCardTitle||t[13]!==j||t[14]!==M?(N={tab:`reverse-proxy`,icon:K,title:a.reverseProxyCardTitle,kind:j,statusLabel:M},t[12]=a.reverseProxyCardTitle,t[13]=j,t[14]=M,t[15]=N):N=t[15];let P;t[16]!==a.sshCardStatus||t[17]!==a.sshCardTitle?(P={tab:`ssh`,icon:w,title:a.sshCardTitle,kind:`off`,statusLabel:a.sshCardStatus},t[16]=a.sshCardStatus,t[17]=a.sshCardTitle,t[18]=P):P=t[18];let F;t[19]!==a.lanCardStatus||t[20]!==a.lanCardTitle?(F={tab:`lan`,icon:J,title:a.lanCardTitle,kind:`off`,statusLabel:a.lanCardStatus},t[19]=a.lanCardStatus,t[20]=a.lanCardTitle,t[21]=F):F=t[21];let I;t[22]!==N||t[23]!==P||t[24]!==F||t[25]!==D||t[26]!==A?(I=[D,A,N,P,F],t[22]=N,t[23]=P,t[24]=F,t[25]=D,t[26]=A,t[27]=I):I=t[27];let L=I,z;return t[28]!==L||t[29]!==n?(z=(0,$.jsx)(`div`,{className:`grid gap-1 rounded-xl bg-surface-hover/20 p-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:L.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:d(`flex items-start gap-3 rounded-lg bg-surface-base/45 px-2 py-3 text-left transition-colors`,`hover:bg-surface-hover/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center text-fg-muted`,children:(0,$.jsx)(t,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(Te,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[28]=L,t[29]=n,t[30]=z):z=t[30],z}function De(e){return e.conversationId}function Oe(e){return e.language}function ke(e){let t=(0,Q.c)(21),{title:n,description:r,recommended:i,icon:a,onOpen:o,recommendedLabel:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=d(`group flex w-full items-start gap-3 px-3 py-4 text-left transition-colors`,`hover:bg-surface-hover/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=c):c=t[0];let l;t[1]===a?l=t[2]:(l=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/70 text-fg-muted`,children:(0,$.jsx)(a,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=a,t[2]=l);let u;t[3]===n?u=t[4]:(u=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=u);let f;t[5]!==i||t[6]!==s?(f=i&&s?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:s}):null,t[5]=i,t[6]=s,t[7]=f):f=t[7];let p;t[8]!==u||t[9]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[u,f]}),t[8]=u,t[9]=f,t[10]=p):p=t[10];let m;t[11]===r?m=t[12]:(m=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=m);let h;t[13]!==p||t[14]!==m?(h=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[p,m]}),t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(D,{className:`mt-2 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":!0}),t[16]=g):g=t[16];let _;return t[17]!==o||t[18]!==l||t[19]!==h?(_=(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:c,children:[l,h,g]}),t[17]=o,t[18]=l,t[19]=h,t[20]=_):_=t[20],_}function Ae(e){let t=(0,Q.c)(78),{onOpenTab:n}=e,r=p(Ne),i;t[0]===r?i=t[1]:(i=u(r),t[0]=r,t[1]=i);let a=i.remoteAccess,o=a.guide,s=!!f(Me),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:l}=x(s?`exposure-status`:null,Se,c),d;t[3]===l?.conflicts?d=t[4]:(d=l?.conflicts??[],t[3]=l?.conflicts,t[4]=d);let m=d;if(!s){let e;return t[5]===o.needToken?e=t[6]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.needToken}),t[5]=o.needToken,t[6]=e),e}let h;t[7]===n?h=t[8]:(h=(0,$.jsx)(Ee,{onOpenTab:n}),t[7]=n,t[8]=h);let g;t[9]!==m||t[10]!==o.conflictsHint||t[11]!==o.conflictsTitle?(g=m.length>0?(0,$.jsxs)(`div`,{className:`rounded-xl bg-amber-500/10 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:o.conflictsTitle}),(0,$.jsx)(`p`,{className:`mt-1`,children:o.conflictsHint}),(0,$.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-xs`,children:m.map(je)})]}):null,t[9]=m,t[10]=o.conflictsHint,t[11]=o.conflictsTitle,t[12]=g):g=t[12];let _;t[13]===o.pickMethod?_=t[14]:(_=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o.pickMethod}),t[13]=o.pickMethod,t[14]=_);let v;t[15]===n?v=t[16]:(v=()=>n(`tailscale`),t[15]=n,t[16]=v);let y;t[17]!==o.recommended||t[18]!==o.tailscaleCardDesc||t[19]!==o.tailscaleCardTitle||t[20]!==v?(y=(0,$.jsx)(ke,{icon:R,title:o.tailscaleCardTitle,description:o.tailscaleCardDesc,recommended:!0,recommendedLabel:o.recommended,onOpen:v}),t[17]=o.recommended,t[18]=o.tailscaleCardDesc,t[19]=o.tailscaleCardTitle,t[20]=v,t[21]=y):y=t[21];let b;t[22]===n?b=t[23]:(b=()=>n(`public`),t[22]=n,t[23]=b);let S;t[24]!==o.publicCardDesc||t[25]!==o.publicCardTitle||t[26]!==b?(S=(0,$.jsx)(ke,{icon:B,title:o.publicCardTitle,description:o.publicCardDesc,onOpen:b}),t[24]=o.publicCardDesc,t[25]=o.publicCardTitle,t[26]=b,t[27]=S):S=t[27];let C;t[28]===n?C=t[29]:(C=()=>n(`reverse-proxy`),t[28]=n,t[29]=C);let T;t[30]!==o.reverseProxyCardDesc||t[31]!==o.reverseProxyCardTitle||t[32]!==C?(T=(0,$.jsx)(ke,{icon:K,title:o.reverseProxyCardTitle,description:o.reverseProxyCardDesc,onOpen:C}),t[30]=o.reverseProxyCardDesc,t[31]=o.reverseProxyCardTitle,t[32]=C,t[33]=T):T=t[33];let E;t[34]===n?E=t[35]:(E=()=>n(`ssh`),t[34]=n,t[35]=E);let D;t[36]!==o.sshCardDesc||t[37]!==o.sshCardTitle||t[38]!==E?(D=(0,$.jsx)(ke,{icon:w,title:o.sshCardTitle,description:o.sshCardDesc,onOpen:E}),t[36]=o.sshCardDesc,t[37]=o.sshCardTitle,t[38]=E,t[39]=D):D=t[39];let O;t[40]!==a.advanced.proxyBody||t[41]!==a.advanced.proxyTitle||t[42]!==T||t[43]!==D?(O=(0,$.jsxs)(A,{title:a.advanced.proxyTitle,summary:a.advanced.proxyBody,children:[T,D]}),t[40]=a.advanced.proxyBody,t[41]=a.advanced.proxyTitle,t[42]=T,t[43]=D,t[44]=O):O=t[44];let k;t[45]===n?k=t[46]:(k=()=>n(`lan`),t[45]=n,t[46]=k);let j;t[47]!==o.lanCardDesc||t[48]!==o.lanCardTitle||t[49]!==k?(j=(0,$.jsx)(ke,{icon:J,title:o.lanCardTitle,description:o.lanCardDesc,onOpen:k}),t[47]=o.lanCardDesc,t[48]=o.lanCardTitle,t[49]=k,t[50]=j):j=t[50];let M;t[51]!==S||t[52]!==O||t[53]!==j||t[54]!==y?(M=(0,$.jsxs)(`div`,{className:`mt-2 flex max-w-3xl flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[y,S,O,j]}),t[51]=S,t[52]=O,t[53]=j,t[54]=y,t[55]=M):M=t[55];let N;t[56]!==M||t[57]!==_?(N=(0,$.jsxs)(`div`,{children:[_,M]}),t[56]=M,t[57]=_,t[58]=N):N=t[58];let P;t[59]===o.oneAtATimeHint?P=t[60]:(P=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.oneAtATimeHint}),t[59]=o.oneAtATimeHint,t[60]=P);let F;t[61]===a.advanced.proxyTitle?F=t[62]:(F=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.advanced.proxyTitle}),t[61]=a.advanced.proxyTitle,t[62]=F);let I;t[63]===a.advanced.proxyBody?I=t[64]:(I=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.advanced.proxyBody}),t[63]=a.advanced.proxyBody,t[64]=I);let L;t[65]!==r||t[66]!==a.advanced.proxyDocs?(L=(0,$.jsx)(fe,{language:r,label:a.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[65]=r,t[66]=a.advanced.proxyDocs,t[67]=L):L=t[67];let z;t[68]!==F||t[69]!==I||t[70]!==L?(z=(0,$.jsxs)(`div`,{className:`max-w-3xl rounded-xl bg-surface-hover/20 px-4 py-4`,children:[F,I,L]}),t[68]=F,t[69]=I,t[70]=L,t[71]=z):z=t[71];let V;return t[72]!==N||t[73]!==P||t[74]!==z||t[75]!==h||t[76]!==g?(V=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[h,g,N,P,z]}),t[72]=N,t[73]=P,t[74]=z,t[75]=h,t[76]=g,t[77]=V):V=t[77],V}function je(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function Me(e){return e.conversationId}function Ne(e){return e.language}function Pe(){let e=(0,Q.c)(16),t=p(Fe),n;e[0]===t?n=e[1]:(n=u(t),e[0]=t,e[1]=n);let r=n.remoteAccess.lan,i;e[2]!==r.subtitle||e[3]!==r.title?(i=(0,$.jsx)(Y,{icon:J,title:r.title,subtitle:r.subtitle}),e[2]=r.subtitle,e[3]=r.title,e[4]=i):i=e[4];let a;e[5]===r.body?a=e[6]:(a=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.body}),e[5]=r.body,e[6]=a);let s;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),e[7]=s):s=e[7];let c;e[8]===r.link?c=e[9]:(c=(0,$.jsxs)(o,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[r.link,s]}),e[8]=r.link,e[9]=c);let d;e[10]!==a||e[11]!==c?(d=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[a,c]}),e[10]=a,e[11]=c,e[12]=d):d=e[12];let f;return e[13]!==i||e[14]!==d?(f=(0,$.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,$.jsxs)(ue,{children:[i,d]})}),e[13]=i,e[14]=d,e[15]=f):f=e[15],f}function Fe(e){return e.language}function Ie(e){let t=(0,Q.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=p(Le),a;t[0]===i?a=t[1]:(a=u(i),t[0]=i,t[1]=a);let o=a.remoteAccess.ssh,[s,l]=(0,Z.useState)(!1),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=async()=>{await b(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(l(!0),setTimeout(()=>l(!1),2e3))},t[2]=d):d=t[2];let f=d,m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg bg-surface-base/55 px-3 py-2 text-xs text-fg-muted`,children:`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`}),t[3]=m):m=t[3];let h,g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>void f(),g=(0,$.jsx)(c,{className:`mr-1 size-4`}),t[4]=h,t[5]=g):(h=t[4],g=t[5]);let _=s?o.copied:o.copy,v;t[6]===_?v=t[7]:(v=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(U,{type:`button`,variant:`ghost`,onClick:h,children:[g,_]})}),t[6]=_,t[7]=v);let y;t[8]!==r||t[9]!==o.hint?(y=r?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:o.hint}):null,t[8]=r,t[9]=o.hint,t[10]=y):y=t[10];let x;t[11]!==v||t[12]!==y?(x=(0,$.jsxs)($.Fragment,{children:[m,v,y]}),t[11]=v,t[12]=y,t[13]=x):x=t[13];let S=x;if(r){let e;t[14]!==o.subtitle||t[15]!==o.title?(e=(0,$.jsx)(Y,{icon:w,title:o.title,subtitle:o.subtitle}),t[14]=o.subtitle,t[15]=o.title,t[16]=e):e=t[16];let n;t[17]===S?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:S}),t[17]=S,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(ue,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let C;t[22]!==o.subtitle||t[23]!==o.title?(C=(0,$.jsx)(Y,{icon:w,title:o.title,subtitle:o.subtitle}),t[22]=o.subtitle,t[23]=o.title,t[24]=C):C=t[24];let T;t[25]===S?T=t[26]:(T=(0,$.jsx)(`div`,{className:`mt-4`,children:S}),t[25]=S,t[26]=T);let E;return t[27]!==C||t[28]!==T?(E=(0,$.jsxs)(ue,{children:[C,T]}),t[27]=C,t[28]=T,t[29]=E):E=t[29],E}function Le(e){return e.language}function Re(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Ie,{embedded:!0}),e[0]=t):t=e[0],t}var ze=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Be(e){return e&&ze.includes(e)?e:`guide`}function Ve(e){let t=(0,Q.c)(32),{showLabel:n,hideLabel:r,icon:i,hint:a,children:o,className:s,defaultOpen:c,advancedOnly:l}=e,u=l===void 0?!1:l,[f,p]=(0,Z.useState)(c??!1),m;t[0]===s?m=t[1]:(m=d(`rounded-xl bg-surface-hover/20`,s),t[0]=s,t[1]=m);let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>p(He),t[2]=h):h=t[2];let g=f&&`rotate-180`,_;t[3]===g?_=t[4]:(_=d(`size-4 shrink-0 text-fg-muted transition-transform duration-200 motion-reduce:transition-none`,g),t[3]=g,t[4]=_);let v;t[5]===_?v=t[6]:(v=(0,$.jsx)(G,{className:_,"aria-hidden":!0}),t[5]=_,t[6]=v);let y;t[7]===i?y=t[8]:(y=i?(0,$.jsx)(i,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}):null,t[7]=i,t[8]=y);let b=f?r:n,x;t[9]===b?x=t[10]:(x=(0,$.jsx)(`span`,{children:b}),t[9]=b,t[10]=x);let S;t[11]!==f||t[12]!==v||t[13]!==y||t[14]!==x?(S=(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":f,onClick:h,className:`flex w-full items-center gap-2 rounded-2xl px-4 py-3.5 text-left text-sm font-medium text-fg transition-colors hover:text-fg`,children:[v,y,x]}),t[11]=f,t[12]=v,t[13]=y,t[14]=x,t[15]=S):S=t[15];let C=f?`grid-rows-[1fr] opacity-100`:`grid-rows-[0fr] opacity-0`,w;t[16]===C?w=t[17]:(w=d(`grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none`,C),t[16]=C,t[17]=w);let T;t[18]===a?T=t[19]:(T=a?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[18]=a,t[19]=T);let E;t[20]!==o||t[21]!==T?(E=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-4 pt-1`,children:[T,o]})}),t[20]=o,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==w||t[24]!==E?(D=(0,$.jsx)(`div`,{className:w,children:E}),t[23]=w,t[24]=E,t[25]=D):D=t[25];let O;t[26]!==S||t[27]!==D||t[28]!==m?(O=(0,$.jsxs)(`section`,{className:m,children:[S,D]}),t[26]=S,t[27]=D,t[28]=m,t[29]=O):O=t[29];let k=O;if(u){let e;return t[30]===k?e=t[31]:(e=(0,$.jsx)(Ce,{children:k}),t[30]=k,t[31]=e),e}return k}function He(e){return!e}function Ue(e){let t=(0,Q.c)(40),{open:n,title:r,intro:i,bullets:a,checkboxLabel:o,confirmLabel:s,cancelLabel:c,onConfirm:l,onCancel:u}=e,[f,p]=(0,Z.useState)(!1),b;t[0]===u?b=t[1]:(b=e=>{e||(p(!1),u())},t[0]=u,t[1]=b);let x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(m,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,k)}),t[2]=x):x=t[2];let S;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=d(`xopc-dialog-content fixed left-1/2 top-1/2 max-h-[min(90vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-overlay p-6 shadow-popover outline-none dark:border-edge`,L),t[3]=S):S=t[3];let C;t[4]===r?C=t[5]:(C=(0,$.jsx)(v,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=C);let w;t[6]===i?w=t[7]:(w=(0,$.jsx)(h,{className:`mt-2 text-sm text-fg-muted`,children:i}),t[6]=i,t[7]=w);let T;t[8]===a?T=t[9]:(T=a.map(We),t[8]=a,t[9]=T);let E;t[10]===T?E=t[11]:(E=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:T}),t[10]=T,t[11]=E);let D;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>p(e.target.checked),t[12]=D):D=t[12];let O;t[13]===f?O=t[14]:(O=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:f,onChange:D}),t[13]=f,t[14]=O);let A;t[15]===o?A=t[16]:(A=(0,$.jsx)(`span`,{children:o}),t[15]=o,t[16]=A);let j;t[17]!==A||t[18]!==O?(j=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[O,A]}),t[17]=A,t[18]=O,t[19]=j):j=t[19];let M;t[20]!==c||t[21]!==u?(M=(0,$.jsx)(U,{type:`button`,variant:`secondary`,onClick:u,children:c}),t[20]=c,t[21]=u,t[22]=M):M=t[22];let N=!f,P;t[23]!==s||t[24]!==l||t[25]!==N?(P=(0,$.jsx)(U,{type:`button`,disabled:N,onClick:l,children:s}),t[23]=s,t[24]=l,t[25]=N,t[26]=P):P=t[26];let F;t[27]!==M||t[28]!==P?(F=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[M,P]}),t[27]=M,t[28]=P,t[29]=F):F=t[29];let I;t[30]!==j||t[31]!==F||t[32]!==C||t[33]!==w||t[34]!==E?(I=(0,$.jsxs)(g,{children:[x,(0,$.jsxs)(_,{className:S,onOpenAutoFocus:Ge,children:[C,w,E,j,F]})]}),t[30]=j,t[31]=F,t[32]=C,t[33]=w,t[34]=E,t[35]=I):I=t[35];let R;return t[36]!==n||t[37]!==b||t[38]!==I?(R=(0,$.jsx)(y,{open:n,onOpenChange:b,children:I}),t[36]=n,t[37]=b,t[38]=I,t[39]=R):R=t[39],R}function We(e){return(0,$.jsx)(`li`,{children:e},e)}function Ge(e){return e.preventDefault()}function Ke(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var qe=[`preparing_frpc`,`registering`,`starting_frpc`];function Je(e){return e?e===`reconnecting_frpc`?qe.indexOf(`starting_frpc`):qe.indexOf(e):-1}function Ye(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=qe.indexOf(e),i=Je(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Xe(e,t,n){let r=n.startProgress;return Ye(t,n)===`active`?t===`preparing_frpc`&&n.frpcDownload?n.frpcDownload.phase===`extracting`?e.frpcExtracting:n.frpcDownload.percent==null?e.frpcDownloading:e.frpcDownloadingPercent.replace(`{{percent}}`,String(n.frpcDownload.percent)):t===`registering`&&r?.publicUrl?e.stepRegisterDetail:t===`starting_frpc`?r?.phase===`reconnecting_frpc`?e.stepReconnectDetail:e.stepFrpcDetail:null:null}function Ze(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function Qe(e){if(!e)return null;let t=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function $e(e){let t=(0,Q.c)(31),{status:n,t:r}=e,[,i]=(0,Z.useState)(0),a;t[0]!==i||t[1]!==n.state?(a=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>i(et),1e3);return()=>window.clearInterval(e)},t[0]=i,t[1]=n.state,t[2]=a):a=t[2];let o=n.startProgress?.startedAt,c;if(t[3]!==n.state||t[4]!==o?(c=[n.state,o],t[3]=n.state,t[4]=o,t[5]=c):c=t[5],(0,Z.useEffect)(a,c),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let l,u,f,p,m;if(t[6]!==n||t[7]!==r){let e=Qe(n.startProgress?.startedAt);l=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,u=`mt-3 space-y-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`;let i;t[13]===r.startProgressTitle?i=t[14]:(i=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.startProgressTitle}),t[13]=r.startProgressTitle,t[14]=i);let a;t[15]===r.startProgressHint?a=t[16]:(a=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.startProgressHint}),t[15]=r.startProgressHint,t[16]=a),t[17]!==i||t[18]!==a?(f=(0,$.jsxs)(`div`,{children:[i,a]}),t[17]=i,t[18]=a,t[19]=f):f=t[19];let o=qe.map(e=>{let t=Ye(e,n),i=Xe(r,e,n);return(0,$.jsxs)(`li`,{className:`flex gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-subtle`,"aria-hidden":!0,children:t===`done`?(0,$.jsx)(s,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(ae,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(q,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:d(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:Ze(r,e)}),i?(0,$.jsx)(`div`,{className:`mt-0.5 text-fg-muted`,children:i}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload&&n.frpcDownload.phase===`downloading`?(0,$.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-panel`,children:(0,$.jsx)(`div`,{className:d(`h-full rounded-full bg-accent transition-[width] duration-300`,n.frpcDownload.percent==null&&`w-1/3 animate-pulse`),style:n.frpcDownload.percent==null?void 0:{width:`${n.frpcDownload.percent}%`}})}),n.frpcDownload.bytesReceived!=null&&n.frpcDownload.totalBytes?(0,$.jsxs)(`p`,{className:`text-fg-subtle`,children:[Ke(n.frpcDownload.bytesReceived),` /`,` `,Ke(n.frpcDownload.totalBytes)]}):null]}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload?.url?(0,$.jsxs)(`p`,{className:`mt-2 text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`font-sans`,children:[r.frpcDownloadingUrlLabel,`: `]}),(0,$.jsx)(`a`,{href:n.frpcDownload.url,target:`_blank`,rel:`noopener noreferrer`,className:`break-all font-mono text-[11px] text-accent hover:underline`,children:n.frpcDownload.url})]}):null]})]},e)});t[20]===o?p=t[21]:(p=(0,$.jsx)(`ol`,{className:`space-y-2`,children:o}),t[20]=o,t[21]=p),m=e&&n.startProgress?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.startProgressElapsed.replace(`{{elapsed}}`,e)}):null,t[6]=n,t[7]=r,t[8]=l,t[9]=u,t[10]=f,t[11]=p,t[12]=m}else l=t[8],u=t[9],f=t[10],p=t[11],m=t[12];let h;t[22]!==l||t[23]!==r.publicUrlPendingNotice?(h=l?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=l,t[23]=r.publicUrlPendingNotice,t[24]=h):h=t[24];let g;return t[25]!==u||t[26]!==f||t[27]!==p||t[28]!==m||t[29]!==h?(g=(0,$.jsxs)(`div`,{className:u,children:[f,p,m,h]}),t[25]=u,t[26]=f,t[27]=p,t[28]=m,t[29]=h,t[30]=g):g=t[30],g}function et(e){return e+1}function tt(e,t){return t.state===`connected`?e.statusConnected:t.state===`error`?e.statusError:t.startProgress?.phase===`reconnecting_frpc`?e.statusReconnecting:t.startProgress?.phase===`starting_frpc`?e.statusStartingFrpc:t.startProgress?.phase===`registering`?e.statusRegistering:t.startProgress?.phase===`preparing_frpc`||t.frpcDownload?e.statusPreparingFrpc:t.state===`connecting`||t.state===`reconnecting`?e.statusConnecting:e.statusOff}function nt(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function rt(e){switch(e){case`connected`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`progress`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;case`error`:return`bg-red-500/15 text-red-700 dark:text-red-400`;default:return`bg-surface-hover text-fg-muted`}}function it(e){if(!e)return`—`;let t=Date.now()-new Date(e).getTime();if(t<0)return`—`;let n=Math.floor(t/6e4);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function at(e){let t=(0,Q.c)(61),{t:n,status:r,isLoading:i,statusErr:a,starting:o,stopping:s,showConsentExpired:c,copyLabels:l,startDisabled:u,startDisabledReason:f,stepLabel:p,onStart:m,onStop:h}=e,g=u===void 0?!1:u,_,v,y,b,x,S,C;t[0]!==r||t[1]!==o?(C=nt(r),_=r.enabled||o,v=o||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=d(le(),`space-y-4`),t[9]=S):S=t[9],x=`flex flex-wrap items-start justify-between gap-3`,b=`flex items-center gap-2`,y=d(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,rt(C)),t[0]=r,t[1]=o,t[2]=_,t[3]=v,t[4]=y,t[5]=b,t[6]=x,t[7]=S,t[8]=C):(_=t[2],v=t[3],y=t[4],b=t[5],x=t[6],S=t[7],C=t[8]);let w=C===`connected`&&`bg-emerald-500`,T=C===`progress`&&`bg-amber-500 animate-pulse`,E=C===`error`&&`bg-red-500`,D=C===`off`&&`bg-fg-subtle`,O;t[10]!==w||t[11]!==T||t[12]!==E||t[13]!==D?(O=d(`size-1.5 rounded-full`,w,T,E,D),t[10]=w,t[11]=T,t[12]=E,t[13]=D,t[14]=O):O=t[14];let k;t[15]===O?k=t[16]:(k=(0,$.jsx)(`span`,{className:O,"aria-hidden":!0}),t[15]=O,t[16]=k);let A;t[17]!==i||t[18]!==r||t[19]!==n?(A=i&&!r.enabled?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block h-3 w-16 animate-pulse rounded-full bg-surface-hover/70 motion-reduce:animate-none`}):tt(n,r),t[17]=i,t[18]=r,t[19]=n,t[20]=A):A=t[20];let j;t[21]!==k||t[22]!==A||t[23]!==y?(j=(0,$.jsxs)(`span`,{className:y,children:[k,A]}),t[21]=k,t[22]=A,t[23]=y,t[24]=j):j=t[24];let M;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(M=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,it(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=M):M=t[28];let F;t[29]!==j||t[30]!==M||t[31]!==b?(F=(0,$.jsxs)(`div`,{className:b,children:[j,M]}),t[29]=j,t[30]=M,t[31]=b,t[32]=F):F=t[32];let L;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(R,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=L):L=t[33];let z;t[34]!==F||t[35]!==x?(z=(0,$.jsxs)(`div`,{className:x,children:[F,L]}),t[34]=F,t[35]=x,t[36]=z):z=t[36];let B;t[37]===a?B=t[38]:(B=a?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a instanceof Error?a.message:String(a)}):null,t[37]=a,t[38]=B);let V;t[39]!==c||t[40]!==n.consentExpiredBanner?(V=c?(0,$.jsx)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=c,t[40]=n.consentExpiredBanner,t[41]=V):V=t[41];let H;t[42]!==_||t[43]!==l||t[44]!==m||t[45]!==h||t[46]!==v||t[47]!==r||t[48]!==g||t[49]!==f||t[50]!==o||t[51]!==p||t[52]!==s||t[53]!==n?(H=_?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,$.jsx)(P,{label:n.publicUrlLabel,text:r.publicUrl,labels:l})}):null,v?(0,$.jsx)($e,{status:r,t:n}):null,r.lastError&&r.state===`error`?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:r.lastError}):null,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.enabled?(0,$.jsxs)(U,{type:`button`,variant:`secondary`,disabled:s,onClick:h,children:[s?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(U,{type:`button`,disabled:o,onClick:m,children:[o?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):(0,$.jsx)(I,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:p}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.emptyStateTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.emptyStateBody})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg bg-amber-500/10 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(N,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),g&&f?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:f}):null,(0,$.jsxs)(U,{type:`button`,disabled:o||g,onClick:m,className:`w-full sm:w-auto`,children:[o?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):(0,$.jsx)(I,{className:`size-4`}),n.start]})]}),t[42]=_,t[43]=l,t[44]=m,t[45]=h,t[46]=v,t[47]=r,t[48]=g,t[49]=f,t[50]=o,t[51]=p,t[52]=s,t[53]=n,t[54]=H):H=t[54];let W;return t[55]!==z||t[56]!==B||t[57]!==V||t[58]!==H||t[59]!==S?(W=(0,$.jsxs)(`section`,{className:S,children:[z,B,V,H]}),t[55]=z,t[56]=B,t[57]=V,t[58]=H,t[59]=S,t[60]=W):W=t[60],W}var ot={reconfiguring:!1};function st(e){let t=(0,Q.c)(89),{t:n,brokerSecretReady:r,brokerSecretConfiguredInConfig:i,brokerSecretMaskedValue:a,brokerSecretDraft:o,savingBrokerSecret:c,authorizingBrokerSecret:u,brokerSecretAuthorizationUrl:f,brokerSecretNotice:p,copyFailedLabel:m,onDraftChange:h,onSave:g,onAuthorize:_,onClear:v,sectionRef:y}=e,b=(0,Z.useId)(),x=r,S=!x,[C,w]=(0,Z.useReducer)(V,ot),{reconfiguring:T}=C,D;t[0]!==i||t[1]!==o||t[2]!==T?(D=i&&!T&&!o.trim(),t[0]=i,t[1]=o,t[2]=T,t[3]=D):D=t[3];let O=D,k;t[4]!==n.copied||t[5]!==n.copyKey||t[6]!==n.hideKey||t[7]!==n.showKey?(k={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[4]=n.copied,t[5]=n.copyKey,t[6]=n.hideKey,t[7]=n.showKey,t[8]=k):k=t[8];let A=k,j;t[9]===o?j=t[10]:(j=o.trim().length>0&&!re(o.trim()),t[9]=o,t[10]=j);let M=j,N;t[11]===h?N=t[12]:(N=()=>{w({type:`patch`,patch:{reconfiguring:!1}}),h(``)},t[11]=h,t[12]=N);let P=N,F=S&&`ring-1 ring-amber-500/30`,I;t[13]===F?I=t[14]:(I=d(F),t[13]=F,t[14]=I);let L=x?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:S?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,R;t[15]===L?R=t[16]:(R=d(`flex size-9 shrink-0 items-center justify-center rounded-lg`,L),t[15]=L,t[16]=R);let B;t[17]===x?B=t[18]:(B=x?(0,$.jsx)(s,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(E,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=x,t[18]=B);let H;t[19]!==R||t[20]!==B?(H=(0,$.jsx)(`span`,{className:R,children:B}),t[19]=R,t[20]=B,t[21]=H):H=t[21];let W=x?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,ee;t[22]===W?ee=t[23]:(ee=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:W}),t[22]=W,t[23]=ee);let te=x?n.brokerSecretReadyHint:n.brokerSecretHint,G;t[24]===te?G=t[25]:(G=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:te}),t[24]=te,t[25]=G);let ne;t[26]!==S||t[27]!==n.brokerSecretMissingHint?(ne=S?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[26]=S,t[27]=n.brokerSecretMissingHint,t[28]=ne):ne=t[28];let K;t[29]!==ee||t[30]!==G||t[31]!==ne?(K=(0,$.jsxs)(`div`,{children:[ee,G,ne]}),t[29]=ee,t[30]=G,t[31]=ne,t[32]=K):K=t[32];let ie;t[33]!==u||t[34]!==S||t[35]!==_||t[36]!==T||t[37]!==c||t[38]!==n.brokerSecretAuthorize||t[39]!==n.brokerSecretAuthorizing||t[40]!==n.brokerSecretConsoleLink?(ie=S||T?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(U,{type:`button`,disabled:c||u,onClick:_,children:[u?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):null,u?n.brokerSecretAuthorizing:n.brokerSecretAuthorize]}),(0,$.jsxs)(`a`,{href:be,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n.brokerSecretConsoleLink,(0,$.jsx)(l,{className:`size-3`,"aria-hidden":!0})]})]}):null,t[33]=u,t[34]=S,t[35]=_,t[36]=T,t[37]=c,t[38]=n.brokerSecretAuthorize,t[39]=n.brokerSecretAuthorizing,t[40]=n.brokerSecretConsoleLink,t[41]=ie):ie=t[41];let q;t[42]!==u||t[43]!==f||t[44]!==n.brokerSecretOpenAuthorization?(q=u&&f?(0,$.jsxs)(`a`,{href:f,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,children:[n.brokerSecretOpenAuthorization,(0,$.jsx)(l,{className:`size-3`,"aria-hidden":!0})]}):null,t[42]=u,t[43]=f,t[44]=n.brokerSecretOpenAuthorization,t[45]=q):q=t[45];let J;t[46]!==i||t[47]!==o||t[48]!==a||t[49]!==M||t[50]!==P||t[51]!==m||t[52]!==b||t[53]!==S||t[54]!==v||t[55]!==h||t[56]!==g||t[57]!==T||t[58]!==c||t[59]!==A||t[60]!==O||t[61]!==n.brokerSecretCancelReconfigure||t[62]!==n.brokerSecretClear||t[63]!==n.brokerSecretMaskedHelp||t[64]!==n.brokerSecretNotInConfigFile||t[65]!==n.brokerSecretPlaceholder||t[66]!==n.brokerSecretReconfigure||t[67]!==n.brokerSecretRevealFailed||t[68]!==n.brokerSecretSave||t[69]!==n.brokerSecretSaveAndContinue||t[70]!==n.brokerSecretTitle?(J=O?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:b,children:n.brokerSecretTitle}),(0,$.jsx)(z,{id:b,value:a,labels:A,reveal:ct,loadFailedLabel:m||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(U,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>{w({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(U,{type:`button`,variant:`ghost`,disabled:c,onClick:v,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:b,children:n.brokerSecretTitle}),(0,$.jsx)(z,{id:b,value:o,onChange:h,placeholder:n.brokerSecretPlaceholder,labels:A,disabled:c}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(U,{type:`button`,disabled:c||!M,onClick:g,children:[c?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):null,S?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),i?(0,$.jsx)(U,{type:`button`,variant:`ghost`,disabled:c,onClick:v,children:n.brokerSecretClear}):null,T?(0,$.jsx)(U,{type:`button`,variant:`ghost`,disabled:c,onClick:P,children:n.brokerSecretCancelReconfigure}):null]})]}),t[46]=i,t[47]=o,t[48]=a,t[49]=M,t[50]=P,t[51]=m,t[52]=b,t[53]=S,t[54]=v,t[55]=h,t[56]=g,t[57]=T,t[58]=c,t[59]=A,t[60]=O,t[61]=n.brokerSecretCancelReconfigure,t[62]=n.brokerSecretClear,t[63]=n.brokerSecretMaskedHelp,t[64]=n.brokerSecretNotInConfigFile,t[65]=n.brokerSecretPlaceholder,t[66]=n.brokerSecretReconfigure,t[67]=n.brokerSecretRevealFailed,t[68]=n.brokerSecretSave,t[69]=n.brokerSecretSaveAndContinue,t[70]=n.brokerSecretTitle,t[71]=J):J=t[71];let oe;t[72]===p?oe=t[73]:(oe=p?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:p}):null,t[72]=p,t[73]=oe);let se;t[74]!==K||t[75]!==ie||t[76]!==q||t[77]!==J||t[78]!==oe?(se=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[K,ie,q,J,oe]}),t[74]=K,t[75]=ie,t[76]=q,t[77]=J,t[78]=oe,t[79]=se):se=t[79];let ce;t[80]!==H||t[81]!==se?(ce=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[H,se]}),t[80]=H,t[81]=se,t[82]=ce):ce=t[82];let Y;t[83]!==ce||t[84]!==I?(Y=(0,$.jsx)(ue,{className:I,children:ce}),t[83]=ce,t[84]=I,t[85]=Y):Y=t[85];let le;return t[86]!==y||t[87]!==Y?(le=(0,$.jsx)(`div`,{ref:y,id:`tunnel-broker-secret-setup`,children:Y}),t[86]=y,t[87]=Y,t[88]=le):le=t[88],le}function ct(){return _e().then(lt)}function lt(e){return e.registrationSecret??null}var ut={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null};function dt({embedded:e=!1}){let t=p(e=>e.language),n=u(t).tunnelSettings,r=!!f(e=>e.conversationId),[i,a]=(0,Z.useReducer)(V,ut),{actionError:o,starting:s,stopping:c,savingAutoStart:l,consentOpen:m,autoStartConfirmOpen:h,releaseConfirmOpen:g,releasing:_,brokerSecretDraft:v,savingBrokerSecret:y,authorizingBrokerSecret:b,brokerSecretAuthorizationUrl:w,brokerSecretNotice:E}=i,D=(0,Z.useRef)(null),{data:k}=C(r),{data:A,error:j,isLoading:N,mutate:P}=x(r?`tunnel-status`:null,ge,{refreshInterval:e=>s?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),I=(0,Z.useMemo)(()=>{let e=k?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)&&t.autoStart===!0)return!0}return A?.config?.autoStart===!0},[k,A?.config?.autoStart]),L=(0,Z.useMemo)(()=>{let e=k?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.registrationSecret;if(typeof e==`string`)return e}}return``},[k]),z=re(L),B=A?.registrationSecret?.configured??z;(0,Z.useEffect)(()=>{let e=()=>{P()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[P]);let H=(0,Z.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),W=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{actionError:null}}),a({type:`patch`,patch:{starting:!0}});try{await ye(),await P(),S()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{starting:!1}})}},[P]),G=(0,Z.useCallback)(()=>{if(!B){a({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),D.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(A?.consentRequired){a({type:`patch`,patch:{consentOpen:!0}});return}W()},[B,A?.consentRequired,W,n.brokerSecretRequiredBeforeStart]),K=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{consentOpen:!1}}),a({type:`patch`,patch:{actionError:null}});try{await de(),await Promise.all([P(),W()])}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[P,W]),ie=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{actionError:null}}),a({type:`patch`,patch:{stopping:!0}});try{await pe(),await P(),S()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{stopping:!1}})}},[P]),q=(0,Z.useCallback)(async e=>{a({type:`patch`,patch:{savingAutoStart:!0}}),a({type:`patch`,patch:{actionError:null}});try{await ve({autoStart:e}),S()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingAutoStart:!1}})}},[]),J=(0,Z.useCallback)(()=>{if(I){q(!1);return}if(A?.consentRequired){a({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!A?.canAutoStart){a({type:`patch`,patch:{actionError:n.autoStartHint}});return}a({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[q,A?.canAutoStart,A?.consentRequired,n,I]),oe=(0,Z.useCallback)(async()=>{let e=v.trim();if(e){a({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await ve({registrationSecret:e}),a({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),S(),await P(),a({type:`patch`,patch:{actionError:null}})}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[v,P,n.brokerSecretSaved]),se=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await ve({registrationSecret:null}),a({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),S(),await P()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingBrokerSecret:!1}})}},[P,n.brokerSecretCleared]),ce=(0,Z.useCallback)(async()=>{let e=F(),t=null,r=null;a({type:`patch`,patch:{authorizingBrokerSecret:!0,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null,actionError:null}});try{for(t=(await ne(`xopc-tunnel`)).sessionId;;){await new Promise(e=>window.setTimeout(e,1e3));let i=await ee(t);if(i.authUrl&&i.authUrl!==r&&(r=i.authUrl,a({type:`patch`,patch:{brokerSecretAuthorizationUrl:i.authUrl}}),await M(i.authUrl,e)),i.status===`failed`||i.status===`cancelled`)throw Error(i.error??i.message??`OAuth authorization failed`);if(i.status===`completed`){await he(),await Promise.all([P(),S()]),a({type:`patch`,patch:{brokerSecretNotice:n.brokerSecretSaved,brokerSecretDraft:``}});return}}}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{O(e),t&&T(t).catch(()=>void 0),a({type:`patch`,patch:{authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null}})}},[P,n.brokerSecretSaved]),Y=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await pe({release:!0}),await P(),S()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{releasing:!1}})}},[P]),le=(0,Z.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:u(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!r)return(0,$.jsx)(`div`,{className:e?void 0:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let X=A??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:I,brokerUrl:`https://frp.xopc.ai/api`}},me=A?.consentRequired&&(X.enabled||I||A?.consent?.acceptedAt),_e=(0,$.jsx)(st,{t:n,brokerSecretReady:B,brokerSecretConfiguredInConfig:z,brokerSecretMaskedValue:z?L:``,brokerSecretDraft:v,savingBrokerSecret:y,authorizingBrokerSecret:b,brokerSecretAuthorizationUrl:w,brokerSecretNotice:E,copyFailedLabel:u(t).clipboard.copyFailed,onDraftChange:e=>a({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void oe(),onAuthorize:()=>void ce(),onClear:()=>void se(),sectionRef:D}),be=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ue,{open:m,title:n.consentTitle,intro:n.consentIntro,bullets:H,checkboxLabel:n.consentCheckbox,confirmLabel:me?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void K(),onCancel:()=>a({type:`patch`,patch:{consentOpen:!1}})},m?`consent-open`:`consent-closed`),(0,$.jsx)(te,{open:h,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{a({type:`patch`,patch:{autoStartConfirmOpen:!1}}),q(!0)},onCancel:()=>a({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(te,{open:g,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void Y(),onCancel:()=>a({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o}):null,_e,(0,$.jsx)(at,{t:n,status:X,isLoading:N,statusErr:j,starting:s,stopping:c,showConsentExpired:!!me,copyLabels:le,startDisabled:!B,startDisabledReason:B?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:G,onStop:()=>void ie()}),(0,$.jsxs)(Ve,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:d(`flex items-center gap-3 text-sm text-fg`,!I&&!A?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:I,disabled:l||!I&&!A?.canAutoStart,onChange:J}),n.autoStart]}),!A?.canAutoStart&&!I?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,X.subdomain||X.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[(0,$.jsxs)(U,{type:`button`,variant:`secondary`,disabled:_||c,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>a({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[_?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(Ve,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-base/45 p-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(R,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(fe,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),be]}):(0,$.jsxs)(`div`,{className:e?`flex w-full flex-col gap-6`:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[e?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o}):null,_e,(0,$.jsx)(at,{t:n,status:X,isLoading:N,statusErr:j,starting:s,stopping:c,showConsentExpired:!!me,copyLabels:le,startDisabled:!B,startDisabledReason:B?void 0:n.brokerSecretRequiredBeforeStart,onStart:G,onStop:()=>void ie()}),X.subdomain||X.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(U,{type:`button`,variant:`secondary`,disabled:_||c,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>a({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[_?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):null,n.release]})}):null,X.subdomain||X.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(ue,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:d(`flex items-center gap-3 text-sm text-fg`,!I&&!A?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:I,disabled:l||!I&&!A?.canAutoStart,onChange:J}),n.autoStart]}),!A?.canAutoStart&&!I?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n.autoStartHint}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-panel/80 px-3 py-2 text-xs text-fg-subtle shadow-surface`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(R,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(fe,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),be]})}function ft(e,t){return e.tabs[t]}function pt(e,t){return e.tabIntro[t]}function mt(e){switch(e){case`tailscale`:return`tailscale-serve`;case`public`:return`public-tunnel`;case`reverse-proxy`:return`reverse-proxy`;case`ssh`:return`ssh-tunnel`;case`lan`:return`lan`;default:return}}function ht(e){let t=(0,Q.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(Ae,{onOpenTab:r}),t[0]=r,t[1]=e),e}case`tailscale`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(xe,{embedded:!0}),t[2]=e):e=t[2],e}case`public`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(dt,{embedded:!0}),t[3]=e):e=t[3],e}case`reverse-proxy`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Re,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Pe,{}),t[6]=e):e=t[6],e}}}function gt(){let e=(0,Q.c)(3),t=i(),n=p(vt),r=u(n).remoteAccess,o=!!f(_t),[s,c]=a(),l=ie(),d=Be(s.get(`tab`)),m=s.get(`intent`)===`mobile-pairing`,h;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(h={refreshInterval:2e3},e[0]=h):h=e[0];let g=x(m?`device-pairing-readiness`:null,me,h),_;e[1]===c?_=e[2]:(_=e=>{c(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[1]=c,e[2]=_);let v=_,y=pt(r,d),b=ze.filter(e=>l||e!==`ssh`&&e!==`reverse-proxy`||e===d).map(e=>({id:e,label:ft(r,e)}));return(0,$.jsxs)(se,{children:[(0,$.jsx)(oe,{title:r.pageTitle,meta:(0,$.jsx)(fe,{language:n,label:r.docsLink,section:mt(d),className:`mt-1`})}),o?(0,$.jsxs)($.Fragment,{children:[m?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl bg-accent-soft px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(W,{className:`mt-0.5 size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.mobilePairingFlow.title}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:g.data?.ready?r.mobilePairingFlow.ready:r.mobilePairingFlow.hint})]})]}),(0,$.jsxs)(U,{variant:`primary`,disabled:!g.data?.ready,onClick:()=>t(`/settings/devices?startDevicePairing=mobile`),children:[g.data?.ready?r.mobilePairingFlow.continue:r.mobilePairingFlow.waiting,(0,$.jsx)(j,{className:`size-4`,"aria-hidden":!0})]})]}):null,(0,$.jsx)(H,{items:b,activeTab:d,onChange:v,ariaLabel:r.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(ce,{id:d,activeTab:d,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:ft(r,d),hint:d===`public`?void 0:y,showHeading:!1,framed:!1,children:(0,$.jsx)(ht,{tab:d,onOpenTab:v})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.guide.needToken})]})}function _t(e){return e.conversationId}function vt(e){return e.language}export{gt as RemoteAccessHub};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./circle-check-C23XjkUj.js";import{t as i}from"./download-Dk-ZjtO6.js";import{t as a}from"./messages-D__oW2yE.js";import{n as o,r as s}from"./locale-store-D_migb9R.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{Ds as l,Ef as u,Eu as d,Os as f,Un as p,cl as m,do as h}from"./index-BUv4J0JN.js";import{n as g,r as _}from"./settings-page-layout-Dx5S-Msc.js";import{t as v}from"./settings-advanced-gate-BE-SKsf6.js";import{i as y,n as b,r as x}from"./runtime-tools-api-CmEWVrOg.js";var S=e(t(),1);function C(e){return e?.trim()||void 0}function w(e,t,n){return e?.state===`ready`?C(t)!==C(n):!0}var T=n(),E=[`node`,`python`,`uv`];function D(){let e=a(o(e=>e.language)).runtimeToolsSettings,{data:t,error:n,isLoading:C,mutate:D}=c(s(`/api/runtime-tools`)),[O,k]=(0,S.useState)(null),[A,j]=(0,S.useState)(!1),[M,N]=(0,S.useState)(!1),[P,F]=(0,S.useState)({}),[I,L]=(0,S.useState)({}),[R,z]=(0,S.useState)(null),B=Object.values(P).some(Boolean);if((0,S.useEffect)(()=>{t?.payload.config&&k(structuredClone(t.payload.config))},[t?.payload.config]),n)return(0,T.jsxs)(_,{children:[(0,T.jsx)(g,{title:e.title,subtitle:e.loadError}),(0,T.jsx)(m,{onClick:()=>void D(),children:e.refresh})]});if(C||!O)return(0,T.jsx)(_,{children:(0,T.jsx)(p,{sections:3})});let V=new Map(t?.payload.statuses.map(e=>[e.runtime,e])),H=(e,t)=>k(n=>n&&{...n,[e]:{...n[e],...t}}),U=async()=>{j(!0),z(null);try{await y(O),await D()}catch(e){z(e instanceof Error?e.message:String(e))}finally{j(!1)}},W=async(e,t)=>{F(t=>({...t,[e]:!0})),z(null);try{await y(O),await x({runtime:e,action:t,version:e===`uv`?O.uv.version:O[e].version,onProgress:t=>L(n=>({...n,[e]:t}))}),await D()}catch(e){z(e instanceof Error?e.message:String(e))}finally{F(t=>({...t,[e]:!1}))}},G=async()=>{N(!0),z(null);try{await b(),await D()}catch(e){z(e instanceof Error?e.message:String(e))}finally{N(!1)}};return(0,T.jsxs)(_,{gap:`gap-6`,children:[(0,T.jsx)(g,{title:e.title,actions:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(h,{className:`size-9 shrink-0 p-0`,disabled:B,label:e.refresh,onClick:async()=>{await D()}}),(0,T.jsx)(m,{onClick:()=>void G(),disabled:M||B,children:M?e.pruning:e.prune}),(0,T.jsx)(m,{variant:`primary`,onClick:()=>void U(),disabled:A||B,children:A?e.saving:e.save})]})}),R?(0,T.jsx)(`div`,{className:`rounded-xl bg-danger/10 px-4 py-3 text-sm text-danger`,children:R}):null,(0,T.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:(0,T.jsxs)(`label`,{className:`flex items-center justify-between gap-4`,children:[(0,T.jsxs)(`span`,{children:[(0,T.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.enabled}),(0,T.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.enabledHint})]}),(0,T.jsx)(`input`,{type:`checkbox`,checked:O.enabled,onChange:e=>k({...O,enabled:e.target.checked}),className:`size-4 accent-accent`})]})}),(0,T.jsx)(v,{children:(0,T.jsxs)(`section`,{className:`grid gap-4 rounded-xl bg-surface-hover/20 p-4 md:grid-cols-2`,children:[(0,T.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.downloadSource,(0,T.jsxs)(l,{value:O.download.source,onChange:e=>k({...O,download:{...O.download,source:e.target.value}}),children:[(0,T.jsx)(f,{value:`auto`,children:e.downloadSources.auto}),(0,T.jsx)(f,{value:`website-only`,children:e.downloadSources.websiteOnly}),(0,T.jsx)(f,{value:`direct-only`,children:e.downloadSources.directOnly})]})]}),(0,T.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.gatewayBaseUrl,(0,T.jsx)(`input`,{value:O.download.gatewayBaseUrl,disabled:O.download.source===`direct-only`,onChange:e=>k({...O,download:{...O.download,gatewayBaseUrl:e.target.value}}),className:`h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-edge-strong disabled:opacity-50`})]}),(0,T.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.offlineBundle,(0,T.jsx)(`input`,{value:O.download.bundleDir??``,placeholder:e.offlineBundlePlaceholder,onChange:e=>k({...O,download:{...O.download,bundleDir:e.target.value||void 0}}),className:`h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-edge-strong`})]}),(0,T.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.proxy,(0,T.jsx)(`input`,{value:O.download.proxy??``,placeholder:`http://127.0.0.1:7890`,onChange:e=>k({...O,download:{...O.download,proxy:e.target.value||void 0}}),className:`h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-edge-strong`})]})]})}),(0,T.jsx)(`div`,{className:`flex flex-col gap-4`,children:E.map(n=>{let a=V.get(n),o=a?.state===`ready`,s=I[n],c=n===`uv`?O.uv:O[n],p=n===`uv`?t?.payload.config.uv:t?.payload.config[n],h=P[n]===!0,g=w(a,c.version,p?.version);return(0,T.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-5 rounded-xl bg-surface-base/55 p-5 sm:p-6`,children:[(0,T.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e.runtimeNames[n]}),(0,T.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:a?.message??e.unknown})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o?(0,T.jsx)(r,{className:`size-5 shrink-0 text-success`}):(0,T.jsx)(u,{className:`size-5 shrink-0 text-warning`}),(0,T.jsx)(`input`,{type:`checkbox`,"aria-label":`${e.runtimeNames[n]} ${e.enabled}`,checked:c.enabled,onChange:e=>{n===`uv`?k({...O,uv:{...O.uv,enabled:e.target.checked}}):H(n,{enabled:e.target.checked})},className:`size-4 accent-accent`})]})]}),(0,T.jsxs)(`div`,{className:n===`uv`?`grid gap-4 md:grid-cols-[minmax(16rem,28rem)]`:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:[(0,T.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.version,(0,T.jsx)(`input`,{value:c.version??``,placeholder:a?.requestedVersion,onChange:e=>{let t=e.target.value||void 0;n===`uv`?k({...O,uv:{...O.uv,version:t}}):H(n,{version:t})},className:`h-10 w-full rounded-lg border border-edge bg-surface-inset px-3 text-sm text-fg outline-none focus:border-edge-strong`})]}),n===`uv`?null:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.sourcePolicy,(0,T.jsxs)(l,{value:O[n].preference,onChange:e=>H(n,{preference:e.target.value}),children:[(0,T.jsx)(f,{value:`managed-first`,children:e.preferences.managedFirst}),(0,T.jsx)(f,{value:`system-first`,children:e.preferences.systemFirst}),(0,T.jsx)(f,{value:`managed-only`,children:e.preferences.managedOnly}),(0,T.jsx)(f,{value:`system-only`,children:e.preferences.systemOnly})]})]}),(0,T.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.provisionPolicy,(0,T.jsxs)(l,{value:O[n].provision,onChange:e=>H(n,{provision:e.target.value}),children:[(0,T.jsx)(f,{value:`eager`,children:e.provisions.eager}),(0,T.jsx)(f,{value:`on-demand`,children:e.provisions.onDemand}),(0,T.jsx)(f,{value:`disabled`,children:e.provisions.disabled})]})]})]})]}),s&&h?(0,T.jsxs)(`div`,{className:`rounded-lg bg-accent-soft px-3 py-2 text-xs text-accent-fg`,children:[s.message,s.totalBytes&&s.downloadedBytes?` · ${Math.round(s.downloadedBytes/s.totalBytes*100)}%`:``]}):null,(0,T.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[g?(0,T.jsxs)(m,{variant:`primary`,disabled:!O.enabled||!c.enabled||h,onClick:()=>void W(n,`install`),children:[(0,T.jsx)(i,{className:`size-4`}),h?e.working:e.install]}):(0,T.jsxs)(`span`,{className:`inline-flex h-9 items-center gap-2 px-1 text-sm text-success`,children:[(0,T.jsx)(r,{className:`size-4`}),e.installed]}),a?.repairable?(0,T.jsxs)(m,{disabled:!O.enabled||!c.enabled||h,onClick:()=>void W(n,`repair`),children:[(0,T.jsx)(d,{className:`size-4`}),e.repair]}):null]}),(0,T.jsx)(v,{children:a?.resolved?.executable?(0,T.jsx)(`code`,{className:`break-all text-[11px] text-fg-subtle`,children:a.resolved.executable}):null})]})]},n)})})]})}export{D as RuntimeToolsSettingsPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./circle-check-C23XjkUj.js";import{t as i}from"./download-Dk-ZjtO6.js";import{t as a}from"./messages-D__oW2yE.js";import{n as o,r as s}from"./locale-store-D_migb9R.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{Ds as l,Ef as u,Eu as d,Os as f,Un as p,cl as m,do as h}from"./index-Cgd4fGVP.js";import{n as g,r as _}from"./settings-page-layout-Dx5S-Msc.js";import{t as v}from"./settings-advanced-gate-CjRLXfoo.js";import{i as y,n as b,r as x}from"./runtime-tools-api-CmEWVrOg.js";var S=e(t(),1);function C(e){return e?.trim()||void 0}function w(e,t,n){return e?.state===`ready`?C(t)!==C(n):!0}var T=n(),E=[`node`,`python`,`uv`];function D(){let e=a(o(e=>e.language)).runtimeToolsSettings,{data:t,error:n,isLoading:C,mutate:D}=c(s(`/api/runtime-tools`)),[O,k]=(0,S.useState)(null),[A,j]=(0,S.useState)(!1),[M,N]=(0,S.useState)(!1),[P,F]=(0,S.useState)({}),[I,L]=(0,S.useState)({}),[R,z]=(0,S.useState)(null),B=Object.values(P).some(Boolean);if((0,S.useEffect)(()=>{t?.payload.config&&k(structuredClone(t.payload.config))},[t?.payload.config]),n)return(0,T.jsxs)(_,{children:[(0,T.jsx)(g,{title:e.title,subtitle:e.loadError}),(0,T.jsx)(m,{onClick:()=>void D(),children:e.refresh})]});if(C||!O)return(0,T.jsx)(_,{children:(0,T.jsx)(p,{sections:3})});let V=new Map(t?.payload.statuses.map(e=>[e.runtime,e])),H=(e,t)=>k(n=>n&&{...n,[e]:{...n[e],...t}}),U=async()=>{j(!0),z(null);try{await y(O),await D()}catch(e){z(e instanceof Error?e.message:String(e))}finally{j(!1)}},W=async(e,t)=>{F(t=>({...t,[e]:!0})),z(null);try{await y(O),await x({runtime:e,action:t,version:e===`uv`?O.uv.version:O[e].version,onProgress:t=>L(n=>({...n,[e]:t}))}),await D()}catch(e){z(e instanceof Error?e.message:String(e))}finally{F(t=>({...t,[e]:!1}))}},G=async()=>{N(!0),z(null);try{await b(),await D()}catch(e){z(e instanceof Error?e.message:String(e))}finally{N(!1)}};return(0,T.jsxs)(_,{gap:`gap-6`,children:[(0,T.jsx)(g,{title:e.title,actions:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(h,{className:`size-9 shrink-0 p-0`,disabled:B,label:e.refresh,onClick:async()=>{await D()}}),(0,T.jsx)(m,{onClick:()=>void G(),disabled:M||B,children:M?e.pruning:e.prune}),(0,T.jsx)(m,{variant:`primary`,onClick:()=>void U(),disabled:A||B,children:A?e.saving:e.save})]})}),R?(0,T.jsx)(`div`,{className:`rounded-xl bg-danger/10 px-4 py-3 text-sm text-danger`,children:R}):null,(0,T.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:(0,T.jsxs)(`label`,{className:`flex items-center justify-between gap-4`,children:[(0,T.jsxs)(`span`,{children:[(0,T.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.enabled}),(0,T.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.enabledHint})]}),(0,T.jsx)(`input`,{type:`checkbox`,checked:O.enabled,onChange:e=>k({...O,enabled:e.target.checked}),className:`size-4 accent-accent`})]})}),(0,T.jsx)(v,{children:(0,T.jsxs)(`section`,{className:`grid gap-4 rounded-xl bg-surface-hover/20 p-4 md:grid-cols-2`,children:[(0,T.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.downloadSource,(0,T.jsxs)(l,{value:O.download.source,onChange:e=>k({...O,download:{...O.download,source:e.target.value}}),children:[(0,T.jsx)(f,{value:`auto`,children:e.downloadSources.auto}),(0,T.jsx)(f,{value:`website-only`,children:e.downloadSources.websiteOnly}),(0,T.jsx)(f,{value:`direct-only`,children:e.downloadSources.directOnly})]})]}),(0,T.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.gatewayBaseUrl,(0,T.jsx)(`input`,{value:O.download.gatewayBaseUrl,disabled:O.download.source===`direct-only`,onChange:e=>k({...O,download:{...O.download,gatewayBaseUrl:e.target.value}}),className:`h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-edge-strong disabled:opacity-50`})]}),(0,T.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.offlineBundle,(0,T.jsx)(`input`,{value:O.download.bundleDir??``,placeholder:e.offlineBundlePlaceholder,onChange:e=>k({...O,download:{...O.download,bundleDir:e.target.value||void 0}}),className:`h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-edge-strong`})]}),(0,T.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.proxy,(0,T.jsx)(`input`,{value:O.download.proxy??``,placeholder:`http://127.0.0.1:7890`,onChange:e=>k({...O,download:{...O.download,proxy:e.target.value||void 0}}),className:`h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-edge-strong`})]})]})}),(0,T.jsx)(`div`,{className:`flex flex-col gap-4`,children:E.map(n=>{let a=V.get(n),o=a?.state===`ready`,s=I[n],c=n===`uv`?O.uv:O[n],p=n===`uv`?t?.payload.config.uv:t?.payload.config[n],h=P[n]===!0,g=w(a,c.version,p?.version);return(0,T.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-5 rounded-xl bg-surface-base/55 p-5 sm:p-6`,children:[(0,T.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e.runtimeNames[n]}),(0,T.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:a?.message??e.unknown})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o?(0,T.jsx)(r,{className:`size-5 shrink-0 text-success`}):(0,T.jsx)(u,{className:`size-5 shrink-0 text-warning`}),(0,T.jsx)(`input`,{type:`checkbox`,"aria-label":`${e.runtimeNames[n]} ${e.enabled}`,checked:c.enabled,onChange:e=>{n===`uv`?k({...O,uv:{...O.uv,enabled:e.target.checked}}):H(n,{enabled:e.target.checked})},className:`size-4 accent-accent`})]})]}),(0,T.jsxs)(`div`,{className:n===`uv`?`grid gap-4 md:grid-cols-[minmax(16rem,28rem)]`:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:[(0,T.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.version,(0,T.jsx)(`input`,{value:c.version??``,placeholder:a?.requestedVersion,onChange:e=>{let t=e.target.value||void 0;n===`uv`?k({...O,uv:{...O.uv,version:t}}):H(n,{version:t})},className:`h-10 w-full rounded-lg border border-edge bg-surface-inset px-3 text-sm text-fg outline-none focus:border-edge-strong`})]}),n===`uv`?null:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.sourcePolicy,(0,T.jsxs)(l,{value:O[n].preference,onChange:e=>H(n,{preference:e.target.value}),children:[(0,T.jsx)(f,{value:`managed-first`,children:e.preferences.managedFirst}),(0,T.jsx)(f,{value:`system-first`,children:e.preferences.systemFirst}),(0,T.jsx)(f,{value:`managed-only`,children:e.preferences.managedOnly}),(0,T.jsx)(f,{value:`system-only`,children:e.preferences.systemOnly})]})]}),(0,T.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.provisionPolicy,(0,T.jsxs)(l,{value:O[n].provision,onChange:e=>H(n,{provision:e.target.value}),children:[(0,T.jsx)(f,{value:`eager`,children:e.provisions.eager}),(0,T.jsx)(f,{value:`on-demand`,children:e.provisions.onDemand}),(0,T.jsx)(f,{value:`disabled`,children:e.provisions.disabled})]})]})]})]}),s&&h?(0,T.jsxs)(`div`,{className:`rounded-lg bg-accent-soft px-3 py-2 text-xs text-accent-fg`,children:[s.message,s.totalBytes&&s.downloadedBytes?` · ${Math.round(s.downloadedBytes/s.totalBytes*100)}%`:``]}):null,(0,T.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[g?(0,T.jsxs)(m,{variant:`primary`,disabled:!O.enabled||!c.enabled||h,onClick:()=>void W(n,`install`),children:[(0,T.jsx)(i,{className:`size-4`}),h?e.working:e.install]}):(0,T.jsxs)(`span`,{className:`inline-flex h-9 items-center gap-2 px-1 text-sm text-success`,children:[(0,T.jsx)(r,{className:`size-4`}),e.installed]}),a?.repairable?(0,T.jsxs)(m,{disabled:!O.enabled||!c.enabled||h,onClick:()=>void W(n,`repair`),children:[(0,T.jsx)(d,{className:`size-4`}),e.repair]}):null]}),(0,T.jsx)(v,{children:a?.resolved?.executable?(0,T.jsx)(`code`,{className:`break-all text-[11px] text-fg-subtle`,children:a.resolved.executable}):null})]})]},n)})})]})}export{D as RuntimeToolsSettingsPanel};
@@ -1 +1 @@
1
- import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-0WouolD0.js";import{Ds as i,Ks as a,Os as o,Ys as s}from"./index-BUv4J0JN.js";import{t as c}from"./number-input-DDeqHK-G.js";var l=t();e();var u=n();function d(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function f(e){let t=e[`x-order`];return typeof t==`number`&&!Number.isNaN(t)?t:999}function p(e){let t=e[`x-group`];return typeof t==`string`&&t.length>0?t:``}function m(e){return e[`x-hidden`]===!0}function h(e){let t=e.properties;if(!d(t))return[];let n=[];for(let[e,r]of Object.entries(t))d(r)&&(m(r)||n.push({key:e,sub:r,order:f(r),group:p(r),hidden:!1}));return n.sort((e,t)=>e.order-t.order||e.key.localeCompare(t.key)),n}function g(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 _(e){let t=(0,l.c)(38),{name:n,s:r,value:o,onChange:c,disabled:d}=e,f=typeof r.description==`string`?r.description:void 0,p=(typeof r[`x-placeholder`]==`string`?r[`x-placeholder`]:null)||f,m=r.format;if(Array.isArray(r.enum)&&r.enum.every(y)){let e;t[0]===f?e=t[1]:(e=f?(0,u.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[0]=f,t[1]=e);let a;t[2]===c?a=t[3]:(a=e=>c(e.target.value),t[2]=c,t[3]=a);let s;t[4]===r.enum?s=t[5]:(s=r.enum.map(v),t[4]=r.enum,t[5]=s);let l;t[6]!==d||t[7]!==n||t[8]!==a||t[9]!==s||t[10]!==o?(l=(0,u.jsx)(i,{name:n,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg`,value:o,disabled:d,onChange:a,children:s}),t[6]=d,t[7]=n,t[8]=a,t[9]=s,t[10]=o,t[11]=l):l=t[11];let p;return t[12]!==e||t[13]!==l?(p=(0,u.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,l]}),t[12]=e,t[13]=l,t[14]=p):p=t[14],p}if(m===`password`){let e;t[15]===f?e=t[16]:(e=f?(0,u.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[15]=f,t[16]=e);let n;t[17]!==d||t[18]!==c||t[19]!==p||t[20]!==o?(n=(0,u.jsx)(s,{value:o,onChange:c,placeholder:p,labels:a,disabled:d,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]=d,t[18]=c,t[19]=p,t[20]=o,t[21]=n):n=t[21];let r;return t[22]!==e||t[23]!==n?(r=(0,u.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,n]}),t[22]=e,t[23]=n,t[24]=r):r=t[24],r}let h;t[25]===f?h=t[26]:(h=f?(0,u.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[25]=f,t[26]=h);let g;t[27]===c?g=t[28]:(g=e=>c(e.target.value),t[27]=c,t[28]=g);let _;t[29]!==d||t[30]!==n||t[31]!==p||t[32]!==g||t[33]!==o?(_=(0,u.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:o,placeholder:p,disabled:d,onChange:g}),t[29]=d,t[30]=n,t[31]=p,t[32]=g,t[33]=o,t[34]=_):_=t[34];let b;return t[35]!==h||t[36]!==_?(b=(0,u.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[h,_]}),t[35]=h,t[36]=_,t[37]=b):b=t[37],b}function v(e){return(0,u.jsx)(o,{value:e,children:e},e)}function y(e){return typeof e==`string`}function b(e){let t=(0,l.c)(11),{s:n,value:r,onChange:i,disabled:a}=e,o=typeof n.description==`string`?n.description:void 0,s;t[0]===o?s=t[1]:(s=o?(0,u.jsx)(`label`,{className:`text-xs text-fg-muted`,children:o}):null,t[0]=o,t[1]=s);let d=Number.isFinite(r)?r:0,f;t[2]===i?f=t[3]:(f=e=>i(Number(e.target.value)),t[2]=i,t[3]=f);let p;t[4]!==a||t[5]!==d||t[6]!==f?(p=(0,u.jsx)(c,{type:`number`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg`,value:d,disabled:a,onChange:f}),t[4]=a,t[5]=d,t[6]=f,t[7]=p):p=t[7];let m;return t[8]!==s||t[9]!==p?(m=(0,u.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,p]}),t[8]=s,t[9]=p,t[10]=m):m=t[10],m}function x(e){let t=(0,l.c)(11),{s:n,value:r,onChange:i,disabled:a,labels:o}=e,s=(typeof n.description==`string`?n.description:void 0)??(typeof n.title==`string`&&n.title.length>0?n.title:o?.defaultBooleanLabel??`Enable`),c;t[0]===i?c=t[1]:(c=e=>i(e.target.checked),t[0]=i,t[1]=c);let d;t[2]!==a||t[3]!==c||t[4]!==r?(d=(0,u.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border border-edge`,checked:r,disabled:a,onChange:c}),t[2]=a,t[3]=c,t[4]=r,t[5]=d):d=t[5];let f;t[6]===s?f=t[7]:(f=(0,u.jsx)(`span`,{children:s}),t[6]=s,t[7]=f);let p;return t[8]!==d||t[9]!==f?(p=(0,u.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 S(e){let t=(0,l.c)(27),{s:n,value:r,onChange:i,disabled:a,labels:o}=e,s=typeof n.description==`string`?n.description:void 0,c=n.items,f=d(c)?c.type:void 0;if(!(f===`string`||Array.isArray(f)&&f.includes(`string`))){let e=o?.unsupportedArrayType??`Unsupported array type`,n;return t[0]===e?n=t[1]:(n=(0,u.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]!==s||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]===s?_=t[12]:(_=s?(0,u.jsx)(`label`,{className:`text-xs text-fg-muted`,children:s}):null,t[11]=s,t[12]=_),m=`flex flex-wrap gap-1`,h=e.map(t=>(0,u.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,u.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,disabled:a,onClick:()=>i(e.filter(e=>e!==t)),children:`×`})]},t)),t[2]=s,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,u.jsx)(`div`,{className:m,children:h}),t[13]=m,t[14]=h,t[15]=v):v=t[15];let y=o?.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,u.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,u.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 C(e){let t=(0,l.c)(66),{k:n,sub:r,value:i,onValue:a,disabled:o,labels:s}=e,c=r.type,f=(typeof r.title==`string`&&r.title.length>0?r.title:null)??n;if(c===`boolean`){let e;t[0]===f?e=t[1]:(e=(0,u.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[0]=f,t[1]=e);let n=i===!0,c;t[2]===a?c=t[3]:(c=e=>a(e),t[2]=a,t[3]=c);let l;t[4]!==o||t[5]!==s||t[6]!==r||t[7]!==n||t[8]!==c?(l=(0,u.jsx)(x,{s:r,value:n,disabled:o,onChange:c,labels:s}),t[4]=o,t[5]=s,t[6]=r,t[7]=n,t[8]=c,t[9]=l):l=t[9];let d;return t[10]!==e||t[11]!==l?(d=(0,u.jsxs)(`div`,{className:`space-y-1.5`,children:[e,l]}),t[10]=e,t[11]=l,t[12]=d):d=t[12],d}if(c===`number`||c===`integer`){let e;t[13]===f?e=t[14]:(e=(0,u.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[13]=f,t[14]=e);let n=typeof i==`number`?i:0,s;t[15]!==o||t[16]!==a||t[17]!==r||t[18]!==n?(s=(0,u.jsx)(b,{s:r,value:n,disabled:o,onChange:a}),t[15]=o,t[16]=a,t[17]=r,t[18]=n,t[19]=s):s=t[19];let c;return t[20]!==e||t[21]!==s?(c=(0,u.jsxs)(`div`,{className:`space-y-1.5`,children:[e,s]}),t[20]=e,t[21]=s,t[22]=c):c=t[22],c}if(c===`string`){let e;t[23]===f?e=t[24]:(e=(0,u.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[23]=f,t[24]=e);let s=typeof i==`string`?i:``,c;t[25]!==o||t[26]!==n||t[27]!==a||t[28]!==r||t[29]!==s?(c=(0,u.jsx)(_,{name:n,s:r,value:s,disabled:o,onChange:a}),t[25]=o,t[26]=n,t[27]=a,t[28]=r,t[29]=s,t[30]=c):c=t[30];let l;return t[31]!==e||t[32]!==c?(l=(0,u.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[31]=e,t[32]=c,t[33]=l):l=t[33],l}if(c===`array`){let e=r.items,n=d(e)?e.type:void 0;if(n===`string`||Array.isArray(n)&&n.includes(`string`)){let e;t[34]===f?e=t[35]:(e=(0,u.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(w)?i.map(String):[],t[36]=i,t[37]=n);let c;t[38]!==o||t[39]!==s||t[40]!==a||t[41]!==r||t[42]!==n?(c=(0,u.jsx)(S,{s:r,value:n,disabled:o,onChange:a,labels:s}),t[38]=o,t[39]=s,t[40]=a,t[41]=r,t[42]=n,t[43]=c):c=t[43];let l;return t[44]!==e||t[45]!==c?(l=(0,u.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[44]=e,t[45]=c,t[46]=l):l=t[46],l}}if(c===`object`){let e;t[47]===i?e=t[48]:(e=d(i)?i:{},t[47]=i,t[48]=e);let n=e,c;t[49]===f?c=t[50]:(c=(0,u.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]=c);let l;t[51]!==o||t[52]!==s||t[53]!==n||t[54]!==a||t[55]!==r?(l=(0,u.jsx)(`div`,{className:`border-t border-edge p-3`,children:(0,u.jsx)(T,{schema:r,values:n,onChange:a,disabled:o,labels:s})}),t[51]=o,t[52]=s,t[53]=n,t[54]=a,t[55]=r,t[56]=l):l=t[56];let p;return t[57]!==c||t[58]!==l?(p=(0,u.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[c,l]}),t[57]=c,t[58]=l,t[59]=p):p=t[59],p}let p;t[60]!==s||t[61]!==c||t[62]!==f?(p=s?.unsupportedFieldType?.(f,typeof c==`string`?c:void 0)??`${f}: unsupported field type${typeof c==`string`?` (${c})`:``}`,t[60]=s,t[61]=c,t[62]=f,t[63]=p):p=t[63];let m;return t[64]===p?m=t[65]:(m=(0,u.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[64]=p,t[65]=m),m}function w(e){return typeof e==`string`||typeof e==`number`}function T(e){let t=(0,l.c)(28),{schema:n,values:i,onChange:a,disabled:o,className:s,labels:c}=e,f=o===void 0?!1:o,p;bb0:{if(n.type!==`object`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],p=e;break bb0}let e;t[1]===n?e=t[2]:(e=h(n),t[1]=n,t[2]=e),p=e}let m=p,_;bb1:{if(m.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]===m?e=t[5]:(e=g(m),t[4]=m,t[5]=e),_=e}let v=_,y;t[6]!==a||t[7]!==i?(y=(e,t)=>{a({...i,[e]:t})},t[6]=a,t[7]=i,t[8]=y):y=t[8];let b=y;if(n.type!==`object`||!d(n.properties)||m.length===0)return null;let x,S;if(t[9]!==s||t[10]!==f||t[11]!==v||t[12]!==c||t[13]!==b||t[14]!==i){let e=Array.from(v.keys()).sort(E);t[17]===s?x=t[18]:(x=r(`flex flex-col gap-4`,s),t[17]=s,t[18]=x);let n;t[19]!==f||t[20]!==v||t[21]!==c||t[22]!==b||t[23]!==i?(n=e=>{let t=(v.get(e)??[]).map(e=>(0,u.jsx)(C,{k:e.key,sub:e.sub,value:i[e.key],onValue:t=>b(e.key,t),disabled:f,labels:c},e.key));return e===``?(0,u.jsx)(`div`,{children:t},`default`):(0,u.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[(0,u.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,u.jsx)(`div`,{className:`space-y-4 border-t border-edge p-3`,children:t})]},e)},t[19]=f,t[20]=v,t[21]=c,t[22]=b,t[23]=i,t[24]=n):n=t[24],S=e.map(n),t[9]=s,t[10]=f,t[11]=v,t[12]=c,t[13]=b,t[14]=i,t[15]=x,t[16]=S}else x=t[15],S=t[16];let w;return t[25]!==x||t[26]!==S?(w=(0,u.jsx)(`div`,{className:x,children:S}),t[25]=x,t[26]=S,t[27]=w):w=t[27],w}function E(e,t){return e===``?-1:t===``?1:e.localeCompare(t)}export{T as t};
1
+ import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-0WouolD0.js";import{Ds as i,Ks as a,Os as o,Ys as s}from"./index-Cgd4fGVP.js";import{t as c}from"./number-input-DDeqHK-G.js";var l=t();e();var u=n();function d(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function f(e){let t=e[`x-order`];return typeof t==`number`&&!Number.isNaN(t)?t:999}function p(e){let t=e[`x-group`];return typeof t==`string`&&t.length>0?t:``}function m(e){return e[`x-hidden`]===!0}function h(e){let t=e.properties;if(!d(t))return[];let n=[];for(let[e,r]of Object.entries(t))d(r)&&(m(r)||n.push({key:e,sub:r,order:f(r),group:p(r),hidden:!1}));return n.sort((e,t)=>e.order-t.order||e.key.localeCompare(t.key)),n}function g(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 _(e){let t=(0,l.c)(38),{name:n,s:r,value:o,onChange:c,disabled:d}=e,f=typeof r.description==`string`?r.description:void 0,p=(typeof r[`x-placeholder`]==`string`?r[`x-placeholder`]:null)||f,m=r.format;if(Array.isArray(r.enum)&&r.enum.every(y)){let e;t[0]===f?e=t[1]:(e=f?(0,u.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[0]=f,t[1]=e);let a;t[2]===c?a=t[3]:(a=e=>c(e.target.value),t[2]=c,t[3]=a);let s;t[4]===r.enum?s=t[5]:(s=r.enum.map(v),t[4]=r.enum,t[5]=s);let l;t[6]!==d||t[7]!==n||t[8]!==a||t[9]!==s||t[10]!==o?(l=(0,u.jsx)(i,{name:n,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg`,value:o,disabled:d,onChange:a,children:s}),t[6]=d,t[7]=n,t[8]=a,t[9]=s,t[10]=o,t[11]=l):l=t[11];let p;return t[12]!==e||t[13]!==l?(p=(0,u.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,l]}),t[12]=e,t[13]=l,t[14]=p):p=t[14],p}if(m===`password`){let e;t[15]===f?e=t[16]:(e=f?(0,u.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[15]=f,t[16]=e);let n;t[17]!==d||t[18]!==c||t[19]!==p||t[20]!==o?(n=(0,u.jsx)(s,{value:o,onChange:c,placeholder:p,labels:a,disabled:d,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]=d,t[18]=c,t[19]=p,t[20]=o,t[21]=n):n=t[21];let r;return t[22]!==e||t[23]!==n?(r=(0,u.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,n]}),t[22]=e,t[23]=n,t[24]=r):r=t[24],r}let h;t[25]===f?h=t[26]:(h=f?(0,u.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[25]=f,t[26]=h);let g;t[27]===c?g=t[28]:(g=e=>c(e.target.value),t[27]=c,t[28]=g);let _;t[29]!==d||t[30]!==n||t[31]!==p||t[32]!==g||t[33]!==o?(_=(0,u.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:o,placeholder:p,disabled:d,onChange:g}),t[29]=d,t[30]=n,t[31]=p,t[32]=g,t[33]=o,t[34]=_):_=t[34];let b;return t[35]!==h||t[36]!==_?(b=(0,u.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[h,_]}),t[35]=h,t[36]=_,t[37]=b):b=t[37],b}function v(e){return(0,u.jsx)(o,{value:e,children:e},e)}function y(e){return typeof e==`string`}function b(e){let t=(0,l.c)(11),{s:n,value:r,onChange:i,disabled:a}=e,o=typeof n.description==`string`?n.description:void 0,s;t[0]===o?s=t[1]:(s=o?(0,u.jsx)(`label`,{className:`text-xs text-fg-muted`,children:o}):null,t[0]=o,t[1]=s);let d=Number.isFinite(r)?r:0,f;t[2]===i?f=t[3]:(f=e=>i(Number(e.target.value)),t[2]=i,t[3]=f);let p;t[4]!==a||t[5]!==d||t[6]!==f?(p=(0,u.jsx)(c,{type:`number`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg`,value:d,disabled:a,onChange:f}),t[4]=a,t[5]=d,t[6]=f,t[7]=p):p=t[7];let m;return t[8]!==s||t[9]!==p?(m=(0,u.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,p]}),t[8]=s,t[9]=p,t[10]=m):m=t[10],m}function x(e){let t=(0,l.c)(11),{s:n,value:r,onChange:i,disabled:a,labels:o}=e,s=(typeof n.description==`string`?n.description:void 0)??(typeof n.title==`string`&&n.title.length>0?n.title:o?.defaultBooleanLabel??`Enable`),c;t[0]===i?c=t[1]:(c=e=>i(e.target.checked),t[0]=i,t[1]=c);let d;t[2]!==a||t[3]!==c||t[4]!==r?(d=(0,u.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border border-edge`,checked:r,disabled:a,onChange:c}),t[2]=a,t[3]=c,t[4]=r,t[5]=d):d=t[5];let f;t[6]===s?f=t[7]:(f=(0,u.jsx)(`span`,{children:s}),t[6]=s,t[7]=f);let p;return t[8]!==d||t[9]!==f?(p=(0,u.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 S(e){let t=(0,l.c)(27),{s:n,value:r,onChange:i,disabled:a,labels:o}=e,s=typeof n.description==`string`?n.description:void 0,c=n.items,f=d(c)?c.type:void 0;if(!(f===`string`||Array.isArray(f)&&f.includes(`string`))){let e=o?.unsupportedArrayType??`Unsupported array type`,n;return t[0]===e?n=t[1]:(n=(0,u.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]!==s||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]===s?_=t[12]:(_=s?(0,u.jsx)(`label`,{className:`text-xs text-fg-muted`,children:s}):null,t[11]=s,t[12]=_),m=`flex flex-wrap gap-1`,h=e.map(t=>(0,u.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,u.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,disabled:a,onClick:()=>i(e.filter(e=>e!==t)),children:`×`})]},t)),t[2]=s,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,u.jsx)(`div`,{className:m,children:h}),t[13]=m,t[14]=h,t[15]=v):v=t[15];let y=o?.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,u.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,u.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 C(e){let t=(0,l.c)(66),{k:n,sub:r,value:i,onValue:a,disabled:o,labels:s}=e,c=r.type,f=(typeof r.title==`string`&&r.title.length>0?r.title:null)??n;if(c===`boolean`){let e;t[0]===f?e=t[1]:(e=(0,u.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[0]=f,t[1]=e);let n=i===!0,c;t[2]===a?c=t[3]:(c=e=>a(e),t[2]=a,t[3]=c);let l;t[4]!==o||t[5]!==s||t[6]!==r||t[7]!==n||t[8]!==c?(l=(0,u.jsx)(x,{s:r,value:n,disabled:o,onChange:c,labels:s}),t[4]=o,t[5]=s,t[6]=r,t[7]=n,t[8]=c,t[9]=l):l=t[9];let d;return t[10]!==e||t[11]!==l?(d=(0,u.jsxs)(`div`,{className:`space-y-1.5`,children:[e,l]}),t[10]=e,t[11]=l,t[12]=d):d=t[12],d}if(c===`number`||c===`integer`){let e;t[13]===f?e=t[14]:(e=(0,u.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[13]=f,t[14]=e);let n=typeof i==`number`?i:0,s;t[15]!==o||t[16]!==a||t[17]!==r||t[18]!==n?(s=(0,u.jsx)(b,{s:r,value:n,disabled:o,onChange:a}),t[15]=o,t[16]=a,t[17]=r,t[18]=n,t[19]=s):s=t[19];let c;return t[20]!==e||t[21]!==s?(c=(0,u.jsxs)(`div`,{className:`space-y-1.5`,children:[e,s]}),t[20]=e,t[21]=s,t[22]=c):c=t[22],c}if(c===`string`){let e;t[23]===f?e=t[24]:(e=(0,u.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[23]=f,t[24]=e);let s=typeof i==`string`?i:``,c;t[25]!==o||t[26]!==n||t[27]!==a||t[28]!==r||t[29]!==s?(c=(0,u.jsx)(_,{name:n,s:r,value:s,disabled:o,onChange:a}),t[25]=o,t[26]=n,t[27]=a,t[28]=r,t[29]=s,t[30]=c):c=t[30];let l;return t[31]!==e||t[32]!==c?(l=(0,u.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[31]=e,t[32]=c,t[33]=l):l=t[33],l}if(c===`array`){let e=r.items,n=d(e)?e.type:void 0;if(n===`string`||Array.isArray(n)&&n.includes(`string`)){let e;t[34]===f?e=t[35]:(e=(0,u.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(w)?i.map(String):[],t[36]=i,t[37]=n);let c;t[38]!==o||t[39]!==s||t[40]!==a||t[41]!==r||t[42]!==n?(c=(0,u.jsx)(S,{s:r,value:n,disabled:o,onChange:a,labels:s}),t[38]=o,t[39]=s,t[40]=a,t[41]=r,t[42]=n,t[43]=c):c=t[43];let l;return t[44]!==e||t[45]!==c?(l=(0,u.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[44]=e,t[45]=c,t[46]=l):l=t[46],l}}if(c===`object`){let e;t[47]===i?e=t[48]:(e=d(i)?i:{},t[47]=i,t[48]=e);let n=e,c;t[49]===f?c=t[50]:(c=(0,u.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]=c);let l;t[51]!==o||t[52]!==s||t[53]!==n||t[54]!==a||t[55]!==r?(l=(0,u.jsx)(`div`,{className:`border-t border-edge p-3`,children:(0,u.jsx)(T,{schema:r,values:n,onChange:a,disabled:o,labels:s})}),t[51]=o,t[52]=s,t[53]=n,t[54]=a,t[55]=r,t[56]=l):l=t[56];let p;return t[57]!==c||t[58]!==l?(p=(0,u.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[c,l]}),t[57]=c,t[58]=l,t[59]=p):p=t[59],p}let p;t[60]!==s||t[61]!==c||t[62]!==f?(p=s?.unsupportedFieldType?.(f,typeof c==`string`?c:void 0)??`${f}: unsupported field type${typeof c==`string`?` (${c})`:``}`,t[60]=s,t[61]=c,t[62]=f,t[63]=p):p=t[63];let m;return t[64]===p?m=t[65]:(m=(0,u.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[64]=p,t[65]=m),m}function w(e){return typeof e==`string`||typeof e==`number`}function T(e){let t=(0,l.c)(28),{schema:n,values:i,onChange:a,disabled:o,className:s,labels:c}=e,f=o===void 0?!1:o,p;bb0:{if(n.type!==`object`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],p=e;break bb0}let e;t[1]===n?e=t[2]:(e=h(n),t[1]=n,t[2]=e),p=e}let m=p,_;bb1:{if(m.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]===m?e=t[5]:(e=g(m),t[4]=m,t[5]=e),_=e}let v=_,y;t[6]!==a||t[7]!==i?(y=(e,t)=>{a({...i,[e]:t})},t[6]=a,t[7]=i,t[8]=y):y=t[8];let b=y;if(n.type!==`object`||!d(n.properties)||m.length===0)return null;let x,S;if(t[9]!==s||t[10]!==f||t[11]!==v||t[12]!==c||t[13]!==b||t[14]!==i){let e=Array.from(v.keys()).sort(E);t[17]===s?x=t[18]:(x=r(`flex flex-col gap-4`,s),t[17]=s,t[18]=x);let n;t[19]!==f||t[20]!==v||t[21]!==c||t[22]!==b||t[23]!==i?(n=e=>{let t=(v.get(e)??[]).map(e=>(0,u.jsx)(C,{k:e.key,sub:e.sub,value:i[e.key],onValue:t=>b(e.key,t),disabled:f,labels:c},e.key));return e===``?(0,u.jsx)(`div`,{children:t},`default`):(0,u.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[(0,u.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,u.jsx)(`div`,{className:`space-y-4 border-t border-edge p-3`,children:t})]},e)},t[19]=f,t[20]=v,t[21]=c,t[22]=b,t[23]=i,t[24]=n):n=t[24],S=e.map(n),t[9]=s,t[10]=f,t[11]=v,t[12]=c,t[13]=b,t[14]=i,t[15]=x,t[16]=S}else x=t[15],S=t[16];let w;return t[25]!==x||t[26]!==S?(w=(0,u.jsx)(`div`,{className:x,children:S}),t[25]=x,t[26]=S,t[27]=w):w=t[27],w}function E(e,t){return e===``?-1:t===``?1:e.localeCompare(t)}export{T as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./download-Dk-ZjtO6.js";import{t as o}from"./folder-open-CyzJ19I9.js";import{t as s}from"./plus-Q2yW6OE7.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./messages-D__oW2yE.js";import{t as u}from"./cn-0WouolD0.js";import{a as d,c as f,n as p,r as m}from"./locale-store-D_migb9R.js";import{a as h,n as g,o as _,r as ee,s as v,t as te}from"./dist-BGTk37IG.js";import{a as y,c as b,f as x,n as S,o as C,p as w,r as T,s as E,t as D}from"./session-api-aQLptIs9.js";import{i as O}from"./vendor-swr-BIWyz7Rc.js";import{n as k,r as A}from"./gateway-config-swr-CTXr917C.js";import{n as j,t as M}from"./registry-api-4NZOh0iz.js";import{Ds as N,Eo as P,Fs as ne,G as F,Go as I,Jf as L,Jo as R,Lu as z,Os as B,Ps as re,Qc as V,Ru as ie,Sd as ae,So as oe,To as se,Yf as ce,Yl as le,Zc as H,_o as ue,_u as de,bs as fe,cl as U,ec as W,ed as pe,el as G,go as me,ho as K,if as he,lf as ge,ma as _e,mn as ve,nd as ye,pn as be,vf as xe,wd as Se,xd as Ce,xu as we}from"./index-BUv4J0JN.js";import{t as q}from"./number-input-DDeqHK-G.js";import{n as Te,r as Ee}from"./settings-page-layout-Dx5S-Msc.js";import{n as De,t as J}from"./settings-form-section-BA2RkU1S.js";import{n as Oe,t as Y}from"./use-autosave-DqPaXiX2.js";import{t as ke}from"./settings-advanced-gate-BE-SKsf6.js";var X=e(t(),1),Ae=n(),Z=r();function je(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 Me(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`).format(e)}function Ne(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function Pe(e){let t=(0,Ae.c)(124),{session:n,variant:r,labels:i,sessionAgentId:o,sessionAgentAvatar:s,onOpen:c,onAction:d}=e,f;t[0]!==i.unnamedSession||t[1]!==n.name?(f=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=f):f=t[2];let m=f,h=p(Re),g;t[3]!==h||t[4]!==n?(g=P(n,l(h).sidebar.sessionFilters),t[3]=h,t[4]=n,t[5]=g):g=t[5];let _=g,ee;t[6]===n.name?ee=t[7]:(ee=n.name?.trim(),t[6]=n.name,t[7]=ee);let v=!!ee,te=n.status===`archived`,y=n.status===`pinned`,b=n.usage,x;t[8]!==i.costUnknown||t[9]!==i.noUsage||t[10]!==b?(x=b?.calls?b.costCompleteness===`unknown`?i.costUnknown:`${b.costCompleteness===`partial`?`≥ `:`≈ `}${Ne(b.knownCostUsd)}`:i.noUsage,t[8]=i.costUnknown,t[9]=i.noUsage,t[10]=b,t[11]=x):x=t[11];let S=x,C=b?.calls?b.costCompleteness===`partial`?i.costPartial:b.costCompleteness===`unknown`?i.costUnknown:i.cost:i.noUsage,w=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,T;t[12]===w?T=t[13]:(T=u(`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`,w),t[12]=w,t[13]=T);let E;t[14]===c?E=t[15]:(E=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[14]=c,t[15]=E);let D=r===`list`&&`sm:py-3`,O;t[16]===D?O=t[17]:(O=u(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,D),t[16]=D,t[17]=O);let k;t[18]===n?k=t[19]:(k=(0,Z.jsx)(se,{sourceChannel:n.sourceChannel,session:n,className:`size-3.5`}),t[18]=n,t[19]=k);let A;t[20]===_?A=t[21]:(A=(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:_}),t[20]=_,t[21]=A);let j;t[22]!==k||t[23]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[k,A]}),t[22]=k,t[23]=A,t[24]=j):j=t[24];let M;t[25]===y?M=t[26]:(M=y?(0,Z.jsx)(ie,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[25]=y,t[26]=M);let N;t[27]===n.updatedAt?N=t[28]:(N=je(n.updatedAt),t[27]=n.updatedAt,t[28]=N);let ne;t[29]===N?ne=t[30]:(ne=(0,Z.jsx)(`span`,{children:N}),t[29]=N,t[30]=ne);let F;t[31]!==M||t[32]!==ne?(F=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[M,ne]}),t[31]=M,t[32]=ne,t[33]=F):F=t[33];let I;t[34]!==j||t[35]!==F||t[36]!==O?(I=(0,Z.jsxs)(`div`,{className:O,children:[j,F]}),t[34]=j,t[35]=F,t[36]=O,t[37]=I):I=t[37];let B=r===`list`&&`sm:py-3`,re;t[38]===B?re=t[39]:(re=u(`min-w-0 flex-1 px-3 py-2`,B),t[38]=B,t[39]=re);let V=r===`list`&&`sm:items-start`,ae;t[40]===V?ae=t[41]:(ae=u(`flex gap-3`,V),t[40]=V,t[41]=ae);let oe;t[42]!==s||t[43]!==o?(oe=(0,Z.jsx)(R,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[42]=s,t[43]=o,t[44]=oe):oe=t[44];let ue;t[45]===m?ue=t[46]:(ue=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:m,children:m}),t[45]=m,t[46]=ue);let de;t[47]!==n.key||t[48]!==v?(de=v?(0,Z.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[47]=n.key,t[48]=v,t[49]=de):de=t[49];let fe;t[50]!==ue||t[51]!==de?(fe=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[ue,de]}),t[50]=ue,t[51]=de,t[52]=fe):fe=t[52];let U;t[53]!==ae||t[54]!==oe||t[55]!==fe?(U=(0,Z.jsxs)(`div`,{className:ae,children:[oe,fe]}),t[53]=ae,t[54]=oe,t[55]=fe,t[56]=U):U=t[56];let W;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Z.jsx)(ye,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[57]=W):W=t[57];let pe;t[58]===n.messageCount?pe=t[59]:(pe=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[W,n.messageCount]}),t[58]=n.messageCount,t[59]=pe);let G;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsx)(he,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[60]=G):G=t[60];let me=b?.totalTokens??0,K;t[61]!==h||t[62]!==me?(K=Me(me,h),t[61]=h,t[62]=me,t[63]=K):K=t[63];let _e;t[64]!==i.tokens||t[65]!==K?(_e=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[G,K,` `,i.tokens]}),t[64]=i.tokens,t[65]=K,t[66]=_e):_e=t[66];let ve;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,Z.jsx)(ge,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[67]=ve):ve=t[67];let be;t[68]!==S||t[69]!==C?(be=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:C,children:[ve,S]}),t[68]=S,t[69]=C,t[70]=be):be=t[70];let xe;t[71]!==pe||t[72]!==_e||t[73]!==be?(xe=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[pe,_e,be]}),t[71]=pe,t[72]=_e,t[73]=be,t[74]=xe):xe=t[74];let Se;t[75]===n.tags?Se=t[76]:(Se=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Le),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[75]=n.tags,t[76]=Se);let Ce;t[77]!==re||t[78]!==U||t[79]!==xe||t[80]!==Se?(Ce=(0,Z.jsxs)(`div`,{className:re,children:[U,xe,Se]}),t[77]=re,t[78]=U,t[79]=xe,t[80]=Se,t[81]=Ce):Ce=t[81];let we;t[82]===d?we=t[83]:(we=()=>d(`continue`),t[82]=d,t[83]=we);let q;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Z.jsx)(ye,{className:`size-4`,strokeWidth:1.75}),t[84]=q):q=t[84];let Te;t[85]!==i.continueChat||t[86]!==we?(Te=(0,Z.jsx)(`button`,{type:`button`,className:H,title:i.continueChat,"aria-label":i.continueChat,onClick:we,children:q}),t[85]=i.continueChat,t[86]=we,t[87]=Te):Te=t[87];let Ee;t[88]!==te||t[89]!==i.archive||t[90]!==i.unarchive||t[91]!==d?(Ee=te?(0,Z.jsx)(`button`,{type:`button`,className:H,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>d(`unarchive`),children:(0,Z.jsx)(ce,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:H,title:i.archive,"aria-label":i.archive,onClick:()=>d(`archive`),children:(0,Z.jsx)(L,{className:`size-4`,strokeWidth:1.75})}),t[88]=te,t[89]=i.archive,t[90]=i.unarchive,t[91]=d,t[92]=Ee):Ee=t[92];let De;t[93]!==y||t[94]!==i.pin||t[95]!==i.unpin||t[96]!==d?(De=y?(0,Z.jsx)(`button`,{type:`button`,className:H,title:i.unpin,"aria-label":i.unpin,onClick:()=>d(`unpin`),children:(0,Z.jsx)(z,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:H,title:i.pin,"aria-label":i.pin,onClick:()=>d(`pin`),children:(0,Z.jsx)(ie,{className:`size-4`,strokeWidth:1.75})}),t[93]=y,t[94]=i.pin,t[95]=i.unpin,t[96]=d,t[97]=De):De=t[97];let J;t[98]===d?J=t[99]:(J=()=>d(`export`),t[98]=d,t[99]=J);let Oe;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,Z.jsx)(a,{className:`size-4`,strokeWidth:1.75}),t[100]=Oe):Oe=t[100];let Y;t[101]!==i.export||t[102]!==J?(Y=(0,Z.jsx)(`button`,{type:`button`,className:H,title:i.export,"aria-label":i.export,onClick:J,children:Oe}),t[101]=i.export,t[102]=J,t[103]=Y):Y=t[103];let ke;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(ke=u(H,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[104]=ke):ke=t[104];let X;t[105]===d?X=t[106]:(X=()=>d(`delete`),t[105]=d,t[106]=X);let Pe;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=(0,Z.jsx)(le,{className:`size-4`,strokeWidth:1.75}),t[107]=Pe):Pe=t[107];let ze;t[108]!==i.delete||t[109]!==X?(ze=(0,Z.jsx)(`button`,{type:`button`,className:ke,title:i.delete,"aria-label":i.delete,onClick:X,children:Pe}),t[108]=i.delete,t[109]=X,t[110]=ze):ze=t[110];let Be;t[111]!==Te||t[112]!==Ee||t[113]!==De||t[114]!==Y||t[115]!==ze?(Be=(0,Z.jsxs)(`div`,{role:`group`,className:`m-1 mt-0 flex flex-wrap items-center gap-0.5 rounded-lg bg-surface-hover/35 p-1.5`,onClick:Ie,onKeyDown:Fe,children:[Te,Ee,De,Y,ze]}),t[111]=Te,t[112]=Ee,t[113]=De,t[114]=Y,t[115]=ze,t[116]=Be):Be=t[116];let Ve;return t[117]!==c||t[118]!==I||t[119]!==Ce||t[120]!==Be||t[121]!==T||t[122]!==E?(Ve=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:T,onClick:c,onKeyDown:E,children:[I,Ce,Be]}),t[117]=c,t[118]=I,t[119]=Ce,t[120]=Be,t[121]=T,t[122]=E,t[123]=Ve):Ve=t[123],Ve}function Fe(e){return e.stopPropagation()}function Ie(e){return e.stopPropagation()}function Le(e){return(0,Z.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 Re(e){return e.language}function ze(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function Be(e,t){return t.find(t=>t.id===e)?.avatar}var Ve={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:16e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function He(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ue(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Q(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function We(e){let t=He(e)?e:{},n=He(t.userContext)?t.userContext:{},r=He(n.contextPlanning)?n.contextPlanning:{},i=He(r.compaction)?r.compaction:{},a=Ve,o=typeof i.model==`string`&&i.model.trim()?i.model.trim():void 0,s=Array.isArray(i.postCompactionSections)&&i.postCompactionSections.length<=12&&i.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(i.postCompactionSections.map(e=>e.trim()))]:[...a.postCompactionSections];return{enabled:typeof i.enabled==`boolean`?i.enabled:a.enabled,triggerThreshold:Ue(i.triggerThreshold,a.triggerThreshold,.1,.98),reserveTokens:Q(i.reserveTokens,a.reserveTokens,1024),minMessagesBeforeCompact:Q(i.minMessagesBeforeCompact,a.minMessagesBeforeCompact,2),keepRecentTokens:Q(i.keepRecentTokens,a.keepRecentTokens,1e3),recentTurnsPreserve:Q(i.recentTurnsPreserve,a.recentTurnsPreserve,1,12),summaryMaxTokens:Q(i.summaryMaxTokens,a.summaryMaxTokens,256),summaryChunkTokens:Q(i.summaryChunkTokens,a.summaryChunkTokens,1e3),summaryTimeoutMs:Q(i.summaryTimeoutMs,a.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(i.summaryRetries,a.summaryRetries,0,5),qualityGuard:typeof i.qualityGuard==`boolean`?i.qualityGuard:a.qualityGuard,gapAudit:typeof i.gapAudit==`boolean`?i.gapAudit:a.gapAudit,...o?{model:o}:{},minToolResultKeepChars:Q(i.minToolResultKeepChars,a.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(i.maxActiveTranscriptBytes,a.maxActiveTranscriptBytes,64e3),postCompactionSections:s}}function Ge(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function Ke(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{contextPlanning:{compaction:t}}}}async function qe(e){await d(m(`/api/config`),{method:`PATCH`,body:JSON.stringify(Ke(e))}),await k()}var Je=128e3,Ye={balanced:Ve,preserve:{...Ve,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Ve,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Xe=K();function Ze(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,W,`dark:border-edge`)}function Qe(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function $e(e){let t=Qe(e);for(let[e,n]of Object.entries(Ye))if(t===Qe(n))return e;return`custom`}function et(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,Ae.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=Ze(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,Z.jsx)(q,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function tt(e){let t=(0,Ae.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=u(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let d;t[4]!==i||t[5]!==a||t[6]!==l?(d=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=d):d=t[7];let f;t[8]===n?f=t[9]:(f=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=f);let p;t[10]===r?p=t[11]:(p=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,Z.jsxs)(`span`,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;return t[15]!==c||t[16]!==d||t[17]!==m?(h=(0,Z.jsxs)(`label`,{className:c,children:[d,m]}),t[15]=c,t[16]=d,t[17]=m,t[18]=h):h=t[18],h}function nt({hasToken:e}){let t=l(p(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=A(e),{data:i=[],isLoading:a}=O(e?M:null,j,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:We(n.payload.config),[n]),[d,f]=(0,X.useReducer)(Xe,{form:null,baseline:null}),[m,h]=(0,X.useState)(``),g=(0,X.useRef)(!1),_=(0,X.useRef)(d.form);_.current=d.form;let ee=(0,X.useRef)(null);me({enabled:e,parsed:o,dirty:g.current,trackedParsedRef:ee,dispatch:f,onResetDirty:()=>{g.current=!1}});let v=d.form,te=d.baseline,y=!!(v&&te&&JSON.stringify(v)!==JSON.stringify(te)),b=(0,X.useCallback)(e=>{g.current=!0,f({type:`patch`,patch:e})},[]),x=(0,X.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),S=Y({value:v,dirty:y,onSave:(0,X.useCallback)(async e=>{try{await qe(e),f({type:`saved`,value:e}),g.current=!!(_.current&&JSON.stringify(_.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ge(e);return n?t.invalidValue.replace(`{{field}}`,x(n)):null}});if(!e||!v)return r?(0,Z.jsx)(J,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(G,{className:`h-5 w-48`}),(0,Z.jsx)(G,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(G,{className:`h-36 w-full rounded-xl`})]})}):null;let C=$e(v),w=Math.max(0,Je-v.reserveTokens),T=Math.min(Math.floor(Je*v.triggerThreshold),w),E=Math.min(100,T/Je*100),D=Math.min(100,w/Je*100),k=v.model?i.find(e=>e.id===v.model):void 0,N=k?.contextWindow&&v.summaryChunkTokens+v.summaryMaxTokens+4096>k.contextWindow,P=v.keepRecentTokens+v.reserveTokens>T,ne=Math.round(v.summaryTimeoutMs*(v.summaryRetries+1)/1e3),I=e=>{let t=Ye[e];b({...t,...v.model?{model:v.model}:{model:void 0},postCompactionSections:v.postCompactionSections})},L={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},R=()=>{let e=m.trim();!e||v.postCompactionSections.includes(e)||v.postCompactionSections.length>=12||(b({postCompactionSections:[...v.postCompactionSections,e]}),h(``))};return(0,Z.jsxs)(J,{onBlurCapture:S.onBlurCapture,children:[(0,Z.jsx)(De,{icon:pe,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(Oe,{status:S.status,error:S.error}),(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:v.enabled,onChange:e=>b({enabled:e.target.checked})}),v.enabled?t.enabled:t.disabled]})]})}),S.error?(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:S.error}):null,v.enabled?null:(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Z.jsxs)(`fieldset`,{disabled:!v.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),C===`custom`?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":C===e,className:u(`rounded-xl bg-surface-base/55 px-3 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,V.transition,V.focusRingPanel,C===e?`bg-accent-soft text-accent-fg shadow-surface`:`text-fg hover:bg-surface-hover`),onClick:()=>I(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:L[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:L[e].hint})]},e))})]}),(0,Z.jsxs)(F,{title:t.advancedTitle,summary:C===`custom`?t.presetCustom:t.presetHint,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.compactionTrigger}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:et(T)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${E}%`}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.hardInputLimit}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:et(w)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${D}%`}})})]})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((v.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>b({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,et(v.reserveTokens)),value:v.reserveTokens,min:1024,step:1024,onChange:e=>b({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:v.recentTurnsPreserve,min:1,max:12,onChange:e=>b({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,et(v.keepRecentTokens)),value:v.keepRecentTokens,min:1e3,step:1e3,onChange:e=>b({keepRecentTokens:Math.floor(e)})})]}),P?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Z.jsx)(_e,{value:v.model??``,disabled:!v.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>b({model:e})}),v.model?(0,Z.jsx)(U,{type:`button`,variant:`secondary`,onClick:()=>b({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Z.jsx)(tt,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:v.qualityGuard,onChange:e=>b({qualityGuard:e})}),(0,Z.jsx)(tt,{label:t.gapAudit,hint:t.gapAuditHint,checked:v.gapAudit,onChange:e=>b({gapAudit:e})})]}),v.qualityGuard?null:(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning})]}),(0,Z.jsx)(ke,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:v.minMessagesBeforeCompact,min:2,onChange:e=>b({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((v.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>b({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:v.summaryMaxTokens,min:256,step:256,onChange:e=>b({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:v.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>b({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(ne)),value:v.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>b({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:v.summaryRetries,min:0,max:5,onChange:e=>b({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:v.minToolResultKeepChars,min:200,step:100,onChange:e=>b({minToolResultKeepChars:Math.floor(e)})})]}),N?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),v.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:v.postCompactionSections.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Z.jsx)(`button`,{type:`button`,className:u(`text-fg-muted hover:text-fg`,V.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>b({postCompactionSections:v.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(c,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`input`,{className:Ze(),value:m,maxLength:120,disabled:v.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),R())}}),(0,Z.jsxs)(U,{type:`button`,variant:`secondary`,disabled:!m.trim()||v.postCompactionSections.length>=12,onClick:R,children:[(0,Z.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function rt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function it(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function at(e){let t=rt(e)?e:{},n=rt(t.session)?t.session:{},r=rt(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:it(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function ot(e){await d(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),k()}function st(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,W,`dark:border-edge`)}var ct=K();function lt({hasToken:e}){let t=l(p(e=>e.language)).sessions.config,{data:n,isLoading:r}=A(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:at(n.payload.config),[n]),[a,o]=(0,X.useReducer)(ct,{form:null,baseline:null}),s=a.form,c=a.baseline,u=(0,X.useRef)(!1),d=(0,X.useRef)(s);d.current=s;let f=(0,X.useRef)(null);me({enabled:e,parsed:i,dirty:u.current,trackedParsedRef:f,dispatch:o,onResetDirty:()=>{u.current=!1}});let m=!!(s&&c&&JSON.stringify(s)!==JSON.stringify(c)),h=(0,X.useCallback)(e=>{u.current=!0,o({type:`patch`,patch:e})},[]),g=Y({value:s,dirty:m,onSave:(0,X.useCallback)(async e=>{try{await ot(e),o({type:`saved`,value:e}),u.current=!!(d.current&&JSON.stringify(d.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!s?r?(0,Z.jsx)(J,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(G,{className:`h-5 w-40`}),(0,Z.jsx)(G,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(J,{onBlurCapture:g.onBlurCapture,children:[(0,Z.jsx)(De,{icon:he,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(Oe,{status:g.status,error:g.error})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(F,{title:t.dmScope,summary:s.dmScope,children:(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Z.jsxs)(N,{className:st(),value:s.dmScope,onChange:e=>h({dmScope:e.target.value}),children:[(0,Z.jsx)(B,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(B,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(B,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(B,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Z.jsx)(q,{allowEmpty:!0,type:`number`,min:0,className:st(),value:s.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Z.jsx)(F,{title:t.maxEntries,summary:s.maxEntries??t.unsetPlaceholder,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Z.jsx)(q,{allowEmpty:!0,type:`number`,min:1,className:st(),value:s.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})})]})]})}function ut(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 dt(e){let t=(0,Ae.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:l,onArchive:d,onUnarchive:f,onPin:p,onUnpin:m,onExport:y,onDelete:b}=e,x=i?.status===`archived`,S=i?.status===`pinned`,C;t[0]===l?C=t[1]:(C=e=>!e&&l(),t[0]=l,t[1]=C);let w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(h,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ne)}),t[2]=w):w=t[2];let T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=u(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,re,`dark:border-edge`),t[3]=T):T=t[3];let E;t[4]!==i||t[5]!==o||t[6]!==a?(E=i&&a?(0,Z.jsx)(R,{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]=E):E=t[7];let D;t[8]!==s.unnamedSession||t[9]!==i?.name?(D=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=D):D=t[10];let O;t[11]===D?O=t[12]:(O=(0,Z.jsx)(v,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:D}),t[11]=D,t[12]=O);let k;t[13]!==E||t[14]!==O?(k=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[E,O]}),t[13]=E,t[14]=O,t[15]=k):k=t[15];let A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(c,{className:`size-5`,strokeWidth:1.75}),t[16]=A):A=t[16];let j;t[17]===s.close?j=t[18]:(j=(0,Z.jsx)(g,{asChild:!0,children:(0,Z.jsx)(U,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:A})}),t[17]=s.close,t[18]=j);let M;t[19]!==k||t[20]!==j?(M=(0,Z.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:[k,j]}),t[19]=k,t[20]=j,t[21]=M):M=t[21];let N;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(N=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Z.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Z.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(ft)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=N):N=t[26];let P;t[27]===N?P=t[28]:(P=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:N}),t[27]=N,t[28]=P);let F;t[29]!==s.detailExport||t[30]!==y?(F=(0,Z.jsx)(U,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:y,children:s.detailExport}),t[29]=s.detailExport,t[30]=y,t[31]=F):F=t[31];let I;t[32]!==x||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==d||t[36]!==f?(I=x?(0,Z.jsx)(U,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:s.unarchive}):(0,Z.jsx)(U,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:s.archive}),t[32]=x,t[33]=s.archive,t[34]=s.unarchive,t[35]=d,t[36]=f,t[37]=I):I=t[37];let L;t[38]!==S||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==p||t[42]!==m?(L=S?(0,Z.jsx)(U,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:s.unpin}):(0,Z.jsx)(U,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:s.pin}),t[38]=S,t[39]=s.pin,t[40]=s.unpin,t[41]=p,t[42]=m,t[43]=L):L=t[43];let z;t[44]!==s.delete||t[45]!==b?(z=(0,Z.jsx)(U,{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:b,children:s.delete}),t[44]=s.delete,t[45]=b,t[46]=z):z=t[46];let B;t[47]!==F||t[48]!==I||t[49]!==L||t[50]!==z?(B=(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[F,I,L,z]})}),t[47]=F,t[48]=I,t[49]=L,t[50]=z,t[51]=B):B=t[51];let V;t[52]!==M||t[53]!==P||t[54]!==B?(V=(0,Z.jsxs)(_,{children:[w,(0,Z.jsxs)(ee,{className:T,"aria-describedby":void 0,children:[M,P,B]})]}),t[52]=M,t[53]=P,t[54]=B,t[55]=V):V=t[55];let ie;return t[56]!==n||t[57]!==C||t[58]!==V?(ie=(0,Z.jsx)(te,{open:n,onOpenChange:C,children:V}),t[56]=n,t[57]=C,t[58]=V,t[59]=ie):ie=t[59],ie}function ft(e){return(0,Z.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:ut(e.content)})]},`${e.timestamp??``}-${e.role}-${ut(e.content).slice(0,24)}`)}var pt=20;function mt(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ht=new Set([`all`,`active`,`pinned`,`archived`]),gt=new Set([`grid`,`list`]),_t=[`sessions`,`settings`];function vt(e){return e&&_t.includes(e)?e:`sessions`}function yt(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function bt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function xt(e){let t=(0,Ae.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=_t.map(e=>({id:e,label:yt(n,e),icon:e===`sessions`?Se:de})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(fe,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function St(e){let t=(0,Ae.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-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:yt(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:bt(n,r)})]}),(0,Z.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,Z.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 Ct(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ht.has(t)?t:`all`,viewMode:gt.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 wt(){let e=l(p(e=>e.language)),t=e.sessions,n=f(e=>e.conversationId),r=!!n,{data:a,mutate:s}=O(r?[`gateway-chat-agents`,n]:null,oe,{revalidateOnFocus:!1}),c=a?.defaultId??`main`,d=a?.items??[],[m,g]=i(),k=vt(m.get(`tab`)),A=(0,X.useCallback)(e=>{let t=new URLSearchParams(m);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),g(t,{replace:!0})},[m,g]),[j,M]=(0,X.useReducer)(ue,m,Ct),{searchInput:N,debouncedSearch:P,statusFilter:F,viewMode:R,channelFilter:z,sessions:B,loading:se,error:ce,hasMore:le,stats:H,detailOpen:de,detailLoading:fe,detailSession:W,confirmOpen:pe,confirmKey:G}=j;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=N.trim();P!==e&&M({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[N,P]);let me=m.toString(),K=(0,X.useRef)(me);if(K.current!==me){K.current=me;let e=m.get(`q`)??``,t=m.get(`status`),n=m.get(`view`),r=(m.get(`channel`)??``).trim(),i=ht.has(t)?t:`all`,a=gt.has(n)?n:`grid`,o=e.trim();M({type:`patch`,patch:{...N===e?{}:{searchInput:e},...P===o?{}:{debouncedSearch:o},...F===i?{}:{statusFilter:i},...R===a?{}:{viewMode:a},...z===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(m),t=P.trim();t?e.set(`q`,t):e.delete(`q`),F===`all`?e.delete(`status`):e.set(`status`,F),R===`grid`?e.delete(`view`):e.set(`view`,R),z?e.set(`channel`,z):e.delete(`channel`),e.toString()!==m.toString()&&g(e,{replace:!0})},[P,m,g,F,R,z]),(0,X.useEffect)(()=>{if(!r||k!==`sessions`)return;let e=!1;return(async()=>{M({type:`patch`,patch:{loading:!0,error:null}});try{let t=await E({limit:pt,offset:0,...P?{search:P}:{},...F===`all`?{}:{status:F},...z?{channel:z}:{}});if(e)return;M({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||M({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||M({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,k,P,F,z,t.loadError]),(0,X.useEffect)(()=>{!r||k!==`sessions`||C().then(e=>M({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,k]),(0,X.useEffect)(()=>{if(!r||k!==`sessions`)return;let e=()=>void s();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,k,s]),(0,X.useEffect)(()=>{if(!r||k!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||M({type:`patch`,patch:{sessions:B.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:W&&W.key===t.key?{...W,name:t.name}:W}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,k,B,W]);let he=(0,X.useCallback)(async()=>{if(!(!r||se||!le)){M({type:`patch`,patch:{loading:!0,error:null}});try{let e=await E({limit:pt,offset:B.length,...P?{search:P}:{},...F===`all`?{}:{status:F},...z?{channel:z}:{}});M({type:`patch`,patch:{sessions:[...B,...e.items],hasMore:e.hasMore}})}catch(e){M({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{M({type:`patch`,patch:{loading:!1}})}}},[r,se,le,B.length,P,F,z,t.loadError]),ge=(0,X.useCallback)((e,t)=>{M({type:`patch`,patch:{sessions:B.map(n=>n.key===e?{...n,status:t}:n),detailSession:W&&W.key===e?{...W,status:t}:W}})},[B,W]),_e=(0,X.useCallback)(async e=>{M({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{M({type:`patch`,patch:{detailSession:await y(e)}})}catch{M({type:`patch`,patch:{detailOpen:!1}})}finally{M({type:`patch`,patch:{detailLoading:!1}})}},[]),ye=e=>{_e(e)},q=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e},bubbles:!0}));return}if(t===`delete`){M({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await D(e),ge(e,`archived`);break;case`unarchive`:await x(e),ge(e,`active`);break;case`pin`:await b(e),ge(e,`pinned`);break;case`unpin`:await w(e),ge(e,`active`);break;case`export`:{let t=await T(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}C().then(e=>M({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},De=async e=>{try{await S(e),M({type:`patch`,patch:{sessions:B.filter(t=>t.key!==e),detailSession:W?.key===e?null:W,...W?.key===e?{detailOpen:!1}:{}}}),C().then(e=>M({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},J={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,tokens:t.tokens,cost:t.cost,costPartial:t.costPartial,costUnknown:t.costUnknown,noUsage:t.noUsage,unnamedSession:e.chat.newSession},Oe={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},Y=[{key:`all`,label:t.filterAll,icon:Se},{key:`active`,label:t.filterActive,icon:xe},{key:`pinned`,label:t.filterPinned,icon:ie},{key:`archived`,label:t.filterArchived,icon:L}],ke=(()=>{let e=Object.entries(H?.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,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Z.jsxs)(Ee,{gap:`gap-6`,children:[(0,Z.jsx)(Te,{title:t.title}),(0,Z.jsx)(xt,{s:t,activeTab:k,onChange:A}),(0,Z.jsx)(St,{s:t,id:`settings`,activeTab:k,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(nt,{hasToken:r}),(0,Z.jsx)(lt,{hasToken:r})]})}),(0,Z.jsxs)(St,{s:t,id:`sessions`,activeTab:k,plain:!0,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsx)(I,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.tabsSessions,indicatorClassName:`rounded-xl bg-accent-soft`,children:Y.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":F===e,onClick:()=>M({type:`patch`,patch:{statusFilter:e}}),className:u(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,V.transition,V.focusRingPanel,F===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,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Z.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base focus-within:ring-2 focus-within:ring-accent px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Z.jsx)(we,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:N,onChange:e=>M({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder,"data-debounced-query":P||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-base sm:text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Z.jsxs)(I,{className:`flex flex-wrap items-center gap-2`,role:`group`,"aria-label":t.filterChannelLabel,indicatorClassName:`rounded-xl bg-accent-soft`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":!z,onClick:()=>M({type:`patch`,patch:{channelFilter:``}}),className:u(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,V.transition,V.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}),ke.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":z===e,onClick:()=>M({type:`patch`,patch:{channelFilter:e}}),className:u(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,V.transition,V.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,H?.byChannel?.[e]==null?null:(0,Z.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:H.byChannel[e]})]},e))]}),H?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[H.totalSessions,t.totalSessions],[H.activeSessions,t.activeSessions],[H.pinnedSessions,t.pinnedSessions],[H.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,ce?(0,Z.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:ce}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:mt(t.sessionCount,{count:B.length})}),(0,Z.jsxs)(I,{className:ve,role:`group`,"aria-label":t.layoutToggleGroup,indicatorClassName:`rounded-pill bg-surface-panel shadow-sm dark:ring-1 dark:ring-edge-strong/40`,children:[(0,Z.jsx)(U,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":R===`grid`,onClick:()=>M({type:`patch`,patch:{viewMode:`grid`}}),className:u(be,`size-7 p-0`,R===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,R===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(ae,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(U,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":R===`list`,onClick:()=>M({type:`patch`,patch:{viewMode:`list`}}),className:u(be,`size-9 p-0`,R===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,R===`list`&&`text-accent-fg`),children:(0,Z.jsx)(Ce,{className:`size-3.5`,strokeWidth:1.5})})]})]}),se&&B.length===0?(0,Z.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,Z.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):B.length===0?(0,Z.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,Z.jsx)(o,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Z.jsx)(U,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:u(`grid min-w-0 gap-3`,R===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":P||void 0,children:B.map(e=>{let t=ze(e,c);return(0,Z.jsx)(Pe,{session:e,variant:R,labels:J,sessionAgentId:t,sessionAgentAvatar:Be(t,d),onOpen:()=>ye(e.key),onAction:t=>void q(e.key,t)},e.key)})}),le?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(U,{type:`button`,variant:`secondary`,disabled:se,onClick:()=>void he(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(dt,{open:de,loading:fe,session:W,sessionAgentId:W?ze(W,c):void 0,sessionAgentAvatar:W?Be(ze(W,c),d):void 0,labels:Oe,onClose:()=>{M({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>W&&void q(W.key,`archive`),onUnarchive:()=>W&&void q(W.key,`unarchive`),onPin:()=>W&&void q(W.key,`pin`),onUnpin:()=>W&&void q(W.key,`unpin`),onExport:()=>W&&void q(W.key,`export`),onDelete:()=>W&&M({type:`patch`,patch:{confirmKey:W.key,confirmOpen:!0}})}),(0,Z.jsx)(te,{open:pe,onOpenChange:e=>M({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(_,{children:[(0,Z.jsx)(h,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ne)}),(0,Z.jsxs)(ee,{className:u(`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-overlay p-4 shadow-popover dark:border-edge`,re),children:[(0,Z.jsx)(v,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:G?mt(t.deleteSessionMessage,{name:B.find(e=>e.key===G)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(U,{type:`button`,variant:`secondary`,onClick:()=>M({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(U,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{G&&De(G),M({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Z.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{wt 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{g as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./download-Dk-ZjtO6.js";import{t as o}from"./folder-open-CyzJ19I9.js";import{t as s}from"./plus-Q2yW6OE7.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./messages-D__oW2yE.js";import{t as u}from"./cn-0WouolD0.js";import{a as d,c as f,n as p,r as m}from"./locale-store-D_migb9R.js";import{a as h,n as g,o as _,r as ee,s as v,t as te}from"./dist-BGTk37IG.js";import{a as y,c as b,f as x,n as S,o as C,p as w,r as T,s as E,t as D}from"./session-api-aQLptIs9.js";import{i as O}from"./vendor-swr-BIWyz7Rc.js";import{n as k,r as A}from"./gateway-config-swr-CTXr917C.js";import{n as j,t as M}from"./registry-api-4NZOh0iz.js";import{Ds as N,Eo as P,Fs as ne,G as F,Go as I,Jf as L,Jo as R,Lu as z,Os as B,Ps as re,Qc as V,Ru as ie,Sd as ae,So as oe,To as se,Yf as ce,Yl as le,Zc as H,_o as ue,_u as de,bs as fe,cl as U,ec as W,ed as pe,el as G,go as me,ho as K,if as he,lf as ge,ma as _e,mn as ve,nd as ye,pn as be,vf as xe,wd as Se,xd as Ce,xu as we}from"./index-Cgd4fGVP.js";import{t as q}from"./number-input-DDeqHK-G.js";import{n as Te,r as Ee}from"./settings-page-layout-Dx5S-Msc.js";import{n as De,t as J}from"./settings-form-section-Cl0eF4hl.js";import{n as Oe,t as Y}from"./use-autosave-DwcmmxWR.js";import{t as ke}from"./settings-advanced-gate-CjRLXfoo.js";var X=e(t(),1),Ae=n(),Z=r();function je(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 Me(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`).format(e)}function Ne(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function Pe(e){let t=(0,Ae.c)(124),{session:n,variant:r,labels:i,sessionAgentId:o,sessionAgentAvatar:s,onOpen:c,onAction:d}=e,f;t[0]!==i.unnamedSession||t[1]!==n.name?(f=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=f):f=t[2];let m=f,h=p(Re),g;t[3]!==h||t[4]!==n?(g=P(n,l(h).sidebar.sessionFilters),t[3]=h,t[4]=n,t[5]=g):g=t[5];let _=g,ee;t[6]===n.name?ee=t[7]:(ee=n.name?.trim(),t[6]=n.name,t[7]=ee);let v=!!ee,te=n.status===`archived`,y=n.status===`pinned`,b=n.usage,x;t[8]!==i.costUnknown||t[9]!==i.noUsage||t[10]!==b?(x=b?.calls?b.costCompleteness===`unknown`?i.costUnknown:`${b.costCompleteness===`partial`?`≥ `:`≈ `}${Ne(b.knownCostUsd)}`:i.noUsage,t[8]=i.costUnknown,t[9]=i.noUsage,t[10]=b,t[11]=x):x=t[11];let S=x,C=b?.calls?b.costCompleteness===`partial`?i.costPartial:b.costCompleteness===`unknown`?i.costUnknown:i.cost:i.noUsage,w=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,T;t[12]===w?T=t[13]:(T=u(`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`,w),t[12]=w,t[13]=T);let E;t[14]===c?E=t[15]:(E=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[14]=c,t[15]=E);let D=r===`list`&&`sm:py-3`,O;t[16]===D?O=t[17]:(O=u(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,D),t[16]=D,t[17]=O);let k;t[18]===n?k=t[19]:(k=(0,Z.jsx)(se,{sourceChannel:n.sourceChannel,session:n,className:`size-3.5`}),t[18]=n,t[19]=k);let A;t[20]===_?A=t[21]:(A=(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:_}),t[20]=_,t[21]=A);let j;t[22]!==k||t[23]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[k,A]}),t[22]=k,t[23]=A,t[24]=j):j=t[24];let M;t[25]===y?M=t[26]:(M=y?(0,Z.jsx)(ie,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[25]=y,t[26]=M);let N;t[27]===n.updatedAt?N=t[28]:(N=je(n.updatedAt),t[27]=n.updatedAt,t[28]=N);let ne;t[29]===N?ne=t[30]:(ne=(0,Z.jsx)(`span`,{children:N}),t[29]=N,t[30]=ne);let F;t[31]!==M||t[32]!==ne?(F=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[M,ne]}),t[31]=M,t[32]=ne,t[33]=F):F=t[33];let I;t[34]!==j||t[35]!==F||t[36]!==O?(I=(0,Z.jsxs)(`div`,{className:O,children:[j,F]}),t[34]=j,t[35]=F,t[36]=O,t[37]=I):I=t[37];let B=r===`list`&&`sm:py-3`,re;t[38]===B?re=t[39]:(re=u(`min-w-0 flex-1 px-3 py-2`,B),t[38]=B,t[39]=re);let V=r===`list`&&`sm:items-start`,ae;t[40]===V?ae=t[41]:(ae=u(`flex gap-3`,V),t[40]=V,t[41]=ae);let oe;t[42]!==s||t[43]!==o?(oe=(0,Z.jsx)(R,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[42]=s,t[43]=o,t[44]=oe):oe=t[44];let ue;t[45]===m?ue=t[46]:(ue=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:m,children:m}),t[45]=m,t[46]=ue);let de;t[47]!==n.key||t[48]!==v?(de=v?(0,Z.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[47]=n.key,t[48]=v,t[49]=de):de=t[49];let fe;t[50]!==ue||t[51]!==de?(fe=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[ue,de]}),t[50]=ue,t[51]=de,t[52]=fe):fe=t[52];let U;t[53]!==ae||t[54]!==oe||t[55]!==fe?(U=(0,Z.jsxs)(`div`,{className:ae,children:[oe,fe]}),t[53]=ae,t[54]=oe,t[55]=fe,t[56]=U):U=t[56];let W;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Z.jsx)(ye,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[57]=W):W=t[57];let pe;t[58]===n.messageCount?pe=t[59]:(pe=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[W,n.messageCount]}),t[58]=n.messageCount,t[59]=pe);let G;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsx)(he,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[60]=G):G=t[60];let me=b?.totalTokens??0,K;t[61]!==h||t[62]!==me?(K=Me(me,h),t[61]=h,t[62]=me,t[63]=K):K=t[63];let _e;t[64]!==i.tokens||t[65]!==K?(_e=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[G,K,` `,i.tokens]}),t[64]=i.tokens,t[65]=K,t[66]=_e):_e=t[66];let ve;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,Z.jsx)(ge,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[67]=ve):ve=t[67];let be;t[68]!==S||t[69]!==C?(be=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:C,children:[ve,S]}),t[68]=S,t[69]=C,t[70]=be):be=t[70];let xe;t[71]!==pe||t[72]!==_e||t[73]!==be?(xe=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[pe,_e,be]}),t[71]=pe,t[72]=_e,t[73]=be,t[74]=xe):xe=t[74];let Se;t[75]===n.tags?Se=t[76]:(Se=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Le),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[75]=n.tags,t[76]=Se);let Ce;t[77]!==re||t[78]!==U||t[79]!==xe||t[80]!==Se?(Ce=(0,Z.jsxs)(`div`,{className:re,children:[U,xe,Se]}),t[77]=re,t[78]=U,t[79]=xe,t[80]=Se,t[81]=Ce):Ce=t[81];let we;t[82]===d?we=t[83]:(we=()=>d(`continue`),t[82]=d,t[83]=we);let q;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Z.jsx)(ye,{className:`size-4`,strokeWidth:1.75}),t[84]=q):q=t[84];let Te;t[85]!==i.continueChat||t[86]!==we?(Te=(0,Z.jsx)(`button`,{type:`button`,className:H,title:i.continueChat,"aria-label":i.continueChat,onClick:we,children:q}),t[85]=i.continueChat,t[86]=we,t[87]=Te):Te=t[87];let Ee;t[88]!==te||t[89]!==i.archive||t[90]!==i.unarchive||t[91]!==d?(Ee=te?(0,Z.jsx)(`button`,{type:`button`,className:H,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>d(`unarchive`),children:(0,Z.jsx)(ce,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:H,title:i.archive,"aria-label":i.archive,onClick:()=>d(`archive`),children:(0,Z.jsx)(L,{className:`size-4`,strokeWidth:1.75})}),t[88]=te,t[89]=i.archive,t[90]=i.unarchive,t[91]=d,t[92]=Ee):Ee=t[92];let De;t[93]!==y||t[94]!==i.pin||t[95]!==i.unpin||t[96]!==d?(De=y?(0,Z.jsx)(`button`,{type:`button`,className:H,title:i.unpin,"aria-label":i.unpin,onClick:()=>d(`unpin`),children:(0,Z.jsx)(z,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:H,title:i.pin,"aria-label":i.pin,onClick:()=>d(`pin`),children:(0,Z.jsx)(ie,{className:`size-4`,strokeWidth:1.75})}),t[93]=y,t[94]=i.pin,t[95]=i.unpin,t[96]=d,t[97]=De):De=t[97];let J;t[98]===d?J=t[99]:(J=()=>d(`export`),t[98]=d,t[99]=J);let Oe;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,Z.jsx)(a,{className:`size-4`,strokeWidth:1.75}),t[100]=Oe):Oe=t[100];let Y;t[101]!==i.export||t[102]!==J?(Y=(0,Z.jsx)(`button`,{type:`button`,className:H,title:i.export,"aria-label":i.export,onClick:J,children:Oe}),t[101]=i.export,t[102]=J,t[103]=Y):Y=t[103];let ke;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(ke=u(H,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[104]=ke):ke=t[104];let X;t[105]===d?X=t[106]:(X=()=>d(`delete`),t[105]=d,t[106]=X);let Pe;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=(0,Z.jsx)(le,{className:`size-4`,strokeWidth:1.75}),t[107]=Pe):Pe=t[107];let ze;t[108]!==i.delete||t[109]!==X?(ze=(0,Z.jsx)(`button`,{type:`button`,className:ke,title:i.delete,"aria-label":i.delete,onClick:X,children:Pe}),t[108]=i.delete,t[109]=X,t[110]=ze):ze=t[110];let Be;t[111]!==Te||t[112]!==Ee||t[113]!==De||t[114]!==Y||t[115]!==ze?(Be=(0,Z.jsxs)(`div`,{role:`group`,className:`m-1 mt-0 flex flex-wrap items-center gap-0.5 rounded-lg bg-surface-hover/35 p-1.5`,onClick:Ie,onKeyDown:Fe,children:[Te,Ee,De,Y,ze]}),t[111]=Te,t[112]=Ee,t[113]=De,t[114]=Y,t[115]=ze,t[116]=Be):Be=t[116];let Ve;return t[117]!==c||t[118]!==I||t[119]!==Ce||t[120]!==Be||t[121]!==T||t[122]!==E?(Ve=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:T,onClick:c,onKeyDown:E,children:[I,Ce,Be]}),t[117]=c,t[118]=I,t[119]=Ce,t[120]=Be,t[121]=T,t[122]=E,t[123]=Ve):Ve=t[123],Ve}function Fe(e){return e.stopPropagation()}function Ie(e){return e.stopPropagation()}function Le(e){return(0,Z.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 Re(e){return e.language}function ze(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function Be(e,t){return t.find(t=>t.id===e)?.avatar}var Ve={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:16e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function He(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ue(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Q(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function We(e){let t=He(e)?e:{},n=He(t.userContext)?t.userContext:{},r=He(n.contextPlanning)?n.contextPlanning:{},i=He(r.compaction)?r.compaction:{},a=Ve,o=typeof i.model==`string`&&i.model.trim()?i.model.trim():void 0,s=Array.isArray(i.postCompactionSections)&&i.postCompactionSections.length<=12&&i.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(i.postCompactionSections.map(e=>e.trim()))]:[...a.postCompactionSections];return{enabled:typeof i.enabled==`boolean`?i.enabled:a.enabled,triggerThreshold:Ue(i.triggerThreshold,a.triggerThreshold,.1,.98),reserveTokens:Q(i.reserveTokens,a.reserveTokens,1024),minMessagesBeforeCompact:Q(i.minMessagesBeforeCompact,a.minMessagesBeforeCompact,2),keepRecentTokens:Q(i.keepRecentTokens,a.keepRecentTokens,1e3),recentTurnsPreserve:Q(i.recentTurnsPreserve,a.recentTurnsPreserve,1,12),summaryMaxTokens:Q(i.summaryMaxTokens,a.summaryMaxTokens,256),summaryChunkTokens:Q(i.summaryChunkTokens,a.summaryChunkTokens,1e3),summaryTimeoutMs:Q(i.summaryTimeoutMs,a.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(i.summaryRetries,a.summaryRetries,0,5),qualityGuard:typeof i.qualityGuard==`boolean`?i.qualityGuard:a.qualityGuard,gapAudit:typeof i.gapAudit==`boolean`?i.gapAudit:a.gapAudit,...o?{model:o}:{},minToolResultKeepChars:Q(i.minToolResultKeepChars,a.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(i.maxActiveTranscriptBytes,a.maxActiveTranscriptBytes,64e3),postCompactionSections:s}}function Ge(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function Ke(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{contextPlanning:{compaction:t}}}}async function qe(e){await d(m(`/api/config`),{method:`PATCH`,body:JSON.stringify(Ke(e))}),await k()}var Je=128e3,Ye={balanced:Ve,preserve:{...Ve,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Ve,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Xe=K();function Ze(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,W,`dark:border-edge`)}function Qe(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function $e(e){let t=Qe(e);for(let[e,n]of Object.entries(Ye))if(t===Qe(n))return e;return`custom`}function et(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,Ae.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=Ze(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,Z.jsx)(q,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function tt(e){let t=(0,Ae.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=u(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let d;t[4]!==i||t[5]!==a||t[6]!==l?(d=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=d):d=t[7];let f;t[8]===n?f=t[9]:(f=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=f);let p;t[10]===r?p=t[11]:(p=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,Z.jsxs)(`span`,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;return t[15]!==c||t[16]!==d||t[17]!==m?(h=(0,Z.jsxs)(`label`,{className:c,children:[d,m]}),t[15]=c,t[16]=d,t[17]=m,t[18]=h):h=t[18],h}function nt({hasToken:e}){let t=l(p(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=A(e),{data:i=[],isLoading:a}=O(e?M:null,j,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:We(n.payload.config),[n]),[d,f]=(0,X.useReducer)(Xe,{form:null,baseline:null}),[m,h]=(0,X.useState)(``),g=(0,X.useRef)(!1),_=(0,X.useRef)(d.form);_.current=d.form;let ee=(0,X.useRef)(null);me({enabled:e,parsed:o,dirty:g.current,trackedParsedRef:ee,dispatch:f,onResetDirty:()=>{g.current=!1}});let v=d.form,te=d.baseline,y=!!(v&&te&&JSON.stringify(v)!==JSON.stringify(te)),b=(0,X.useCallback)(e=>{g.current=!0,f({type:`patch`,patch:e})},[]),x=(0,X.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),S=Y({value:v,dirty:y,onSave:(0,X.useCallback)(async e=>{try{await qe(e),f({type:`saved`,value:e}),g.current=!!(_.current&&JSON.stringify(_.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ge(e);return n?t.invalidValue.replace(`{{field}}`,x(n)):null}});if(!e||!v)return r?(0,Z.jsx)(J,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(G,{className:`h-5 w-48`}),(0,Z.jsx)(G,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(G,{className:`h-36 w-full rounded-xl`})]})}):null;let C=$e(v),w=Math.max(0,Je-v.reserveTokens),T=Math.min(Math.floor(Je*v.triggerThreshold),w),E=Math.min(100,T/Je*100),D=Math.min(100,w/Je*100),k=v.model?i.find(e=>e.id===v.model):void 0,N=k?.contextWindow&&v.summaryChunkTokens+v.summaryMaxTokens+4096>k.contextWindow,P=v.keepRecentTokens+v.reserveTokens>T,ne=Math.round(v.summaryTimeoutMs*(v.summaryRetries+1)/1e3),I=e=>{let t=Ye[e];b({...t,...v.model?{model:v.model}:{model:void 0},postCompactionSections:v.postCompactionSections})},L={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},R=()=>{let e=m.trim();!e||v.postCompactionSections.includes(e)||v.postCompactionSections.length>=12||(b({postCompactionSections:[...v.postCompactionSections,e]}),h(``))};return(0,Z.jsxs)(J,{onBlurCapture:S.onBlurCapture,children:[(0,Z.jsx)(De,{icon:pe,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(Oe,{status:S.status,error:S.error}),(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:v.enabled,onChange:e=>b({enabled:e.target.checked})}),v.enabled?t.enabled:t.disabled]})]})}),S.error?(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:S.error}):null,v.enabled?null:(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Z.jsxs)(`fieldset`,{disabled:!v.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),C===`custom`?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":C===e,className:u(`rounded-xl bg-surface-base/55 px-3 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,V.transition,V.focusRingPanel,C===e?`bg-accent-soft text-accent-fg shadow-surface`:`text-fg hover:bg-surface-hover`),onClick:()=>I(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:L[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:L[e].hint})]},e))})]}),(0,Z.jsxs)(F,{title:t.advancedTitle,summary:C===`custom`?t.presetCustom:t.presetHint,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.compactionTrigger}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:et(T)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${E}%`}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.hardInputLimit}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:et(w)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${D}%`}})})]})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((v.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>b({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,et(v.reserveTokens)),value:v.reserveTokens,min:1024,step:1024,onChange:e=>b({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:v.recentTurnsPreserve,min:1,max:12,onChange:e=>b({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,et(v.keepRecentTokens)),value:v.keepRecentTokens,min:1e3,step:1e3,onChange:e=>b({keepRecentTokens:Math.floor(e)})})]}),P?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Z.jsx)(_e,{value:v.model??``,disabled:!v.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>b({model:e})}),v.model?(0,Z.jsx)(U,{type:`button`,variant:`secondary`,onClick:()=>b({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Z.jsx)(tt,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:v.qualityGuard,onChange:e=>b({qualityGuard:e})}),(0,Z.jsx)(tt,{label:t.gapAudit,hint:t.gapAuditHint,checked:v.gapAudit,onChange:e=>b({gapAudit:e})})]}),v.qualityGuard?null:(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning})]}),(0,Z.jsx)(ke,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:v.minMessagesBeforeCompact,min:2,onChange:e=>b({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((v.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>b({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:v.summaryMaxTokens,min:256,step:256,onChange:e=>b({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:v.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>b({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(ne)),value:v.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>b({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:v.summaryRetries,min:0,max:5,onChange:e=>b({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:v.minToolResultKeepChars,min:200,step:100,onChange:e=>b({minToolResultKeepChars:Math.floor(e)})})]}),N?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),v.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:v.postCompactionSections.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Z.jsx)(`button`,{type:`button`,className:u(`text-fg-muted hover:text-fg`,V.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>b({postCompactionSections:v.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(c,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`input`,{className:Ze(),value:m,maxLength:120,disabled:v.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),R())}}),(0,Z.jsxs)(U,{type:`button`,variant:`secondary`,disabled:!m.trim()||v.postCompactionSections.length>=12,onClick:R,children:[(0,Z.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function rt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function it(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function at(e){let t=rt(e)?e:{},n=rt(t.session)?t.session:{},r=rt(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:it(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function ot(e){await d(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),k()}function st(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,W,`dark:border-edge`)}var ct=K();function lt({hasToken:e}){let t=l(p(e=>e.language)).sessions.config,{data:n,isLoading:r}=A(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:at(n.payload.config),[n]),[a,o]=(0,X.useReducer)(ct,{form:null,baseline:null}),s=a.form,c=a.baseline,u=(0,X.useRef)(!1),d=(0,X.useRef)(s);d.current=s;let f=(0,X.useRef)(null);me({enabled:e,parsed:i,dirty:u.current,trackedParsedRef:f,dispatch:o,onResetDirty:()=>{u.current=!1}});let m=!!(s&&c&&JSON.stringify(s)!==JSON.stringify(c)),h=(0,X.useCallback)(e=>{u.current=!0,o({type:`patch`,patch:e})},[]),g=Y({value:s,dirty:m,onSave:(0,X.useCallback)(async e=>{try{await ot(e),o({type:`saved`,value:e}),u.current=!!(d.current&&JSON.stringify(d.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!s?r?(0,Z.jsx)(J,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(G,{className:`h-5 w-40`}),(0,Z.jsx)(G,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(J,{onBlurCapture:g.onBlurCapture,children:[(0,Z.jsx)(De,{icon:he,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(Oe,{status:g.status,error:g.error})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(F,{title:t.dmScope,summary:s.dmScope,children:(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Z.jsxs)(N,{className:st(),value:s.dmScope,onChange:e=>h({dmScope:e.target.value}),children:[(0,Z.jsx)(B,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(B,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(B,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(B,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Z.jsx)(q,{allowEmpty:!0,type:`number`,min:0,className:st(),value:s.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Z.jsx)(F,{title:t.maxEntries,summary:s.maxEntries??t.unsetPlaceholder,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Z.jsx)(q,{allowEmpty:!0,type:`number`,min:1,className:st(),value:s.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})})]})]})}function ut(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 dt(e){let t=(0,Ae.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:l,onArchive:d,onUnarchive:f,onPin:p,onUnpin:m,onExport:y,onDelete:b}=e,x=i?.status===`archived`,S=i?.status===`pinned`,C;t[0]===l?C=t[1]:(C=e=>!e&&l(),t[0]=l,t[1]=C);let w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(h,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ne)}),t[2]=w):w=t[2];let T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=u(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,re,`dark:border-edge`),t[3]=T):T=t[3];let E;t[4]!==i||t[5]!==o||t[6]!==a?(E=i&&a?(0,Z.jsx)(R,{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]=E):E=t[7];let D;t[8]!==s.unnamedSession||t[9]!==i?.name?(D=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=D):D=t[10];let O;t[11]===D?O=t[12]:(O=(0,Z.jsx)(v,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:D}),t[11]=D,t[12]=O);let k;t[13]!==E||t[14]!==O?(k=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[E,O]}),t[13]=E,t[14]=O,t[15]=k):k=t[15];let A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(c,{className:`size-5`,strokeWidth:1.75}),t[16]=A):A=t[16];let j;t[17]===s.close?j=t[18]:(j=(0,Z.jsx)(g,{asChild:!0,children:(0,Z.jsx)(U,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:A})}),t[17]=s.close,t[18]=j);let M;t[19]!==k||t[20]!==j?(M=(0,Z.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:[k,j]}),t[19]=k,t[20]=j,t[21]=M):M=t[21];let N;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(N=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Z.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Z.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(ft)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=N):N=t[26];let P;t[27]===N?P=t[28]:(P=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:N}),t[27]=N,t[28]=P);let F;t[29]!==s.detailExport||t[30]!==y?(F=(0,Z.jsx)(U,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:y,children:s.detailExport}),t[29]=s.detailExport,t[30]=y,t[31]=F):F=t[31];let I;t[32]!==x||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==d||t[36]!==f?(I=x?(0,Z.jsx)(U,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:s.unarchive}):(0,Z.jsx)(U,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:s.archive}),t[32]=x,t[33]=s.archive,t[34]=s.unarchive,t[35]=d,t[36]=f,t[37]=I):I=t[37];let L;t[38]!==S||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==p||t[42]!==m?(L=S?(0,Z.jsx)(U,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:s.unpin}):(0,Z.jsx)(U,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:s.pin}),t[38]=S,t[39]=s.pin,t[40]=s.unpin,t[41]=p,t[42]=m,t[43]=L):L=t[43];let z;t[44]!==s.delete||t[45]!==b?(z=(0,Z.jsx)(U,{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:b,children:s.delete}),t[44]=s.delete,t[45]=b,t[46]=z):z=t[46];let B;t[47]!==F||t[48]!==I||t[49]!==L||t[50]!==z?(B=(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[F,I,L,z]})}),t[47]=F,t[48]=I,t[49]=L,t[50]=z,t[51]=B):B=t[51];let V;t[52]!==M||t[53]!==P||t[54]!==B?(V=(0,Z.jsxs)(_,{children:[w,(0,Z.jsxs)(ee,{className:T,"aria-describedby":void 0,children:[M,P,B]})]}),t[52]=M,t[53]=P,t[54]=B,t[55]=V):V=t[55];let ie;return t[56]!==n||t[57]!==C||t[58]!==V?(ie=(0,Z.jsx)(te,{open:n,onOpenChange:C,children:V}),t[56]=n,t[57]=C,t[58]=V,t[59]=ie):ie=t[59],ie}function ft(e){return(0,Z.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:ut(e.content)})]},`${e.timestamp??``}-${e.role}-${ut(e.content).slice(0,24)}`)}var pt=20;function mt(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ht=new Set([`all`,`active`,`pinned`,`archived`]),gt=new Set([`grid`,`list`]),_t=[`sessions`,`settings`];function vt(e){return e&&_t.includes(e)?e:`sessions`}function yt(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function bt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function xt(e){let t=(0,Ae.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=_t.map(e=>({id:e,label:yt(n,e),icon:e===`sessions`?Se:de})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(fe,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function St(e){let t=(0,Ae.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-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:yt(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:bt(n,r)})]}),(0,Z.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,Z.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 Ct(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ht.has(t)?t:`all`,viewMode:gt.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 wt(){let e=l(p(e=>e.language)),t=e.sessions,n=f(e=>e.conversationId),r=!!n,{data:a,mutate:s}=O(r?[`gateway-chat-agents`,n]:null,oe,{revalidateOnFocus:!1}),c=a?.defaultId??`main`,d=a?.items??[],[m,g]=i(),k=vt(m.get(`tab`)),A=(0,X.useCallback)(e=>{let t=new URLSearchParams(m);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),g(t,{replace:!0})},[m,g]),[j,M]=(0,X.useReducer)(ue,m,Ct),{searchInput:N,debouncedSearch:P,statusFilter:F,viewMode:R,channelFilter:z,sessions:B,loading:se,error:ce,hasMore:le,stats:H,detailOpen:de,detailLoading:fe,detailSession:W,confirmOpen:pe,confirmKey:G}=j;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=N.trim();P!==e&&M({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[N,P]);let me=m.toString(),K=(0,X.useRef)(me);if(K.current!==me){K.current=me;let e=m.get(`q`)??``,t=m.get(`status`),n=m.get(`view`),r=(m.get(`channel`)??``).trim(),i=ht.has(t)?t:`all`,a=gt.has(n)?n:`grid`,o=e.trim();M({type:`patch`,patch:{...N===e?{}:{searchInput:e},...P===o?{}:{debouncedSearch:o},...F===i?{}:{statusFilter:i},...R===a?{}:{viewMode:a},...z===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(m),t=P.trim();t?e.set(`q`,t):e.delete(`q`),F===`all`?e.delete(`status`):e.set(`status`,F),R===`grid`?e.delete(`view`):e.set(`view`,R),z?e.set(`channel`,z):e.delete(`channel`),e.toString()!==m.toString()&&g(e,{replace:!0})},[P,m,g,F,R,z]),(0,X.useEffect)(()=>{if(!r||k!==`sessions`)return;let e=!1;return(async()=>{M({type:`patch`,patch:{loading:!0,error:null}});try{let t=await E({limit:pt,offset:0,...P?{search:P}:{},...F===`all`?{}:{status:F},...z?{channel:z}:{}});if(e)return;M({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||M({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||M({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,k,P,F,z,t.loadError]),(0,X.useEffect)(()=>{!r||k!==`sessions`||C().then(e=>M({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,k]),(0,X.useEffect)(()=>{if(!r||k!==`sessions`)return;let e=()=>void s();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,k,s]),(0,X.useEffect)(()=>{if(!r||k!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||M({type:`patch`,patch:{sessions:B.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:W&&W.key===t.key?{...W,name:t.name}:W}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,k,B,W]);let he=(0,X.useCallback)(async()=>{if(!(!r||se||!le)){M({type:`patch`,patch:{loading:!0,error:null}});try{let e=await E({limit:pt,offset:B.length,...P?{search:P}:{},...F===`all`?{}:{status:F},...z?{channel:z}:{}});M({type:`patch`,patch:{sessions:[...B,...e.items],hasMore:e.hasMore}})}catch(e){M({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{M({type:`patch`,patch:{loading:!1}})}}},[r,se,le,B.length,P,F,z,t.loadError]),ge=(0,X.useCallback)((e,t)=>{M({type:`patch`,patch:{sessions:B.map(n=>n.key===e?{...n,status:t}:n),detailSession:W&&W.key===e?{...W,status:t}:W}})},[B,W]),_e=(0,X.useCallback)(async e=>{M({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{M({type:`patch`,patch:{detailSession:await y(e)}})}catch{M({type:`patch`,patch:{detailOpen:!1}})}finally{M({type:`patch`,patch:{detailLoading:!1}})}},[]),ye=e=>{_e(e)},q=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e},bubbles:!0}));return}if(t===`delete`){M({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await D(e),ge(e,`archived`);break;case`unarchive`:await x(e),ge(e,`active`);break;case`pin`:await b(e),ge(e,`pinned`);break;case`unpin`:await w(e),ge(e,`active`);break;case`export`:{let t=await T(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}C().then(e=>M({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},De=async e=>{try{await S(e),M({type:`patch`,patch:{sessions:B.filter(t=>t.key!==e),detailSession:W?.key===e?null:W,...W?.key===e?{detailOpen:!1}:{}}}),C().then(e=>M({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},J={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,tokens:t.tokens,cost:t.cost,costPartial:t.costPartial,costUnknown:t.costUnknown,noUsage:t.noUsage,unnamedSession:e.chat.newSession},Oe={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},Y=[{key:`all`,label:t.filterAll,icon:Se},{key:`active`,label:t.filterActive,icon:xe},{key:`pinned`,label:t.filterPinned,icon:ie},{key:`archived`,label:t.filterArchived,icon:L}],ke=(()=>{let e=Object.entries(H?.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,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Z.jsxs)(Ee,{gap:`gap-6`,children:[(0,Z.jsx)(Te,{title:t.title}),(0,Z.jsx)(xt,{s:t,activeTab:k,onChange:A}),(0,Z.jsx)(St,{s:t,id:`settings`,activeTab:k,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(nt,{hasToken:r}),(0,Z.jsx)(lt,{hasToken:r})]})}),(0,Z.jsxs)(St,{s:t,id:`sessions`,activeTab:k,plain:!0,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsx)(I,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.tabsSessions,indicatorClassName:`rounded-xl bg-accent-soft`,children:Y.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":F===e,onClick:()=>M({type:`patch`,patch:{statusFilter:e}}),className:u(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,V.transition,V.focusRingPanel,F===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,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Z.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base focus-within:ring-2 focus-within:ring-accent px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Z.jsx)(we,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:N,onChange:e=>M({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder,"data-debounced-query":P||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-base sm:text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Z.jsxs)(I,{className:`flex flex-wrap items-center gap-2`,role:`group`,"aria-label":t.filterChannelLabel,indicatorClassName:`rounded-xl bg-accent-soft`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":!z,onClick:()=>M({type:`patch`,patch:{channelFilter:``}}),className:u(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,V.transition,V.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}),ke.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":z===e,onClick:()=>M({type:`patch`,patch:{channelFilter:e}}),className:u(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,V.transition,V.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,H?.byChannel?.[e]==null?null:(0,Z.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:H.byChannel[e]})]},e))]}),H?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[H.totalSessions,t.totalSessions],[H.activeSessions,t.activeSessions],[H.pinnedSessions,t.pinnedSessions],[H.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,ce?(0,Z.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:ce}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:mt(t.sessionCount,{count:B.length})}),(0,Z.jsxs)(I,{className:ve,role:`group`,"aria-label":t.layoutToggleGroup,indicatorClassName:`rounded-pill bg-surface-panel shadow-sm dark:ring-1 dark:ring-edge-strong/40`,children:[(0,Z.jsx)(U,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":R===`grid`,onClick:()=>M({type:`patch`,patch:{viewMode:`grid`}}),className:u(be,`size-7 p-0`,R===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,R===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(ae,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(U,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":R===`list`,onClick:()=>M({type:`patch`,patch:{viewMode:`list`}}),className:u(be,`size-9 p-0`,R===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,R===`list`&&`text-accent-fg`),children:(0,Z.jsx)(Ce,{className:`size-3.5`,strokeWidth:1.5})})]})]}),se&&B.length===0?(0,Z.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,Z.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):B.length===0?(0,Z.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,Z.jsx)(o,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Z.jsx)(U,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:u(`grid min-w-0 gap-3`,R===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":P||void 0,children:B.map(e=>{let t=ze(e,c);return(0,Z.jsx)(Pe,{session:e,variant:R,labels:J,sessionAgentId:t,sessionAgentAvatar:Be(t,d),onOpen:()=>ye(e.key),onAction:t=>void q(e.key,t)},e.key)})}),le?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(U,{type:`button`,variant:`secondary`,disabled:se,onClick:()=>void he(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(dt,{open:de,loading:fe,session:W,sessionAgentId:W?ze(W,c):void 0,sessionAgentAvatar:W?Be(ze(W,c),d):void 0,labels:Oe,onClose:()=>{M({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>W&&void q(W.key,`archive`),onUnarchive:()=>W&&void q(W.key,`unarchive`),onPin:()=>W&&void q(W.key,`pin`),onUnpin:()=>W&&void q(W.key,`unpin`),onExport:()=>W&&void q(W.key,`export`),onDelete:()=>W&&M({type:`patch`,patch:{confirmKey:W.key,confirmOpen:!0}})}),(0,Z.jsx)(te,{open:pe,onOpenChange:e=>M({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(_,{children:[(0,Z.jsx)(h,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ne)}),(0,Z.jsxs)(ee,{className:u(`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-overlay p-4 shadow-popover dark:border-edge`,re),children:[(0,Z.jsx)(v,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:G?mt(t.deleteSessionMessage,{name:B.find(e=>e.key===G)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(U,{type:`button`,variant:`secondary`,onClick:()=>M({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(U,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{G&&De(G),M({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Z.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{wt as SessionsPage};