@xopcai/xopc 0.0.199 → 0.0.201

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 (152) 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/{activity-store-DYVN1hRp.js → activity-store-DOhnAQOQ.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Bt70bZjv.js → agent-avatar-dicebear-D8Cw0Mve.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-ANavi648.js +68 -0
  6. package/dist/gateway/static/root/assets/{api-B8mzbAle.js → api-E9Bk-Idp.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-B4x7JfL8.js → app-management-settings-panel-BubrReXg.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-Dwdagf-Q.js → appearance-settings-BY5Az2p4.js} +1 -1
  9. package/dist/gateway/static/root/assets/{apps-page-DkTiesxe.js → apps-page-CFh9MBxc.js} +1 -1
  10. package/dist/gateway/static/root/assets/{archive-plugin-Cv0VXKLm.js → archive-plugin-BY8843mB.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-CgidKrXn.js → attachment-load-DG45KScf.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-page-751CeNI3.js +6 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-DN3CQgIq.js → binary-plugins-DGIF2ZAv.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-BwkSl1F_.js → block-editor-C1Qktr1g.js} +5 -5
  15. package/dist/gateway/static/root/assets/browser-settings-page-CGAWs-TT.js +8 -0
  16. package/dist/gateway/static/root/assets/{browser-workflow-inputs-_ndaecsf.js → browser-workflow-inputs-D_jnndyz.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflows-page-C_I31wLm.js → browser-workflows-page-DyIRvPaq.js} +2 -2
  18. package/dist/gateway/static/root/assets/capabilities-settings-panel-CghUK68J.js +7 -0
  19. package/dist/gateway/static/root/assets/{capability-presets-api-Dy1jZJKs.js → capability-presets-api--tz0mGLY.js} +1 -1
  20. package/dist/gateway/static/root/assets/capability-presets-settings-panel-XsTfkvUn.js +3 -0
  21. package/dist/gateway/static/root/assets/{channel-recipient-api-D-9qiuio.js → channel-recipient-api-CkOKF9nc.js} +1 -1
  22. package/dist/gateway/static/root/assets/{channels-settings-DV5BhAeu.js → channels-settings-DkoAZZMe.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-status-swr-DNDvMWpl.js +1 -0
  24. package/dist/gateway/static/root/assets/{connectors-api-5FEBYguL.js → connectors-api-FBOe9SWC.js} +1 -1
  25. package/dist/gateway/static/root/assets/connectors-page-e4vekkAu.js +2 -0
  26. package/dist/gateway/static/root/assets/{cron-expression-SEFx5rnr.js → cron-expression-Q4QaYjpI.js} +1 -1
  27. package/dist/gateway/static/root/assets/{date-picker-D4zCUQJL.js → date-picker-Dtn7e6TW.js} +1 -1
  28. package/dist/gateway/static/root/assets/{dependency-picker-DpQAxS2k.js → dependency-picker-Br6nPaM6.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-B_5G3lQl.js → desktop-pet-DzTM6aH8.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-settings-ClEyoUJe.js → desktop-pet-settings-FDmaty3P.js} +1 -1
  31. package/dist/gateway/static/root/assets/{directory-picker-path-field-AsFWmOjG.js → directory-picker-path-field-X2e8xn8j.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-debug-page-C22Y2o5l.js → extension-debug-page-Dx4MBfga.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-page-C61Ikawk.js → extension-page-Bf_FEDhM.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-settings-page-WlWWcDFr.js → extension-settings-page-CrOgZxkf.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-config-api-ByIOMQdc.js → gateway-config-api-CZ4r-7qT.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-config-swr-jB0hAhWO.js → gateway-config-swr-Cv2ywpdb.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-settings-CzzS9A17.js → gateway-settings-DpWmVi0w.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-startup-retry-C-fRlHCL.js → gateway-startup-retry-undf-k5g.js} +1 -1
  39. package/dist/gateway/static/root/assets/heartbeat-settings-DSQZhSvT.js +1 -0
  40. package/dist/gateway/static/root/assets/home-page-L0uHiu0T.js +3 -0
  41. package/dist/gateway/static/root/assets/{index-CR233S0Q.css → index-Bp8I_eX4.css} +1 -1
  42. package/dist/gateway/static/root/assets/index-DRrjYYzZ.js +152 -0
  43. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BD_TFz0_.js → keyboard-shortcuts-settings-Bc3Quw42.js} +1 -1
  44. package/dist/gateway/static/root/assets/local-app-workbench-page-Copi3sdP.js +2 -0
  45. package/dist/gateway/static/root/assets/{local-apps-page-BwbUeLfm.js → local-apps-page-CP9X_vtz.js} +1 -1
  46. package/dist/gateway/static/root/assets/{locale-store-xULEcFVs.js → locale-store-CnamlR07.js} +1 -1
  47. package/dist/gateway/static/root/assets/logs-page-DMKq6e29.js +2 -0
  48. package/dist/gateway/static/root/assets/{management-settings-CW2VpqtT.js → management-settings-CJmcaVje.js} +1 -1
  49. package/dist/gateway/static/root/assets/{markdown-split-B1M9KO16.js → markdown-split-AcuFp0TH.js} +1 -1
  50. package/dist/gateway/static/root/assets/{media-plugins-B_QlNdqZ.js → media-plugins-BvFgsiJL.js} +1 -1
  51. package/dist/gateway/static/root/assets/messages-D7kOD_o_.js +3 -0
  52. package/dist/gateway/static/root/assets/{notes-page-BTbD4GmH.js → notes-page-IW7IQ9nJ.js} +1 -1
  53. package/dist/gateway/static/root/assets/notes-workbench-Zb8U0anO.js +4 -0
  54. package/dist/gateway/static/root/assets/{preview-open-alternatives-CeqtArlZ.js → preview-open-alternatives-C-b34dgQ.js} +1 -1
  55. package/dist/gateway/static/root/assets/{product-open-page-DnalBZZs.js → product-open-page-CWEzLykF.js} +1 -1
  56. package/dist/gateway/static/root/assets/project-detail-page-BuIbLnan.js +1 -0
  57. package/dist/gateway/static/root/assets/projects-page-BwUfRqNV.js +1 -0
  58. package/dist/gateway/static/root/assets/remote-access-hub-BTaXxcEi.js +1 -0
  59. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-cGkBEfg4.js → runtime-tools-settings-panel-DAohEZrX.js} +2 -2
  60. package/dist/gateway/static/root/assets/{schema-form-CmsrLlxu.js → schema-form-C_OBW8A5.js} +1 -1
  61. package/dist/gateway/static/root/assets/sessions-page-BnHoTCD3.js +1 -0
  62. package/dist/gateway/static/root/assets/settings-advanced-gate-BTB_fxjt.js +1 -0
  63. package/dist/gateway/static/root/assets/{settings-form-section-DUWCbaMJ.js → settings-form-section-C7w2WS-A.js} +1 -1
  64. package/dist/gateway/static/root/assets/{settings-loading-skeleton-Bvy5rdMY.js → settings-loading-skeleton-zwibve4m.js} +1 -1
  65. package/dist/gateway/static/root/assets/{settings-page-cZSAwsRR.js → settings-page-B9W03dSW.js} +1 -1
  66. package/dist/gateway/static/root/assets/setup-status-panel-C8Hec2Af.js +1 -0
  67. package/dist/gateway/static/root/assets/{share-preview-page-BzA2NCAH.js → share-preview-page-6e3ks2be.js} +1 -1
  68. package/dist/gateway/static/root/assets/shares-settings-Bwc5HfLI.js +1 -0
  69. package/dist/gateway/static/root/assets/skill-reload-api-D7kunhqy.js +1 -0
  70. package/dist/gateway/static/root/assets/{skills-page-Bvde7_i5.js → skills-page-WgkaNzpc.js} +1 -1
  71. package/dist/gateway/static/root/assets/{skills-page.utils-vXSqHR7g.js → skills-page.utils-D9QT5cxj.js} +1 -1
  72. package/dist/gateway/static/root/assets/{system-settings-panel-9cQGOGCK.js → system-settings-panel-c1HVtv1Y.js} +1 -1
  73. package/dist/gateway/static/root/assets/task-detail-page-CjP-6WVU.js +1 -0
  74. package/dist/gateway/static/root/assets/{theme-store-CHQRiuCF.js → theme-store-BDyUTObE.js} +1 -1
  75. package/dist/gateway/static/root/assets/{use-autosave-7XfKULPI.js → use-autosave-D6UkH_Ga.js} +1 -1
  76. package/dist/gateway/static/root/assets/{user-context-page-CZ9m9aC_.js → user-context-page-D8ZhPDNF.js} +1 -1
  77. package/dist/gateway/static/root/assets/{voice-api-key-field-DXr21v-3.js → voice-api-key-field-BOxkKbGh.js} +1 -1
  78. package/dist/gateway/static/root/assets/{work-discovery-overlay-CeG7g_DZ.js → work-discovery-overlay-Dd19yK9t.js} +1 -1
  79. package/dist/gateway/static/root/assets/work-discovery-page-DUkdJl1e.js +1 -0
  80. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DSQQZP9T.js → workflow-run-setup-panel-ZA3bP65I.js} +2 -2
  81. package/dist/gateway/static/root/assets/workflows-page-C2b5W5bw.js +5 -0
  82. package/dist/gateway/static/root/assets/{working-directory-picker-modal-D-IgcHPp.js → working-directory-picker-modal-BcyiDXU3.js} +1 -1
  83. package/dist/gateway/static/root/index.html +9 -9
  84. package/dist/package.js +1 -1
  85. package/dist/packages/gateway-contract/src/tasks.js +51 -9
  86. package/dist/src/agent/context/execution-scope.js +3 -1
  87. package/dist/src/agent/tasks/task-judge-service.d.ts +1 -1
  88. package/dist/src/agent/tasks/task-judge-service.js +3 -2
  89. package/dist/src/agent/tools/xopc-use-tool.js +13 -3
  90. package/dist/src/auth/oauth/types.d.ts +2 -0
  91. package/dist/src/auth/oauth/xopc-cloud.js +24 -2
  92. package/dist/src/automations/domain/validation.d.ts +0 -12
  93. package/dist/src/automations/draft/automation-draft-validator.d.ts +0 -3
  94. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  95. package/dist/src/gateway/hono/app.js +1 -1
  96. package/dist/src/gateway/hono/oauth-async.js +2 -0
  97. package/dist/src/gateway/hono/routes/agent-stream.js +2 -74
  98. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +62 -0
  99. package/dist/src/gateway/hono/routes/session-input-handler.js +82 -0
  100. package/dist/src/gateway/hono/routes/tasks.js +161 -2
  101. package/dist/src/gateway/service/task-conversation-query-service.d.ts +58 -0
  102. package/dist/src/gateway/service/task-conversation-query-service.js +84 -0
  103. package/dist/src/gateway/service.d.ts +10 -0
  104. package/dist/src/gateway/service.js +75 -42
  105. package/dist/src/projects/project-agent.js +1 -1
  106. package/dist/src/storage/sqlite/migrations/120_task_conversation.sql +112 -0
  107. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  108. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  109. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  110. package/dist/src/storage/sqlite/schema.js +1 -1
  111. package/dist/src/tasks/execution-context.js +8 -4
  112. package/dist/src/tasks/index.d.ts +2 -0
  113. package/dist/src/tasks/index.js +3 -1
  114. package/dist/src/tasks/task-application-service.js +10 -17
  115. package/dist/src/tasks/task-context-assembler.js +9 -4
  116. package/dist/src/tasks/task-context-repository.d.ts +0 -6
  117. package/dist/src/tasks/task-context-repository.js +0 -4
  118. package/dist/src/tasks/task-conversation-repository.d.ts +71 -0
  119. package/dist/src/tasks/task-conversation-repository.js +194 -0
  120. package/dist/src/tasks/task-handoff-service.d.ts +31 -0
  121. package/dist/src/tasks/task-handoff-service.js +143 -0
  122. package/dist/src/tasks/task-read-model-projector.js +1 -5
  123. package/dist/src/tasks/task-repository.d.ts +0 -2
  124. package/dist/src/tasks/task-repository.js +2 -9
  125. package/dist/src/tasks/task-run-coordinator.js +3 -1
  126. package/dist/src/workflows/service/workflow-run-service.js +4 -2
  127. package/package.json +2 -2
  128. package/dist/gateway/static/root/assets/agents-D19uNmJf.js +0 -68
  129. package/dist/gateway/static/root/assets/automations-page-BR6qMOVr.js +0 -6
  130. package/dist/gateway/static/root/assets/browser-settings-page-CDFQWAxI.js +0 -8
  131. package/dist/gateway/static/root/assets/capabilities-settings-panel-D41mssOq.js +0 -7
  132. package/dist/gateway/static/root/assets/capability-presets-settings-panel-BXgCyuu2.js +0 -3
  133. package/dist/gateway/static/root/assets/channels-status-swr-B4Rbh3bM.js +0 -1
  134. package/dist/gateway/static/root/assets/connectors-page-C_qkEN0T.js +0 -2
  135. package/dist/gateway/static/root/assets/heartbeat-settings-B4A_CXUL.js +0 -1
  136. package/dist/gateway/static/root/assets/home-page-FVGYYPWo.js +0 -3
  137. package/dist/gateway/static/root/assets/index-CGbKTCST.js +0 -152
  138. package/dist/gateway/static/root/assets/local-app-workbench-page-BNpkigNb.js +0 -2
  139. package/dist/gateway/static/root/assets/logs-page-DXP9OQQt.js +0 -2
  140. package/dist/gateway/static/root/assets/messages-3qRsLZuX.js +0 -3
  141. package/dist/gateway/static/root/assets/notes-workbench-JRiq7QDW.js +0 -4
  142. package/dist/gateway/static/root/assets/project-detail-page-CjWA13aE.js +0 -1
  143. package/dist/gateway/static/root/assets/projects-page-jsCkScbG.js +0 -1
  144. package/dist/gateway/static/root/assets/remote-access-hub-CGPJTEkM.js +0 -1
  145. package/dist/gateway/static/root/assets/sessions-page-BBHzziMd.js +0 -1
  146. package/dist/gateway/static/root/assets/settings-advanced-gate-2cGg8-9h.js +0 -1
  147. package/dist/gateway/static/root/assets/setup-status-panel-Cf06b66-.js +0 -1
  148. package/dist/gateway/static/root/assets/shares-settings-xlNKydYY.js +0 -1
  149. package/dist/gateway/static/root/assets/skill-reload-api-C5Xu93c_.js +0 -1
  150. package/dist/gateway/static/root/assets/task-detail-page-Bkno4tTe.js +0 -1
  151. package/dist/gateway/static/root/assets/work-discovery-page-CQWZD03N.js +0 -1
  152. package/dist/gateway/static/root/assets/workflows-page-Cs-MXFJ1.js +0 -5
@@ -0,0 +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,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./check-DUBLcKHA.js";import{t as s}from"./copy-Dv6d4Dvw.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./globe-DSSGFWFn.js";import{t as u}from"./loader-circle-CifKLtgG.js";import{t as d}from"./cn-JdwAhgNB.js";import{t as f}from"./button-CSEbl4zT.js";import{s as p}from"./form-field-width-DJw_jULe.js";import{t as m}from"./copy-to-clipboard-HOJ79TWv.js";import{t as h}from"./messages-D7kOD_o_.js";import{a as g,i as _,l as v,n as y,o as b,r as x,s as S}from"./locale-store-CnamlR07.js";import{i as C,o as w}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{a as T,i as E,o as D,r as O,s as k,t as A}from"./dist-BPoKqzeH.js";import{a as j,i as M}from"./vendor-swr-BIWyz7Rc.js";import{n as N,r as P}from"./gateway-config-swr-Cv2ywpdb.js";import{r as F}from"./settings-form-draft-Dy10ldo8.js";import{$n as I,Al as L,Bo as R,Cr as z,Cs as B,Go as ee,Hs as V,Ls as te,Na as H,Oc as ne,Ol as U,Qn as W,Ts as G,Ua as K,_l as re,ar as q,bi as ie,cr as ae,cs as J,er as Y,fs as X,ir as oe,js as se,jt as ce,lr as le,nr as ue,or as de,rc as fe,rr as pe,sr as me,tr as he,ur as ge}from"./index-DRrjYYzZ.js";import{n as _e,r as ve,t as ye}from"./settings-page-layout-BRQNel6r.js";import{t as be}from"./settings-advanced-gate-BTB_fxjt.js";import{n as xe,r as Se,t as Ce}from"./settings-form-section-C7w2WS-A.js";import{t as we}from"./browser-BLJWD7WI.js";import{t as Te}from"./page-tabs-BaEQMYm_.js";var Z=n(),Q=e(t(),1),$=r();function Ee(e){let t=(0,Z.c)(26),{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,Q.useState)(c??!1),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=e=>p(e.currentTarget.open),t[0]=m):m=t[0];let h;t[1]===s?h=t[2]:(h=d(`group rounded-2xl bg-surface-base open:pb-1`,s),t[1]=s,t[2]=h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(L,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[3]=g):g=t[3];let _;t[4]===i?_=t[5]:(_=i?(0,$.jsx)(i,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}):null,t[4]=i,t[5]=_);let v;t[6]===n?v=t[7]:(v=(0,$.jsx)(`span`,{className:`group-open:hidden`,children:n}),t[6]=n,t[7]=v);let y;t[8]===r?y=t[9]:(y=(0,$.jsx)(`span`,{className:`hidden group-open:inline`,children:r}),t[8]=r,t[9]=y);let b;t[10]!==_||t[11]!==v||t[12]!==y?(b=(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-2xl px-4 py-3.5 text-sm font-medium text-fg transition-colors hover:text-fg group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:[g,_,v,y]}),t[10]=_,t[11]=v,t[12]=y,t[13]=b):b=t[13];let x;t[14]===a?x=t[15]:(x=a?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[14]=a,t[15]=x);let S;t[16]!==o||t[17]!==x?(S=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-4 pt-1`,children:[x,o]}),t[16]=o,t[17]=x,t[18]=S):S=t[18];let C;t[19]!==f||t[20]!==S||t[21]!==h||t[22]!==b?(C=(0,$.jsxs)(`details`,{open:f,onToggle:m,className:h,children:[b,S]}),t[19]=f,t[20]=S,t[21]=h,t[22]=b,t[23]=C):C=t[23];let w=C;if(u){let e;return t[24]===w?e=t[25]:(e=(0,$.jsx)(be,{children:w}),t[24]=w,t[25]=e),e}return w}function De(e,t){let{mutate:n}=j(),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),l=(0,Q.useCallback)(async()=>{await Promise.all([n(`tunnel-pair-context`),n(`tunnel-pair`),n(`tunnel-status`),N()])},[n]);return{busy:r,error:a,confirmOpen:s,setConfirmOpen:c,runEnableLanPairing:(0,Q.useCallback)(async()=>{if(!(!e||r)){i(!0),o(null);try{let n=await ue();if(!n.ok)throw Error(`Failed to enable LAN pairing`);if(n.requiresRestart){let t=await W();if(!t.ok)throw Error(t.message??`Gateway restart failed`);if(!await I(e))throw Error(`Gateway did not come back online in time`)}let r=n.requiresRestart?await Y():n.context;if(!r?.pairingReady)throw Error(`LAN pairing is still not ready after restart`);return await l(),t?.(r),c(!1),r}catch(e){return o(e instanceof Error?e.message:`Enable LAN pairing failed`),null}finally{i(!1)}}},[r,e,t,l]),clearError:()=>o(null)}}function Oe(){return d(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,p,`dark:border-edge`)}function ke(e){let t=(0,Z.c)(122),{pairQr:n,gatewayToken:r,streamlined:i,lanOnly:o,onRefreshQr:s}=e,c=i===void 0?!1:i,l=o===void 0?!1:o,p=y(Me),m;t[0]===p?m=t[1]:(m=h(p),t[0]=p,t[1]=m);let g=m,_=g.tunnelSettings,v=l?g.remoteAccess.lan:null,b;t[2]!==g.clipboard.copyFailed||t[3]!==_.pairCopied||t[4]!==_.pairCopyLink?(b={copy:_.pairCopyLink,copied:_.pairCopied,copyFailed:g.clipboard.copyFailed},t[2]=g.clipboard.copyFailed,t[3]=_.pairCopied,t[4]=_.pairCopyLink,t[5]=b):b=t[5];let x=b,{tunnelActive:S,tunnelStatus:C,tunnelQr:w,pairContext:T,pairBaseUrl:E,setPairBaseUrl:D,applySuggestedPairUrl:O,applyCandidateUrl:k,resetPairBaseFromContext:A,baseOk:j,localhostWarn:M,pairingBlocked:N,deepLink:P,qrPayload:F,qrDataUrl:I,qrGenFailed:L,encoding:R}=n,ee;t[6]===A?ee=t[7]:(ee=e=>{A(e.recommended.url)},t[6]=A,t[7]=ee);let V=De(r,ee),H,ne,U,W,G;if(t[8]!==k||t[9]!==O||t[10]!==j||t[11]!==V||t[12]!==r||t[13]!==v||t[14]!==l||t[15]!==M||t[16]!==s||t[17]!==E||t[18]!==T?.candidates||t[19]!==T?.recommended||t[20]!==N||t[21]!==D||t[22]!==c||t[23]!==_.pairBaseUrlHint||t[24]!==_.pairBaseUrlLabel||t[25]!==_.pairBaseUrlPlaceholder||t[26]!==_.pairBlockedLoopbackBody||t[27]!==_.pairBlockedNextSteps||t[28]!==_.pairBlockedTitle||t[29]!==_.pairCandidatesTitle||t[30]!==_.pairEnableLanButton||t[31]!==_.pairEnableLanEnabling||t[32]!==_.pairEnableLanSecurityAuditLink||t[33]!==_.pairInvalidBaseUrl||t[34]!==_.pairLocalhostWarning||t[35]!==_.pairSelectCandidateHint||t[36]!==_.pairSelectCandidateTitle||t[37]!==_.pairSubtitle||t[38]!==_.pairSuggestedLanLabel||t[39]!==_.pairTitle||t[40]!==_.pairTunnelActive||t[41]!==_.pairTunnelLanUrl||t[42]!==_.pairTunnelPublicUrl||t[43]!==_.pairUseSuggestedUrl||t[44]!==_.pairWaitingForTunnel||t[45]!==_.refreshQr||t[46]!==S||t[47]!==w||t[48]!==C?.publicUrl){G=Symbol.for(`react.early_return_sentinel`);bb0:{let e=T?.candidates.filter(je)??[],n=l?(e.find(Ae)?.url??e[0]?.url??``).trim():T?.recommended.url?.trim()??``,i=(l||!S)&&e.length>1,o=function(t){if(e.length===0)return null;let n=t===`amber`?`text-amber-950 dark:text-amber-100`:`text-fg`,r=t===`amber`?`text-amber-950/80 dark:text-amber-200/90`:`text-fg-muted`;return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:d(`text-xs font-medium`,r),children:i?_.pairSelectCandidateTitle:_.pairCandidatesTitle}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:d(`w-full rounded-md border px-2 py-1.5 text-left font-mono text-[11px] transition-colors`,t===`amber`?`border-amber-300/70 hover:bg-amber-100/80 dark:border-amber-800 dark:hover:bg-amber-950/50`:`border-edge hover:bg-surface-panel`,E.trim()===e.url&&`border-accent bg-accent/5`,n),onClick:()=>k(e.url),children:[e.label?`${e.label}: `:``,e.url]})},e.url))}),i?(0,$.jsx)(`p`,{className:d(`mt-1 text-[11px] leading-relaxed`,r),children:_.pairSelectCandidateHint}):null]})};if(H=c&&!l,H&&!S){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(B,{className:`size-4 text-accent`,strokeWidth:1.75}),t[54]=e):e=t[54];let n;t[55]===_.pairTitle?n=t[56]:(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[e,_.pairTitle]}),t[55]=_.pairTitle,t[56]=n);let r;t[57]===_.pairWaitingForTunnel?r=t[58]:(r=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:_.pairWaitingForTunnel}),t[57]=_.pairWaitingForTunnel,t[58]=r);let i;t[59]!==n||t[60]!==r?(i=(0,$.jsxs)(Ce,{children:[n,r]}),t[59]=n,t[60]=r,t[61]=i):i=t[61],G=i;break bb0}let p=v?.pairTitle??_.pairTitle,m=l?v?.pairSubtitle??_.pairSubtitle:S?_.pairTunnelActive:_.pairSubtitle,h=!!(s&&(l||c&&S)),g=H?`mb-2`:`mb-3`,y;t[62]===g?y=t[63]:(y=d(`flex flex-wrap items-start justify-between gap-2`,g),t[62]=g,t[63]=y);let b;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(B,{className:`size-4 text-accent`,strokeWidth:1.75}),t[64]=b):b=t[64];let x;t[65]===p?x=t[66]:(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[b,p]}),t[65]=p,t[66]=x);let A;t[67]!==H||t[68]!==m||t[69]!==_.pairSubtitle?(A=H?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:_.pairSubtitle}):(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:m}),t[67]=H,t[68]=m,t[69]=_.pairSubtitle,t[70]=A):A=t[70];let P;t[71]!==x||t[72]!==A?(P=(0,$.jsxs)(`div`,{children:[x,A]}),t[71]=x,t[72]=A,t[73]=P):P=t[73];let F;t[74]!==s||t[75]!==h||t[76]!==_.refreshQr?(F=h?(0,$.jsxs)(f,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void s(),children:[(0,$.jsx)(te,{className:`size-4`}),_.refreshQr]}):null,t[74]=s,t[75]=h,t[76]=_.refreshQr,t[77]=F):F=t[77],t[78]!==y||t[79]!==P||t[80]!==F?(ne=(0,$.jsxs)(`div`,{className:y,children:[P,F]}),t[78]=y,t[79]=P,t[80]=F,t[81]=ne):ne=t[81],U=N?(0,$.jsxs)(`div`,{className:`mb-3 space-y-3 rounded-lg border border-amber-200 bg-amber-50 p-3 dark:border-amber-900/50 dark:bg-amber-950/30`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-amber-950 dark:text-amber-100`,children:_.pairBlockedTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:_.pairBlockedLoopbackBody})]}),n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-amber-950/80 dark:text-amber-200/90`,children:_.pairSuggestedLanLabel}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-amber-950 dark:text-amber-100`,children:n})]}),(0,$.jsx)(f,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:O,children:_.pairUseSuggestedUrl})]}):null,e.length>0?o(`amber`):null,(0,$.jsx)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:(0,$.jsxs)(f,{type:`button`,className:`w-full sm:w-auto`,disabled:V.busy||!r,onClick:()=>V.setConfirmOpen(!0),children:[V.busy?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):null,V.busy?_.pairEnableLanEnabling:_.pairEnableLanButton]})}),V.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:V.error}):null,(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:l?v?.pairBlockedNextSteps??_.pairBlockedNextSteps:_.pairBlockedNextSteps}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(a,{to:`/settings/gateway`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:_.pairEnableLanSecurityAuditLink}),l&&v?.pairPublicTabLink?(0,$.jsx)(a,{to:`/settings/remote-access?tab=public`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:v.pairPublicTabLink}):null]})]}):null,W=S&&!l?H?null:(0,$.jsxs)(`div`,{className:`mb-3 space-y-2 rounded-lg bg-surface-panel/80 p-3 shadow-surface`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:_.pairTunnelPublicUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:C?.publicUrl})]}),w?.lanUrl?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:_.pairTunnelLanUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:w.lanUrl})]}):null]}):(0,$.jsxs)(`div`,{className:`mb-3 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`tunnel-mobile-pair-base`,children:_.pairBaseUrlLabel}),(0,$.jsx)(`input`,{id:`tunnel-mobile-pair-base`,className:d(Oe(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:n||_.pairBaseUrlPlaceholder,value:E,onChange:e=>D(e.target.value)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:_.pairBaseUrlHint}),!j&&E.trim()?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:_.pairInvalidBaseUrl}):null,M?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:_.pairLocalhostWarning}):null,i?o(`neutral`):null]})}t[8]=k,t[9]=O,t[10]=j,t[11]=V,t[12]=r,t[13]=v,t[14]=l,t[15]=M,t[16]=s,t[17]=E,t[18]=T?.candidates,t[19]=T?.recommended,t[20]=N,t[21]=D,t[22]=c,t[23]=_.pairBaseUrlHint,t[24]=_.pairBaseUrlLabel,t[25]=_.pairBaseUrlPlaceholder,t[26]=_.pairBlockedLoopbackBody,t[27]=_.pairBlockedNextSteps,t[28]=_.pairBlockedTitle,t[29]=_.pairCandidatesTitle,t[30]=_.pairEnableLanButton,t[31]=_.pairEnableLanEnabling,t[32]=_.pairEnableLanSecurityAuditLink,t[33]=_.pairInvalidBaseUrl,t[34]=_.pairLocalhostWarning,t[35]=_.pairSelectCandidateHint,t[36]=_.pairSelectCandidateTitle,t[37]=_.pairSubtitle,t[38]=_.pairSuggestedLanLabel,t[39]=_.pairTitle,t[40]=_.pairTunnelActive,t[41]=_.pairTunnelLanUrl,t[42]=_.pairTunnelPublicUrl,t[43]=_.pairUseSuggestedUrl,t[44]=_.pairWaitingForTunnel,t[45]=_.refreshQr,t[46]=S,t[47]=w,t[48]=C?.publicUrl,t[49]=H,t[50]=ne,t[51]=U,t[52]=W,t[53]=G}else H=t[49],ne=t[50],U=t[51],W=t[52],G=t[53];if(G!==Symbol.for(`react.early_return_sentinel`))return G;let K;t[82]===_.pairSecurityNote?K=t[83]:(K=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:_.pairSecurityNote}),t[82]=_.pairSecurityNote,t[83]=K);let re;t[84]!==x||t[85]!==P||t[86]!==R||t[87]!==N||t[88]!==I||t[89]!==L||t[90]!==_.pairEncoding||t[91]!==_.pairImageError||t[92]!==_.pairQrDisabled?(re=P?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[I&&!L?(0,$.jsx)(`img`,{src:I,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,R?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_.pairEncoding}):null,L?(0,$.jsx)(`p`,{className:`text-center text-sm text-fg-muted sm:text-left`,children:_.pairImageError}):null,(0,$.jsx)(ie,{text:P,labels:x})]}):N?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_.pairQrDisabled}):null,t[84]=x,t[85]=P,t[86]=R,t[87]=N,t[88]=I,t[89]=L,t[90]=_.pairEncoding,t[91]=_.pairImageError,t[92]=_.pairQrDisabled,t[93]=re):re=t[93];let q;t[94]!==H||t[95]!==F||t[96]!==_.deeplinkTitle?(q=F&&!H?(0,$.jsxs)(`details`,{className:`mt-3 rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:_.deeplinkTitle}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:F})]}):null,t[94]=H,t[95]=F,t[96]=_.deeplinkTitle,t[97]=q):q=t[97];let ae;t[98]!==H||t[99]!==_.pairMobileProbeHint||t[100]!==_.pairSchemeHint?(ae=H?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-3 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:_.pairSchemeHint}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] leading-relaxed text-fg-subtle`,children:_.pairMobileProbeHint})]}),t[98]=H,t[99]=_.pairMobileProbeHint,t[100]=_.pairSchemeHint,t[101]=ae):ae=t[101];let J,Y;t[102]===V?(J=t[103],Y=t[104]):(J=()=>void V.runEnableLanPairing(),Y=()=>{V.busy||V.setConfirmOpen(!1)},t[102]=V,t[103]=J,t[104]=Y);let X;t[105]!==V.confirmOpen||t[106]!==_.consentCancel||t[107]!==_.pairEnableLanButton||t[108]!==_.pairEnableLanConfirmBody||t[109]!==_.pairEnableLanConfirmTitle||t[110]!==J||t[111]!==Y?(X=(0,$.jsx)(z,{open:V.confirmOpen,title:_.pairEnableLanConfirmTitle,description:_.pairEnableLanConfirmBody,confirmLabel:_.pairEnableLanButton,cancelLabel:_.consentCancel,onConfirm:J,onCancel:Y}),t[105]=V.confirmOpen,t[106]=_.consentCancel,t[107]=_.pairEnableLanButton,t[108]=_.pairEnableLanConfirmBody,t[109]=_.pairEnableLanConfirmTitle,t[110]=J,t[111]=Y,t[112]=X):X=t[112];let oe;return t[113]!==K||t[114]!==re||t[115]!==q||t[116]!==ae||t[117]!==X||t[118]!==ne||t[119]!==U||t[120]!==W?(oe=(0,$.jsx)(Ce,{children:(0,$.jsxs)($.Fragment,{children:[ne,U,W,K,re,q,ae,X]})}),t[113]=K,t[114]=re,t[115]=q,t[116]=ae,t[117]=X,t[118]=ne,t[119]=U,t[120]=W,t[121]=oe):oe=t[121],oe}function Ae(e){return e.reachable}function je(e){return e.kind===`lan`}function Me(e){return e.language}function Ne(e){let t=(0,Z.c)(40),{open:n,title:r,intro:i,bullets:a,checkboxLabel:o,confirmLabel:s,cancelLabel:c,onConfirm:l,onCancel:u}=e,[p,m]=(0,Q.useState)(!1),h;t[0]===u?h=t[1]:(h=e=>{e||(m(!1),u())},t[0]=u,t[1]=h);let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(T,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),t[2]=g):g=t[2];let _;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=d(`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-panel p-6 shadow-popover outline-none dark:border-edge`,C),t[3]=_):_=t[3];let v;t[4]===r?v=t[5]:(v=(0,$.jsx)(k,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=v);let y;t[6]===i?y=t[7]:(y=(0,$.jsx)(E,{className:`mt-2 text-sm text-fg-muted`,children:i}),t[6]=i,t[7]=y);let b;t[8]===a?b=t[9]:(b=a.map(Pe),t[8]=a,t[9]=b);let x;t[10]===b?x=t[11]:(x=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:b}),t[10]=b,t[11]=x);let S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>m(e.target.checked),t[12]=S):S=t[12];let j;t[13]===p?j=t[14]:(j=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:p,onChange:S}),t[13]=p,t[14]=j);let M;t[15]===o?M=t[16]:(M=(0,$.jsx)(`span`,{children:o}),t[15]=o,t[16]=M);let N;t[17]!==M||t[18]!==j?(N=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[j,M]}),t[17]=M,t[18]=j,t[19]=N):N=t[19];let P;t[20]!==c||t[21]!==u?(P=(0,$.jsx)(f,{type:`button`,variant:`secondary`,onClick:u,children:c}),t[20]=c,t[21]=u,t[22]=P):P=t[22];let F=!p,I;t[23]!==s||t[24]!==l||t[25]!==F?(I=(0,$.jsx)(f,{type:`button`,disabled:F,onClick:l,children:s}),t[23]=s,t[24]=l,t[25]=F,t[26]=I):I=t[26];let L;t[27]!==P||t[28]!==I?(L=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[P,I]}),t[27]=P,t[28]=I,t[29]=L):L=t[29];let R;t[30]!==N||t[31]!==L||t[32]!==v||t[33]!==y||t[34]!==x?(R=(0,$.jsxs)(D,{children:[g,(0,$.jsxs)(O,{className:_,onOpenAutoFocus:Fe,children:[v,y,x,N,L]})]}),t[30]=N,t[31]=L,t[32]=v,t[33]=y,t[34]=x,t[35]=R):R=t[35];let z;return t[36]!==n||t[37]!==h||t[38]!==R?(z=(0,$.jsx)(A,{open:n,onOpenChange:h,children:R}),t[36]=n,t[37]=h,t[38]=R,t[39]=z):z=t[39],z}function Pe(e){return(0,$.jsx)(`li`,{children:e},e)}function Fe(e){return e.preventDefault()}function Ie(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Le=[`preparing_frpc`,`registering`,`starting_frpc`];function Re(e){return e?e===`reconnecting_frpc`?Le.indexOf(`starting_frpc`):Le.indexOf(e):-1}function ze(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Le.indexOf(e),i=Re(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Be(e,t,n){let r=n.startProgress;return ze(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 Ve(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function He(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 Ue(e){let t=(0,Z.c)(31),{status:n,t:r}=e,[,i]=(0,Q.useState)(0),a;t[0]!==i||t[1]!==n.state?(a=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>i(We),1e3);return()=>window.clearInterval(e)},t[0]=i,t[1]=n.state,t[2]=a):a=t[2];let s=n.startProgress?.startedAt,c;if(t[3]!==n.state||t[4]!==s?(c=[n.state,s],t[3]=n.state,t[4]=s,t[5]=c):c=t[5],(0,Q.useEffect)(a,c),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let l,f,p,m,h;if(t[6]!==n||t[7]!==r){let e=He(n.startProgress?.startedAt);l=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,f=`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?(p=(0,$.jsxs)(`div`,{children:[i,a]}),t[17]=i,t[18]=a,t[19]=p):p=t[19];let s=Le.map(e=>{let t=ze(e,n),i=Be(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)(o,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(u,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(re,{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:Ve(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:[Ie(n.frpcDownload.bytesReceived),` /`,` `,Ie(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]===s?m=t[21]:(m=(0,$.jsx)(`ol`,{className:`space-y-2`,children:s}),t[20]=s,t[21]=m),h=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]=f,t[10]=p,t[11]=m,t[12]=h}else l=t[8],f=t[9],p=t[10],m=t[11],h=t[12];let g;t[22]!==l||t[23]!==r.publicUrlPendingNotice?(g=l?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=l,t[23]=r.publicUrlPendingNotice,t[24]=g):g=t[24];let _;return t[25]!==f||t[26]!==p||t[27]!==m||t[28]!==h||t[29]!==g?(_=(0,$.jsxs)(`div`,{className:f,children:[p,m,h,g]}),t[25]=f,t[26]=p,t[27]=m,t[28]=h,t[29]=g,t[30]=_):_=t[30],_}function We(e){return e+1}function Ge(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 Ke(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function qe(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 Je(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 Ye(e){let t=(0,Z.c)(61),{t:n,status:r,isLoading:i,statusErr:a,starting:o,stopping:s,showConsentExpired:c,copyLabels:p,startDisabled:m,startDisabledReason:h,stepLabel:g,onStart:_,onStop:v}=e,y=m===void 0?!1:m,b,x,S,C,w,T,E;t[0]!==r||t[1]!==o?(E=Ke(r),b=r.enabled||o,x=o||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(T=d(Se(),`space-y-4`),t[9]=T):T=t[9],w=`flex flex-wrap items-start justify-between gap-3`,C=`flex items-center gap-2`,S=d(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,qe(E)),t[0]=r,t[1]=o,t[2]=b,t[3]=x,t[4]=S,t[5]=C,t[6]=w,t[7]=T,t[8]=E):(b=t[2],x=t[3],S=t[4],C=t[5],w=t[6],T=t[7],E=t[8]);let D=E===`connected`&&`bg-emerald-500`,O=E===`progress`&&`bg-amber-500 animate-pulse`,k=E===`error`&&`bg-red-500`,A=E===`off`&&`bg-fg-subtle`,j;t[10]!==D||t[11]!==O||t[12]!==k||t[13]!==A?(j=d(`size-1.5 rounded-full`,D,O,k,A),t[10]=D,t[11]=O,t[12]=k,t[13]=A,t[14]=j):j=t[14];let M;t[15]===j?M=t[16]:(M=(0,$.jsx)(`span`,{className:j,"aria-hidden":!0}),t[15]=j,t[16]=M);let N;t[17]!==i||t[18]!==r||t[19]!==n?(N=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`}):Ge(n,r),t[17]=i,t[18]=r,t[19]=n,t[20]=N):N=t[20];let P;t[21]!==M||t[22]!==N||t[23]!==S?(P=(0,$.jsxs)(`span`,{className:S,children:[M,N]}),t[21]=M,t[22]=N,t[23]=S,t[24]=P):P=t[24];let F;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(F=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,Je(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=F):F=t[28];let I;t[29]!==P||t[30]!==F||t[31]!==C?(I=(0,$.jsxs)(`div`,{className:C,children:[P,F]}),t[29]=P,t[30]=F,t[31]=C,t[32]=I):I=t[32];let L;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(l,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=L):L=t[33];let R;t[34]!==I||t[35]!==w?(R=(0,$.jsxs)(`div`,{className:w,children:[I,L]}),t[34]=I,t[35]=w,t[36]=R):R=t[36];let z;t[37]===a?z=t[38]:(z=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]=z);let B;t[39]!==c||t[40]!==n.consentExpiredBanner?(B=c?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=c,t[40]=n.consentExpiredBanner,t[41]=B):B=t[41];let ee;t[42]!==b||t[43]!==p||t[44]!==_||t[45]!==v||t[46]!==x||t[47]!==r||t[48]!==y||t[49]!==h||t[50]!==o||t[51]!==g||t[52]!==s||t[53]!==n?(ee=b?(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)(ie,{label:n.publicUrlLabel,text:r.publicUrl,labels:p})}):null,x?(0,$.jsx)(Ue,{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)(f,{type:`button`,variant:`secondary`,disabled:s,onClick:v,children:[s?(0,$.jsx)(u,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(f,{type:`button`,disabled:o,onClick:_,children:[o?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(V,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[g?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:g}):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 border border-amber-500/25 bg-amber-500/5 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(J,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),y&&h?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:h}):null,(0,$.jsxs)(f,{type:`button`,disabled:o||y,onClick:_,className:`w-full sm:w-auto`,children:[o?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(V,{className:`size-4`}),n.start]})]}),t[42]=b,t[43]=p,t[44]=_,t[45]=v,t[46]=x,t[47]=r,t[48]=y,t[49]=h,t[50]=o,t[51]=g,t[52]=s,t[53]=n,t[54]=ee):ee=t[54];let te;return t[55]!==R||t[56]!==z||t[57]!==B||t[58]!==ee||t[59]!==T?(te=(0,$.jsxs)(`section`,{className:T,children:[R,z,B,ee]}),t[55]=R,t[56]=z,t[57]=B,t[58]=ee,t[59]=T,t[60]=te):te=t[60],te}var Xe=`https://console.xopc.ai/keys/tunnel`,Ze={reconfiguring:!1};function Qe(e){let t=(0,Z.c)(84),{t:n,brokerSecretFromEnv:r,brokerSecretMissing:i,brokerSecretConfiguredInConfig:a,brokerSecretMaskedValue:s,brokerSecretDraft:l,savingBrokerSecret:p,brokerSecretNotice:m,copyFailedLabel:h,onDraftChange:g,onSave:_,onClear:v,sectionRef:y}=e,b=(0,Q.useId)(),x=i&&!r,S=!x,[C,w]=(0,Q.useReducer)(F,Ze),{reconfiguring:T}=C,E;t[0]!==a||t[1]!==l||t[2]!==r||t[3]!==T?(E=a&&!r&&!T&&!l.trim(),t[0]=a,t[1]=l,t[2]=r,t[3]=T,t[4]=E):E=t[4];let D=E,O;t[5]!==n.copied||t[6]!==n.copyKey||t[7]!==n.hideKey||t[8]!==n.showKey?(O={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[5]=n.copied,t[6]=n.copyKey,t[7]=n.hideKey,t[8]=n.showKey,t[9]=O):O=t[9];let k=O,A;t[10]===l?A=t[11]:(A=l.trim().length>0&&!ce(l.trim()),t[10]=l,t[11]=A);let j=A,M;t[12]===g?M=t[13]:(M=()=>{w({type:`patch`,patch:{reconfiguring:!1}}),g(``)},t[12]=g,t[13]=M);let N=M,P=x&&`ring-1 ring-amber-500/30`,I;t[14]===P?I=t[15]:(I=d(P),t[14]=P,t[15]=I);let L=S?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:x?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,R;t[16]===L?R=t[17]:(R=d(`flex size-9 shrink-0 items-center justify-center rounded-lg`,L),t[16]=L,t[17]=R);let z;t[18]===S?z=t[19]:(z=S?(0,$.jsx)(o,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(ne,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=S,t[19]=z);let B;t[20]!==R||t[21]!==z?(B=(0,$.jsx)(`span`,{className:R,children:z}),t[20]=R,t[21]=z,t[22]=B):B=t[22];let V=S?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,te;t[23]===V?te=t[24]:(te=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:V}),t[23]=V,t[24]=te);let H=S?n.brokerSecretReadyHint:n.brokerSecretHint,U;t[25]===H?U=t[26]:(U=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:H}),t[25]=H,t[26]=U);let W;t[27]!==x||t[28]!==n.brokerSecretMissingHint?(W=x?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[27]=x,t[28]=n.brokerSecretMissingHint,t[29]=W):W=t[29];let G;t[30]!==te||t[31]!==U||t[32]!==W?(G=(0,$.jsxs)(`div`,{children:[te,U,W]}),t[30]=te,t[31]=U,t[32]=W,t[33]=G):G=t[33];let K;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(c,{className:`size-3`,"aria-hidden":!0}),t[34]=K):K=t[34];let re;t[35]===n.brokerSecretConsoleLink?re=t[36]:(re=(0,$.jsxs)(`a`,{href:Xe,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,K]}),t[35]=n.brokerSecretConsoleLink,t[36]=re);let q;t[37]!==r||t[38]!==n.brokerSecretEnvHint?(q=r?(0,$.jsx)(`p`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 text-xs text-fg-muted shadow-surface`,children:n.brokerSecretEnvHint}):null,t[37]=r,t[38]=n.brokerSecretEnvHint,t[39]=q):q=t[39];let ie;t[40]!==a||t[41]!==l||t[42]!==r||t[43]!==s||t[44]!==j||t[45]!==N||t[46]!==h||t[47]!==b||t[48]!==x||t[49]!==v||t[50]!==g||t[51]!==_||t[52]!==T||t[53]!==p||t[54]!==k||t[55]!==D||t[56]!==n.brokerSecretCancelReconfigure||t[57]!==n.brokerSecretClear||t[58]!==n.brokerSecretMaskedHelp||t[59]!==n.brokerSecretNotInConfigFile||t[60]!==n.brokerSecretPlaceholder||t[61]!==n.brokerSecretReconfigure||t[62]!==n.brokerSecretRevealFailed||t[63]!==n.brokerSecretSave||t[64]!==n.brokerSecretSaveAndContinue||t[65]!==n.brokerSecretTitle?(ie=D?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:b,children:n.brokerSecretTitle}),(0,$.jsx)(ee,{id:b,value:s,labels:k,reveal:$e,loadFailedLabel:h||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(f,{type:`button`,variant:`secondary`,disabled:p,onClick:()=>{w({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(f,{type:`button`,variant:`ghost`,disabled:p,onClick:v,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:b,children:n.brokerSecretTitle}),(0,$.jsx)(ee,{id:b,value:l,onChange:g,placeholder:n.brokerSecretPlaceholder,labels:k,disabled:p}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(f,{type:`button`,disabled:p||!j,onClick:_,children:[p?(0,$.jsx)(u,{className:`size-4 animate-spin`}):null,x?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),a||r?(0,$.jsx)(f,{type:`button`,variant:`ghost`,disabled:p,onClick:v,children:n.brokerSecretClear}):null,T?(0,$.jsx)(f,{type:`button`,variant:`ghost`,disabled:p,onClick:N,children:n.brokerSecretCancelReconfigure}):null]})]}),t[40]=a,t[41]=l,t[42]=r,t[43]=s,t[44]=j,t[45]=N,t[46]=h,t[47]=b,t[48]=x,t[49]=v,t[50]=g,t[51]=_,t[52]=T,t[53]=p,t[54]=k,t[55]=D,t[56]=n.brokerSecretCancelReconfigure,t[57]=n.brokerSecretClear,t[58]=n.brokerSecretMaskedHelp,t[59]=n.brokerSecretNotInConfigFile,t[60]=n.brokerSecretPlaceholder,t[61]=n.brokerSecretReconfigure,t[62]=n.brokerSecretRevealFailed,t[63]=n.brokerSecretSave,t[64]=n.brokerSecretSaveAndContinue,t[65]=n.brokerSecretTitle,t[66]=ie):ie=t[66];let ae;t[67]===m?ae=t[68]:(ae=m?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:m}):null,t[67]=m,t[68]=ae);let J;t[69]!==G||t[70]!==re||t[71]!==q||t[72]!==ie||t[73]!==ae?(J=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[G,re,q,ie,ae]}),t[69]=G,t[70]=re,t[71]=q,t[72]=ie,t[73]=ae,t[74]=J):J=t[74];let Y;t[75]!==B||t[76]!==J?(Y=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[B,J]}),t[75]=B,t[76]=J,t[77]=Y):Y=t[77];let X;t[78]!==Y||t[79]!==I?(X=(0,$.jsx)(Ce,{className:I,children:Y}),t[78]=Y,t[79]=I,t[80]=X):X=t[80];let oe;return t[81]!==y||t[82]!==X?(oe=(0,$.jsx)(`div`,{ref:y,id:`tunnel-broker-secret-setup`,children:X}),t[81]=y,t[82]=X,t[83]=oe):oe=t[83],oe}function $e(){return ae().then(et)}function et(e){return e.registrationSecret??null}function tt(e){let t=(0,Z.c)(10),{language:n,label:r,section:i,className:a}=e,o;t[0]!==n||t[1]!==i?(o=R(n,i),t[0]=n,t[1]=i,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=d(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,a),t[3]=a,t[4]=s);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(c,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=l):l=t[5];let u;return t[6]!==r||t[7]!==o||t[8]!==s?(u=(0,$.jsxs)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:s,children:[r,l]}),t[6]=r,t[7]=o,t[8]=s,t[9]=u):u=t[9],u}var nt=e(we(),1),rt={width:216,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function it(e){return nt.toDataURL(e,rt)}function at(e){let t=e?.candidates??[],n=t.find(e=>e.kind===`lan`&&e.reachable),r=t.find(e=>e.kind===`lan`);return(n??r)?.url?.trim()??``}function ot(e,t){let n=t.trim();return!n||!e?!1:e.candidates.some(e=>e.kind===`tunnel`&&e.url.trim()===n)}function st(e,t){return e?t?at(e)||e.recommended.url?.trim()||``:e.recommended.url?.trim()||``:``}function ct(e,t){let n=t?.preferLan===!0,r=!!e,{mutate:i}=j(),a=(0,Q.useRef)(!1),{data:o}=M(r?`tunnel-status`:null,q,{refreshInterval:6e4}),{data:s,mutate:c}=M(r?`tunnel-pair-context`:null,pe,{refreshInterval:6e4});(0,Q.useEffect)(()=>{let e=()=>{i(`tunnel-status`),i(`tunnel-qr`),i(`tunnel-pair`),i(`tunnel-pair-context`)};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[i]);let l=o?.state===`connected`&&!!o.publicUrl?.trim(),u=l&&!n,{data:d,mutate:f}=M(u&&r?`tunnel-qr`:null,oe,{refreshInterval:4*6e4}),{data:p,mutate:m}=M(!u&&r&&s?.pairingReady?`tunnel-pair`:null,he,{refreshInterval:4*6e4}),[h,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)({pairContext:void 0,preferLan:n});if(!a.current&&(s!==x.pairContext||n!==x.preferLan)){S({pairContext:s,preferLan:n});let e=st(s,n);h!==e&&v(e)}let C=(0,Q.useCallback)(e=>{a.current=!0,v(e)},[]),w=(0,Q.useCallback)(()=>{let e=st(s,n);e&&(a.current=!0,v(e))},[s,n]),T=(0,Q.useCallback)(e=>{let t=e.trim();t&&(a.current=!0,v(t))},[]),E=(0,Q.useCallback)(e=>{a.current=!1,v(e?.trim()||st(s,n))},[s,n]),D=h.trim(),O=(0,Q.useMemo)(()=>{try{let e=new URL(D);return e.protocol===`http:`||e.protocol===`https:`}catch{return!1}},[D]),k=O&&g(D),A=!u&&!!(s&&!s.pairingReady&&s.blockReason===`GATEWAY_LOOPBACK_ONLY`),N=!u&&O&&!k&&!!p?.pairingSecret&&(s?.pairingReady===!0||!A),P=(0,Q.useMemo)(()=>{let e=at(s);return n?e||(D&&!ot(s,D)?D:``):D},[s,n,D]),F=(0,Q.useMemo)(()=>{if(!e)return``;if(y.trim())return y.trim();if(u&&d?.qrPayload?.trim())return d.qrPayload.trim();if(!N||!p?.pairingSecret)return``;let t=s?.candidates.find(e=>e.kind===`tunnel`&&e.reachable),r=s?.candidates.find(e=>e.kind===`lan`&&e.reachable),i=n?P:t?.url??D;return i?_({baseUrl:i,pairingSecret:p.pairingSecret,lanUrl:n?null:t&&r?r.url:null}):``},[e,P,p?.pairingSecret,N,y,n,D,u,d?.qrPayload,s?.candidates]),I=K(()=>it(F),[F],{enabled:!!F,initial:null,errorData:null}),L=F?I.data:null,R=!!(F&&I.error!==null&&!I.loading);return{tunnelActive:l,tunnelStatus:o,tunnelQr:d,pairContext:s,pairBaseUrl:h,setPairBaseUrl:C,applySuggestedPairUrl:w,applyCandidateUrl:T,baseOk:O,localhostWarn:k,pairingBlocked:A,deepLink:F,qrPayload:F,qrDataUrl:L,qrGenFailed:R,encoding:!!(F&&!L&&!R),refreshQr:(0,Q.useCallback)(async e=>{if(e?.trim()){b(e.trim()),f({qrPayload:e.trim(),publicUrl:o?.publicUrl??``,lanUrl:d?.lanUrl??null},!1);return}b(``),await c(),u?await f():s?.pairingReady&&await m()},[m,c,f,s?.pairingReady,d?.lanUrl,o?.publicUrl,u]),resetPairBaseFromContext:E}}var lt={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,brokerSecretNotice:null};function ut({embedded:e=!1}){let t=y(e=>e.language),n=h(t).tunnelSettings,r=v(e=>e.token),i=!!r,[a,o]=(0,Q.useReducer)(F,lt),{actionError:s,starting:c,stopping:p,savingAutoStart:m,consentOpen:g,autoStartConfirmOpen:_,releaseConfirmOpen:b,releasing:x,brokerSecretDraft:S,savingBrokerSecret:C,brokerSecretNotice:w}=a,T=(0,Q.useRef)(null),E=ct(r??``),{data:D}=P(i),{data:O,error:k,isLoading:A,mutate:j}=M(i?`tunnel-status`:null,q,{refreshInterval:e=>c?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),I=(0,Q.useMemo)(()=>{let e=D?.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 O?.config?.autoStart===!0},[D,O?.config?.autoStart]),L=(0,Q.useMemo)(()=>{let e=D?.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``},[D]),R=ce(L),B=O?.registrationSecret?.source===`env`,ee=O?.registrationSecret?.source===`missing`,V=O?.registrationSecret?.configured===!0;(0,Q.useEffect)(()=>{let e=()=>{j()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[j]);let te=(0,Q.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),H=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{actionError:null}}),o({type:`patch`,patch:{starting:!0}});try{let e=await le();await j(),N(),await E.refreshQr(e.qrPayload)}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{starting:!1}})}},[j,E.refreshQr]),ne=(0,Q.useCallback)(()=>{if(!V){o({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),T.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(O?.consentRequired){o({type:`patch`,patch:{consentOpen:!0}});return}H()},[V,O?.consentRequired,H,n.brokerSecretRequiredBeforeStart]),U=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{consentOpen:!1}}),o({type:`patch`,patch:{actionError:null}});try{await me(),await Promise.all([j(),H()])}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[j,H]),W=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{actionError:null}}),o({type:`patch`,patch:{stopping:!0}});try{await ge(),await Promise.all([E.refreshQr(),j()]),N()}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{stopping:!1}})}},[j,E.refreshQr]),G=(0,Q.useCallback)(async e=>{o({type:`patch`,patch:{savingAutoStart:!0}}),o({type:`patch`,patch:{actionError:null}});try{await de({autoStart:e}),N()}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{savingAutoStart:!1}})}},[]),K=(0,Q.useCallback)(()=>{if(I){G(!1);return}if(O?.consentRequired){o({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!O?.canAutoStart){o({type:`patch`,patch:{actionError:n.autoStartHint}});return}o({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[G,O?.canAutoStart,O?.consentRequired,n,I]),re=(0,Q.useCallback)(async()=>{let e=S.trim();if(e){o({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await de({registrationSecret:e}),o({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),N(),await j(),o({type:`patch`,patch:{actionError:null}})}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[S,j,n.brokerSecretSaved]),ie=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await de({registrationSecret:null}),o({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),N(),await j()}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{savingBrokerSecret:!1}})}},[j,n.brokerSecretCleared]),ae=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await ge({release:!0}),await Promise.all([E.refreshQr(),j()]),N()}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{releasing:!1}})}},[j,E.refreshQr]),J=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:h(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!i)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 Y=O??{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`}},X=O?.consentRequired&&(Y.enabled||I||O?.consent?.acceptedAt),oe=(0,$.jsx)(Qe,{t:n,brokerSecretFromEnv:B,brokerSecretMissing:ee,brokerSecretConfiguredInConfig:R,brokerSecretMaskedValue:R?L:``,brokerSecretDraft:S,savingBrokerSecret:C,brokerSecretNotice:w,copyFailedLabel:h(t).clipboard.copyFailed,onDraftChange:e=>o({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void re(),onClear:()=>void ie(),sectionRef:T}),se=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ne,{open:g,title:n.consentTitle,intro:n.consentIntro,bullets:te,checkboxLabel:n.consentCheckbox,confirmLabel:X?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void U(),onCancel:()=>o({type:`patch`,patch:{consentOpen:!1}})},g?`consent-open`:`consent-closed`),(0,$.jsx)(z,{open:_,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{o({type:`patch`,patch:{autoStartConfirmOpen:!1}}),G(!0)},onCancel:()=>o({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(z,{open:b,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void ae(),onCancel:()=>o({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[s?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:s}):null,oe,(0,$.jsx)(Ye,{t:n,status:Y,isLoading:A,statusErr:k,starting:c,stopping:p,showConsentExpired:!!X,copyLabels:J,startDisabled:!V,startDisabledReason:V?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:ne,onStop:()=>void W()}),(0,$.jsx)(ke,{pairQr:E,gatewayToken:r??``,streamlined:!0,onRefreshQr:()=>void E.refreshQr()}),(0,$.jsxs)(Ee,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:d(`flex items-center gap-3 text-sm text-fg`,!I&&!O?.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:m||!I&&!O?.canAutoStart,onChange:K}),n.autoStart]}),!O?.canAutoStart&&!I?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,Y.subdomain||Y.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(f,{type:`button`,variant:`secondary`,disabled:x||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>o({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[x?(0,$.jsx)(u,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(Ee,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(l,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(tt,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),se]}):(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})]}),s?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:s}):null,oe,(0,$.jsx)(Ye,{t:n,status:Y,isLoading:A,statusErr:k,starting:c,stopping:p,showConsentExpired:!!X,copyLabels:J,startDisabled:!V,startDisabledReason:V?void 0:n.brokerSecretRequiredBeforeStart,onStart:ne,onStop:()=>void W()}),(0,$.jsx)(ke,{pairQr:E,gatewayToken:r??``}),Y.subdomain||Y.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(f,{type:`button`,variant:`secondary`,disabled:x||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>o({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[x?(0,$.jsx)(u,{className:`size-4 animate-spin`}):null,n.release]})}):null,Y.subdomain||Y.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(Ce,{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&&!O?.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:m||!I&&!O?.canAutoStart,onChange:K}),n.autoStart]}),!O?.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)(l,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(tt,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),se]})}async function dt(){let e=await b(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function ft(e=`serve`){let t=await b(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function pt(){let e=await b(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var mt=`https://tailscale.com/download`;function ht(e){let t=(0,Z.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`a`,{href:mt,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function gt({embedded:e=!1}){let t=y(e=>e.language),n=h(t).remoteAccess.tailscale,r=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:h(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!v(e=>e.token),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),{data:d,mutate:p,isLoading:m}=M(i?`exposure-status`:null,dt,{refreshInterval:3e4}),g=d?.tailscale.hostname,_=d?.tailscale.active===!0,b=d?.tailscale.cliAvailable!==!1,x=g?`https://${g}/`:null,S=(0,Q.useCallback)(async()=>{o(!0),c(null);try{await ft(`serve`),await p()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[p]),C=(0,Q.useCallback)(async()=>{o(!0),c(null);try{await pt(),await p()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[p]);if(!i)return null;let w=(0,$.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,$.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,$.jsxs)(`span`,{children:[n.stepInstallBefore,(0,$.jsx)(ht,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,$.jsx)(`span`,{children:n.stepEnable})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,$.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&d?.tailscale.cliAvailable===!1?(0,$.jsxs)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,$.jsx)(ht,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,m&&!d?(0,$.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,$.jsx)(H,{className:`h-20 rounded-lg`}),(0,$.jsx)(H,{className:`h-20 rounded-lg`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Ce,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:_?n.statusActive:n.statusOff}),x?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(ie,{text:x,labels:r})}):null,s?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:s}):null,(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:_?(0,$.jsxs)(f,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void C(),children:[a?(0,$.jsx)(u,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,$.jsxs)(f,{type:`button`,disabled:a||!b,onClick:()=>void S(),children:[a?(0,$.jsx)(u,{className:`mr-1 size-4 animate-spin`}):(0,$.jsx)(V,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,$.jsx)(tt,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?w:(0,$.jsxs)(Ce,{children:[(0,$.jsx)(xe,{icon:l,title:n.title,subtitle:n.subtitle}),w]})}function _t(){let e=(0,Z.c)(26),t=y(yt),n=v(vt),r;e[0]===t?r=e[1]:(r=h(t),e[0]=t,e[1]=r);let i=r.remoteAccess.lan,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o={preferLan:!0},e[2]=o):o=e[2];let s=ct(n??``,o),l;e[3]!==i.subtitle||e[4]!==i.title?(l=(0,$.jsx)(xe,{icon:se,title:i.title,subtitle:i.subtitle}),e[3]=i.subtitle,e[4]=i.title,e[5]=l):l=e[5];let u;e[6]===i.body?u=e[7]:(u=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.body}),e[6]=i.body,e[7]=u);let d;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),e[8]=d):d=e[8];let f;e[9]===i.link?f=e[10]:(f=(0,$.jsxs)(a,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[i.link,d]}),e[9]=i.link,e[10]=f);let p;e[11]!==u||e[12]!==f?(p=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[u,f]}),e[11]=u,e[12]=f,e[13]=p):p=e[13];let m;e[14]!==l||e[15]!==p?(m=(0,$.jsxs)(Ce,{children:[l,p]}),e[14]=l,e[15]=p,e[16]=m):m=e[16];let g=n??``,_;e[17]===s?_=e[18]:(_=()=>void s.refreshQr(),e[17]=s,e[18]=_);let b;e[19]!==s||e[20]!==g||e[21]!==_?(b=(0,$.jsx)(ke,{pairQr:s,gatewayToken:g,lanOnly:!0,onRefreshQr:_}),e[19]=s,e[20]=g,e[21]=_,e[22]=b):b=e[22];let x;return e[23]!==b||e[24]!==m?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[m,b]}),e[23]=b,e[24]=m,e[25]=x):x=e[25],x}function vt(e){return e.token}function yt(e){return e.language}function bt(e){let t=(0,Z.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=y(xt),a;t[0]===i?a=t[1]:(a=h(i),t[0]=i,t[1]=a);let o=a.remoteAccess.ssh,[c,l]=(0,Q.useState)(!1),u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=async()=>{await m(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(l(!0),setTimeout(()=>l(!1),2e3))},t[2]=u):u=t[2];let d=u,p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-edge bg-surface 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]=p):p=t[3];let g,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>void d(),_=(0,$.jsx)(s,{className:`mr-1 size-4`}),t[4]=g,t[5]=_):(g=t[4],_=t[5]);let v=c?o.copied:o.copy,b;t[6]===v?b=t[7]:(b=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(f,{type:`button`,variant:`ghost`,onClick:g,children:[_,v]})}),t[6]=v,t[7]=b);let x;t[8]!==r||t[9]!==o.hint?(x=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]=x):x=t[10];let S;t[11]!==b||t[12]!==x?(S=(0,$.jsxs)($.Fragment,{children:[p,b,x]}),t[11]=b,t[12]=x,t[13]=S):S=t[13];let C=S;if(r){let e;t[14]!==o.subtitle||t[15]!==o.title?(e=(0,$.jsx)(xe,{icon:X,title:o.title,subtitle:o.subtitle}),t[14]=o.subtitle,t[15]=o.title,t[16]=e):e=t[16];let n;t[17]===C?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:C}),t[17]=C,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(Ce,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let w;t[22]!==o.subtitle||t[23]!==o.title?(w=(0,$.jsx)(xe,{icon:X,title:o.title,subtitle:o.subtitle}),t[22]=o.subtitle,t[23]=o.title,t[24]=w):w=t[24];let T;t[25]===C?T=t[26]:(T=(0,$.jsx)(`div`,{className:`mt-4`,children:C}),t[25]=C,t[26]=T);let E;return t[27]!==w||t[28]!==T?(E=(0,$.jsxs)(Ce,{children:[w,T]}),t[27]=w,t[28]=T,t[29]=E):E=t[29],E}function xt(e){return e.language}function St(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(bt,{embedded:!0}),e[0]=t):t=e[0],t}function Ct(e){switch(e){case`active`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`connecting`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;default:return`bg-surface-hover text-fg-muted`}}function wt(e){let t=(0,Z.c)(5),{label:n,kind:r}=e,i;t[0]===r?i=t[1]:(i=d(`rounded-full px-2 py-0.5 text-[11px] font-medium`,Ct(r)),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,$.jsx)(`span`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function Tt(e){let t=(0,Z.c)(32),{onOpenTab:n}=e,r=y(Ot),i;t[0]===r?i=t[1]:(i=h(r),t[0]=r,t[1]=i);let a=i.remoteAccess.guide,o=!!v(Dt),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s={refreshInterval:3e4},t[2]=s):s=t[2];let{data:c}=M(o?`exposure-status`:null,dt,s),u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u={refreshInterval:15e3},t[3]=u):u=t[3];let{data:f}=M(o?`tunnel-status`:null,q,u),p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p={refreshInterval:6e4},t[4]=p):p=t[4];let{data:m}=M(o?`tunnel-pair-context`:null,pe,p);if(!o)return null;let g=c?.tailscale.active===!0,_=f?.state,b=f?.enabled&&_===`connected`,x=f?.enabled&&(_===`connecting`||_===`reconnecting`||!!f?.startProgress||!!f?.frpcDownload),S=(m?.candidates??[]).some(Et),C=g?`active`:`off`,w=g?a.statusActive:a.statusOff,T;t[5]!==a.tailscaleCardTitle||t[6]!==C||t[7]!==w?(T={tab:`tailscale`,icon:l,title:a.tailscaleCardTitle,kind:C,statusLabel:w},t[5]=a.tailscaleCardTitle,t[6]=C,t[7]=w,t[8]=T):T=t[8];let E=b?`active`:x?`connecting`:`off`,D=b?a.statusActive:x?a.statusConnecting:a.statusOff,O;t[9]!==a.publicCardTitle||t[10]!==E||t[11]!==D?(O={tab:`public`,icon:fe,title:a.publicCardTitle,kind:E,statusLabel:D},t[9]=a.publicCardTitle,t[10]=E,t[11]=D,t[12]=O):O=t[12];let k=S?`active`:`off`,A=S?a.statusActive:a.statusOff,j;t[13]!==a.reverseProxyCardTitle||t[14]!==k||t[15]!==A?(j={tab:`reverse-proxy`,icon:G,title:a.reverseProxyCardTitle,kind:k,statusLabel:A},t[13]=a.reverseProxyCardTitle,t[14]=k,t[15]=A,t[16]=j):j=t[16];let N;t[17]!==a.sshCardStatus||t[18]!==a.sshCardTitle?(N={tab:`ssh`,icon:X,title:a.sshCardTitle,kind:`off`,statusLabel:a.sshCardStatus},t[17]=a.sshCardStatus,t[18]=a.sshCardTitle,t[19]=N):N=t[19];let P;t[20]!==a.lanCardStatus||t[21]!==a.lanCardTitle?(P={tab:`lan`,icon:se,title:a.lanCardTitle,kind:`off`,statusLabel:a.lanCardStatus},t[20]=a.lanCardStatus,t[21]=a.lanCardTitle,t[22]=P):P=t[22];let F;t[23]!==O||t[24]!==j||t[25]!==N||t[26]!==P||t[27]!==T?(F=[T,O,j,N,P],t[23]=O,t[24]=j,t[25]=N,t[26]=P,t[27]=T,t[28]=F):F=t[28];let I=F,L;return t[29]!==I||t[30]!==n?(L=(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:I.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:d(`flex items-start gap-3 rounded-xl bg-surface-base px-3 py-2.5 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/50`,`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 rounded-lg bg-surface-hover/90 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)(wt,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[29]=I,t[30]=n,t[31]=L):L=t[31],L}function Et(e){return e.kind===`reverse-proxy`}function Dt(e){return e.token}function Ot(e){return e.language}function kt(e){let t=(0,Z.c)(26),{title:n,description:r,recommended:i,icon:a,onOpen:o,openLabel:s,recommendedLabel:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=d(`group flex w-full flex-col rounded-2xl bg-surface-base p-4 text-left transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=l):l=t[0];let u;t[1]===a?u=t[2]:(u=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(a,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=a,t[2]=u);let f;t[3]===n?f=t[4]:(f=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let p;t[5]!==i||t[6]!==c?(p=i&&c?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:c}):null,t[5]=i,t[6]=c,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(U,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;t[17]!==u||t[18]!==g?(v=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[u,g,_]}),t[17]=u,t[18]=g,t[19]=v):v=t[19];let y;t[20]===s?y=t[21]:(y=(0,$.jsx)(`span`,{className:`mt-3 text-xs font-medium text-accent`,children:s}),t[20]=s,t[21]=y);let b;return t[22]!==o||t[23]!==y||t[24]!==v?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:l,children:[v,y]}),t[22]=o,t[23]=y,t[24]=v,t[25]=b):b=t[25],b}function At(e){let t=(0,Z.c)(83),{onOpenTab:n}=e,r=y(Nt),i;t[0]===r?i=t[1]:(i=h(r),t[0]=r,t[1]=i);let a=i.remoteAccess,o=a.guide,s=!!v(Mt),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:u}=M(s?`exposure-status`:null,dt,c),d;t[3]===u?.conflicts?d=t[4]:(d=u?.conflicts??[],t[3]=u?.conflicts,t[4]=d);let f=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 p;t[7]===n?p=t[8]:(p=(0,$.jsx)(Tt,{onOpenTab:n}),t[7]=n,t[8]=p);let m;t[9]!==f||t[10]!==o.conflictsHint||t[11]!==o.conflictsTitle?(m=f.length>0?(0,$.jsxs)(`div`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/5 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:f.map(jt)})]}):null,t[9]=f,t[10]=o.conflictsHint,t[11]=o.conflictsTitle,t[12]=m):m=t[12];let g;t[13]===o.pickMethod?g=t[14]:(g=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o.pickMethod}),t[13]=o.pickMethod,t[14]=g);let _;t[15]===n?_=t[16]:(_=()=>n(`tailscale`),t[15]=n,t[16]=_);let b;t[17]!==o.configure||t[18]!==o.recommended||t[19]!==o.tailscaleCardDesc||t[20]!==o.tailscaleCardTitle||t[21]!==_?(b=(0,$.jsx)(kt,{icon:l,title:o.tailscaleCardTitle,description:o.tailscaleCardDesc,recommended:!0,recommendedLabel:o.recommended,openLabel:o.configure,onOpen:_}),t[17]=o.configure,t[18]=o.recommended,t[19]=o.tailscaleCardDesc,t[20]=o.tailscaleCardTitle,t[21]=_,t[22]=b):b=t[22];let x;t[23]===n?x=t[24]:(x=()=>n(`public`),t[23]=n,t[24]=x);let S;t[25]!==o.configure||t[26]!==o.publicCardDesc||t[27]!==o.publicCardTitle||t[28]!==x?(S=(0,$.jsx)(kt,{icon:fe,title:o.publicCardTitle,description:o.publicCardDesc,openLabel:o.configure,onOpen:x}),t[25]=o.configure,t[26]=o.publicCardDesc,t[27]=o.publicCardTitle,t[28]=x,t[29]=S):S=t[29];let C;t[30]===n?C=t[31]:(C=()=>n(`reverse-proxy`),t[30]=n,t[31]=C);let w;t[32]!==o.configure||t[33]!==o.reverseProxyCardDesc||t[34]!==o.reverseProxyCardTitle||t[35]!==C?(w=(0,$.jsx)(kt,{icon:G,title:o.reverseProxyCardTitle,description:o.reverseProxyCardDesc,openLabel:o.configure,onOpen:C}),t[32]=o.configure,t[33]=o.reverseProxyCardDesc,t[34]=o.reverseProxyCardTitle,t[35]=C,t[36]=w):w=t[36];let T;t[37]===n?T=t[38]:(T=()=>n(`ssh`),t[37]=n,t[38]=T);let E;t[39]!==o.configure||t[40]!==o.sshCardDesc||t[41]!==o.sshCardTitle||t[42]!==T?(E=(0,$.jsx)(kt,{icon:X,title:o.sshCardTitle,description:o.sshCardDesc,openLabel:o.configure,onOpen:T}),t[39]=o.configure,t[40]=o.sshCardDesc,t[41]=o.sshCardTitle,t[42]=T,t[43]=E):E=t[43];let D;t[44]===n?D=t[45]:(D=()=>n(`lan`),t[44]=n,t[45]=D);let O;t[46]!==o.configure||t[47]!==o.lanCardDesc||t[48]!==o.lanCardTitle||t[49]!==D?(O=(0,$.jsx)(kt,{icon:se,title:o.lanCardTitle,description:o.lanCardDesc,openLabel:o.configure,onOpen:D}),t[46]=o.configure,t[47]=o.lanCardDesc,t[48]=o.lanCardTitle,t[49]=D,t[50]=O):O=t[50];let k;t[51]!==S||t[52]!==w||t[53]!==E||t[54]!==O||t[55]!==b?(k=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[b,S,w,E,O]}),t[51]=S,t[52]=w,t[53]=E,t[54]=O,t[55]=b,t[56]=k):k=t[56];let A;t[57]!==k||t[58]!==g?(A=(0,$.jsxs)(`div`,{children:[g,k]}),t[57]=k,t[58]=g,t[59]=A):A=t[59];let j;t[60]===o.oneAtATimeHint?j=t[61]:(j=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.oneAtATimeHint}),t[60]=o.oneAtATimeHint,t[61]=j);let N;t[62]===a.advanced.proxyTitle?N=t[63]:(N=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.advanced.proxyTitle}),t[62]=a.advanced.proxyTitle,t[63]=N);let P;t[64]===a.advanced.proxyBody?P=t[65]:(P=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.advanced.proxyBody}),t[64]=a.advanced.proxyBody,t[65]=P);let F;t[66]!==r||t[67]!==a.advanced.proxyDocs?(F=(0,$.jsx)(tt,{language:r,label:a.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[66]=r,t[67]=a.advanced.proxyDocs,t[68]=F):F=t[68];let I;t[69]!==N||t[70]!==P||t[71]!==F?(I=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base px-4 py-3`,children:[N,P,F]}),t[69]=N,t[70]=P,t[71]=F,t[72]=I):I=t[72];let L;t[73]!==o.docsLink||t[74]!==r?(L=(0,$.jsx)(tt,{language:r,label:o.docsLink}),t[73]=o.docsLink,t[74]=r,t[75]=L):L=t[75];let R;return t[76]!==A||t[77]!==j||t[78]!==I||t[79]!==L||t[80]!==p||t[81]!==m?(R=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[p,m,A,j,I,L]}),t[76]=A,t[77]=j,t[78]=I,t[79]=L,t[80]=p,t[81]=m,t[82]=R):R=t[82],R}function jt(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function Mt(e){return e.token}function Nt(e){return e.language}async function Pt(e){let t=await b(x(`/api/tunnel/pair/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function Ft(e){await S(x(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function It(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function Lt(){return(0,Q.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||It(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function Rt(){return d(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,p,`dark:border-edge`)}function zt(e){return(e?.candidates.find(e=>e.kind===`reverse-proxy`))?.url?.trim()||null}function Bt(e){return(e?.candidates.find(e=>e.kind===`lan`&&e.reachable))?.url?.trim()||null}function Vt(){let e=y(e=>e.language),t=h(e).remoteAccess.reverseProxy,n=!!v(e=>e.token),r=Lt(),{mutate:i}=j(),{data:a,mutate:o}=M(n?`tunnel-pair-context`:null,pe,{refreshInterval:6e4}),s=zt(a),[c,p]=(0,Q.useState)(``),[m,g]=(0,Q.useState)({busy:!1,result:null}),[b,x]=(0,Q.useState)({busy:!1,error:null});(0,Q.useEffect)(()=>{c||(s?p(s):r&&p(r))},[s,r,c]);let S=(0,Q.useMemo)(()=>c.trim()||(s??r??``),[s,r,c]),C=!s&&!!r&&S===r,w=Bt(a),{data:T,mutate:E}=M(n&&S?[`reverse-proxy-pair`,S]:null,()=>he(),{refreshInterval:4*6e4,revalidateOnFocus:!1}),D=(0,Q.useMemo)(()=>!S||!T?.pairingSecret?``:_({baseUrl:S,pairingSecret:T.pairingSecret,lanUrl:w}),[S,w,T?.pairingSecret]),O=K(()=>it(D),[D],{enabled:!!D,initial:null,errorData:null}),k=(0,Q.useCallback)(async()=>{let e=c.trim()||S;if(e){g({busy:!0,result:null});try{g({busy:!1,result:await Pt(e)})}catch(e){g({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:e instanceof Error?e.message:String(e)}})}}},[c,S]),A=(0,Q.useCallback)(async()=>{let e=S.trim();if(e){x({busy:!0,error:null});try{await Ft(e),await o(),await i(`tunnel-pair-context`),x({busy:!1,error:null})}catch(e){x({busy:!1,error:e instanceof Error?e.message:String(e)})}}},[S,i,o]),N=(0,Q.useCallback)(async()=>{x({busy:!0,error:null});try{await Ft(null),await o(),await i(`tunnel-pair-context`),p(``),g({busy:!1,result:null}),x({busy:!1,error:null})}catch(e){x({busy:!1,error:e instanceof Error?e.message:String(e)})}},[i,o]),P=(0,Q.useCallback)(async()=>{await E()},[E]);return n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(Ce,{children:[(0,$.jsx)(xe,{icon:l,title:t.title,subtitle:t.subtitle}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:t.urlLabel}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[(0,$.jsx)(`input`,{id:`reverse-proxy-url`,className:d(Rt(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:t.urlPlaceholder,value:c,onChange:e=>{p(e.target.value),g({busy:!1,result:null})}}),(0,$.jsxs)(f,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:()=>void k(),disabled:m.busy||!c.trim(),children:[m.busy?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):null,m.busy?t.probing:t.probeButton]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.urlHint}),C&&r?(0,$.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent-soft/50 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:t.autoDetectedTitle}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:r}),(0,$.jsx)(`p`,{className:`mt-1`,children:t.autoDetectedHint})]}):null,m.result?(0,$.jsx)(Ht,{result:m.result,labels:t.probeStatus}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[S&&s!==S?(0,$.jsxs)(f,{type:`button`,onClick:()=>void A(),disabled:b.busy,children:[b.busy?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):null,b.busy?t.saving:t.saveAsDefault]}):null,s?(0,$.jsx)(f,{type:`button`,variant:`ghost`,onClick:()=>void N(),disabled:b.busy,children:t.clear}):null]}),b.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:b.error}):null,(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-100`,children:t.certWarning})]})]}),(0,$.jsxs)(Ce,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:t.qrTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.qrSubtitle})]}),D?(0,$.jsxs)(f,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void P(),children:[(0,$.jsx)(te,{className:`size-4`}),t.refreshQr]}):null]}),S?T?.pairingSecret?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[(0,$.jsxs)(`div`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`baseUrl:`}),` `,S,w?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`br`,{}),(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`lanUrl:`}),` `,w]}):null]}),O.data?(0,$.jsx)(`img`,{src:O.data,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):O.loading?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.encoding}):null,(0,$.jsx)(ie,{text:D,labels:{copy:t.copyLink,copied:t.copied,copyFailed:h(e).clipboard.copyFailed}})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.mintingSecret}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUrlYet})]})]}):null}function Ht(e){let t=(0,Z.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,$.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,$.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.mobileReady||t[5]!==n.mobilePairing?(a=n.mobilePairing?(0,$.jsxs)($.Fragment,{children:[` · `,(0,$.jsx)(`span`,{children:r.mobileReady})]}):null,t[4]=r.mobileReady,t[5]=n.mobilePairing,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,$.jsxs)(`div`,{className:`rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:border-emerald-800/60 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,$.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,$.jsxs)($.Fragment,{children:[` — `,(0,$.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-900 dark:border-red-800/60 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}var Ut=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Wt(e){return e&&Ut.includes(e)?e:`guide`}function Gt(e,t){return e.tabs[t]}function Kt(e,t){return e.tabIntro[t]}function qt(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 Jt(e){let t=(0,Z.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(At,{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)(gt,{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)(ut,{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)(Vt,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(St,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(_t,{}),t[6]=e):e=t[6],e}}}function Yt(){let e=(0,Z.c)(2),t=y(Zt),n=h(t).remoteAccess,r=!!v(Xt),[a,o]=i(),s=Wt(a.get(`tab`)),c;e[0]===o?c=e[1]:(c=e=>{o(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[0]=o,e[1]=c);let l=c,u=Kt(n,s),d=Ut.map(e=>({id:e,label:Gt(n,e)}));return(0,$.jsxs)(ve,{children:[(0,$.jsx)(_e,{title:n.pageTitle,subtitle:n.pageSubtitle,meta:(0,$.jsx)(tt,{language:t,label:n.docsLink,section:qt(s),className:`mt-1`})}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Te,{items:d,activeTab:s,onChange:l,ariaLabel:n.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(ye,{id:s,activeTab:s,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:Gt(n,s),hint:s===`public`?void 0:u,children:(0,$.jsx)(Jt,{tab:s,onOpenTab:l})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.guide.needToken})]})}function Xt(e){return e.token}function Zt(e){return e.language}export{Yt as RemoteAccessHub};
@@ -1,5 +1,5 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r,r as i}from"./popover-select-BzdnTy3h.js";import{t as a}from"./button-CSEbl4zT.js";import{t as o}from"./messages-3qRsLZuX.js";import{n as s,o as c,r as l,s as u}from"./locale-store-xULEcFVs.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Ns as f,Ps as p,Sl as m,nl as h,wl as g}from"./index-CGbKTCST.js";import{n as _,r as v}from"./settings-page-layout-BRQNel6r.js";import{n as y}from"./settings-loading-skeleton-Bvy5rdMY.js";var b=e(t(),1);async function x(e){await u(l(`/api/runtime-tools/config`),{method:`PATCH`,body:JSON.stringify(e)})}async function S(){return(await u(l(`/api/runtime-tools/prune`),{method:`POST`})).payload}async function C(e){let t=await c(l(`/api/runtime-tools/${e.runtime}/${e.action}/stream`),{method:`POST`,headers:{Accept:`text/event-stream`},body:JSON.stringify({version:e.version})});if(!t.ok||!t.body)throw Error(`HTTP ${t.status}`);let n=t.body.getReader(),r=new TextDecoder,i=``,a=!1;try{for(;!a;){let{done:t,value:o}=await n.read();if(t)break;i+=r.decode(o,{stream:!0}).replace(/\r\n/g,`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r,r as i}from"./popover-select-BzdnTy3h.js";import{t as a}from"./button-CSEbl4zT.js";import{t as o}from"./messages-D7kOD_o_.js";import{n as s,o as c,r as l,s as u}from"./locale-store-CnamlR07.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Dl as f,Is as p,Ls as m,Tl as h,al as g}from"./index-DRrjYYzZ.js";import{n as _,r as v}from"./settings-page-layout-BRQNel6r.js";import{n as y}from"./settings-loading-skeleton-zwibve4m.js";var b=e(t(),1);async function x(e){await u(l(`/api/runtime-tools/config`),{method:`PATCH`,body:JSON.stringify(e)})}async function S(){return(await u(l(`/api/runtime-tools/prune`),{method:`POST`})).payload}async function C(e){let t=await c(l(`/api/runtime-tools/${e.runtime}/${e.action}/stream`),{method:`POST`,headers:{Accept:`text/event-stream`},body:JSON.stringify({version:e.version})});if(!t.ok||!t.body)throw Error(`HTTP ${t.status}`);let n=t.body.getReader(),r=new TextDecoder,i=``,a=!1;try{for(;!a;){let{done:t,value:o}=await n.read();if(t)break;i+=r.decode(o,{stream:!0}).replace(/\r\n/g,`
2
2
  `);let s=i.split(`
3
3
 
4
4
  `);i=s.pop()??``;for(let t of s){let n=``,r=``;for(let e of t.split(`
5
- `))e.startsWith(`event:`)&&(n=e.slice(6).trim()),e.startsWith(`data:`)&&(r+=e.slice(5).trimStart());if(!r)continue;let i=JSON.parse(r);if(n===`progress`&&e.onProgress(i),n===`result`&&(a=!0,!i.ok))throw Error(i.message??`${e.action} failed`)}}}finally{n.releaseLock()}if(!a)throw Error(`Runtime operation ended without a result`)}var w=n(),T=[`node`,`python`,`uv`];function E(){let e=o(s(e=>e.language)).runtimeToolsSettings,{data:t,error:n,isLoading:c,mutate:u}=d(l(`/api/runtime-tools`)),[E,D]=(0,b.useState)(null),[O,k]=(0,b.useState)(!1),[A,j]=(0,b.useState)(!1),[M,N]=(0,b.useState)(null),[P,F]=(0,b.useState)({}),[I,L]=(0,b.useState)(null);if((0,b.useEffect)(()=>{t?.payload.config&&D(structuredClone(t.payload.config))},[t?.payload.config]),c||!E)return(0,w.jsx)(v,{children:(0,w.jsx)(y,{sections:3})});if(n)return(0,w.jsxs)(v,{children:[(0,w.jsx)(_,{title:e.title,subtitle:e.loadError}),(0,w.jsx)(a,{onClick:()=>void u(),children:e.refresh})]});let R=new Map(t?.payload.statuses.map(e=>[e.runtime,e])),z=(e,t)=>D(n=>n&&{...n,[e]:{...n[e],...t}}),B=async()=>{k(!0),L(null);try{await x(E),await u()}catch(e){L(e instanceof Error?e.message:String(e))}finally{k(!1)}},V=async(e,t)=>{N(e),L(null);try{await C({runtime:e,action:t,version:e===`uv`?E.uv.version:E[e].version,onProgress:t=>F(n=>({...n,[e]:t}))}),await u()}catch(e){L(e instanceof Error?e.message:String(e))}finally{N(null)}},H=async()=>{j(!0),L(null);try{await S(),await u()}catch(e){L(e instanceof Error?e.message:String(e))}finally{j(!1)}};return(0,w.jsxs)(v,{gap:`gap-6`,children:[(0,w.jsx)(_,{title:e.title,subtitle:e.subtitle,actions:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(a,{onClick:()=>void u(),disabled:M!==null,children:[(0,w.jsx)(p,{className:`size-4`}),e.refresh]}),(0,w.jsx)(a,{onClick:()=>void H(),disabled:A||M!==null,children:A?e.pruning:e.prune}),(0,w.jsx)(a,{variant:`primary`,onClick:()=>void B(),disabled:O||M!==null,children:O?e.saving:e.save})]})}),I?(0,w.jsx)(`div`,{className:`rounded-xl border border-danger/30 bg-danger/10 px-4 py-3 text-sm text-danger`,children:I}):null,(0,w.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-subtle p-4`,children:(0,w.jsxs)(`label`,{className:`flex items-center justify-between gap-4`,children:[(0,w.jsxs)(`span`,{children:[(0,w.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.enabled}),(0,w.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.enabledHint})]}),(0,w.jsx)(`input`,{type:`checkbox`,checked:E.enabled,onChange:e=>D({...E,enabled:e.target.checked}),className:`size-4 accent-accent`})]})}),(0,w.jsxs)(`section`,{className:`grid gap-4 rounded-xl border border-edge bg-surface-subtle p-4 md:grid-cols-2`,children:[(0,w.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.downloadSource,(0,w.jsxs)(r,{value:E.download.source,onChange:e=>D({...E,download:{...E.download,source:e.target.value}}),children:[(0,w.jsx)(i,{value:`auto`,children:e.downloadSources.auto}),(0,w.jsx)(i,{value:`website-only`,children:e.downloadSources.websiteOnly}),(0,w.jsx)(i,{value:`direct-only`,children:e.downloadSources.directOnly})]})]}),(0,w.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.gatewayBaseUrl,(0,w.jsx)(`input`,{value:E.download.gatewayBaseUrl,disabled:E.download.source===`direct-only`,onChange:e=>D({...E,download:{...E.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,w.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.offlineBundle,(0,w.jsx)(`input`,{value:E.download.bundleDir??``,placeholder:e.offlineBundlePlaceholder,onChange:e=>D({...E,download:{...E.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,w.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.proxy,(0,w.jsx)(`input`,{value:E.download.proxy??``,placeholder:`http://127.0.0.1:7890`,onChange:e=>D({...E,download:{...E.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,w.jsx)(`div`,{className:`grid gap-4 xl:grid-cols-3`,children:T.map(t=>{let n=R.get(t),o=n?.state===`ready`,s=P[t],c=t===`uv`?E.uv:E[t];return(0,w.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e.runtimeNames[t]}),(0,w.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:n?.message??e.unknown})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o?(0,w.jsx)(m,{className:`size-5 shrink-0 text-success`}):(0,w.jsx)(g,{className:`size-5 shrink-0 text-warning`}),(0,w.jsx)(`input`,{type:`checkbox`,"aria-label":`${e.runtimeNames[t]} ${e.enabled}`,checked:c.enabled,onChange:e=>{t===`uv`?D({...E,uv:{...E.uv,enabled:e.target.checked}}):z(t,{enabled:e.target.checked})},className:`size-4 accent-accent`})]})]}),(0,w.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.version,(0,w.jsx)(`input`,{value:c.version??``,placeholder:n?.requestedVersion,onChange:e=>{let n=e.target.value||void 0;t===`uv`?D({...E,uv:{...E.uv,version:n}}):z(t,{version:n})},className:`h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none focus:border-edge-strong`})]}),t===`uv`?null:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.sourcePolicy,(0,w.jsxs)(r,{value:E[t].preference,onChange:e=>z(t,{preference:e.target.value}),children:[(0,w.jsx)(i,{value:`managed-first`,children:e.preferences.managedFirst}),(0,w.jsx)(i,{value:`system-first`,children:e.preferences.systemFirst}),(0,w.jsx)(i,{value:`managed-only`,children:e.preferences.managedOnly}),(0,w.jsx)(i,{value:`system-only`,children:e.preferences.systemOnly})]})]}),(0,w.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.provisionPolicy,(0,w.jsxs)(r,{value:E[t].provision,onChange:e=>z(t,{provision:e.target.value}),children:[(0,w.jsx)(i,{value:`eager`,children:e.provisions.eager}),(0,w.jsx)(i,{value:`on-demand`,children:e.provisions.onDemand}),(0,w.jsx)(i,{value:`disabled`,children:e.provisions.disabled})]})]})]}),s&&M===t?(0,w.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,w.jsxs)(`div`,{className:`mt-auto flex gap-2`,children:[(0,w.jsxs)(a,{variant:`primary`,disabled:!E.enabled||!c.enabled||M!==null,onClick:()=>void V(t,`install`),children:[(0,w.jsx)(h,{className:`size-4`}),M===t?e.working:e.install]}),n?.repairable?(0,w.jsxs)(a,{disabled:!E.enabled||!c.enabled||M!==null,onClick:()=>void V(t,`repair`),children:[(0,w.jsx)(f,{className:`size-4`}),e.repair]}):null]}),n?.resolved?.executable?(0,w.jsx)(`code`,{className:`break-all text-[11px] text-fg-subtle`,children:n.resolved.executable}):null]},t)})})]})}export{E as RuntimeToolsSettingsPanel};
5
+ `))e.startsWith(`event:`)&&(n=e.slice(6).trim()),e.startsWith(`data:`)&&(r+=e.slice(5).trimStart());if(!r)continue;let i=JSON.parse(r);if(n===`progress`&&e.onProgress(i),n===`result`&&(a=!0,!i.ok))throw Error(i.message??`${e.action} failed`)}}}finally{n.releaseLock()}if(!a)throw Error(`Runtime operation ended without a result`)}var w=n(),T=[`node`,`python`,`uv`];function E(){let e=o(s(e=>e.language)).runtimeToolsSettings,{data:t,error:n,isLoading:c,mutate:u}=d(l(`/api/runtime-tools`)),[E,D]=(0,b.useState)(null),[O,k]=(0,b.useState)(!1),[A,j]=(0,b.useState)(!1),[M,N]=(0,b.useState)(null),[P,F]=(0,b.useState)({}),[I,L]=(0,b.useState)(null);if((0,b.useEffect)(()=>{t?.payload.config&&D(structuredClone(t.payload.config))},[t?.payload.config]),c||!E)return(0,w.jsx)(v,{children:(0,w.jsx)(y,{sections:3})});if(n)return(0,w.jsxs)(v,{children:[(0,w.jsx)(_,{title:e.title,subtitle:e.loadError}),(0,w.jsx)(a,{onClick:()=>void u(),children:e.refresh})]});let R=new Map(t?.payload.statuses.map(e=>[e.runtime,e])),z=(e,t)=>D(n=>n&&{...n,[e]:{...n[e],...t}}),B=async()=>{k(!0),L(null);try{await x(E),await u()}catch(e){L(e instanceof Error?e.message:String(e))}finally{k(!1)}},V=async(e,t)=>{N(e),L(null);try{await C({runtime:e,action:t,version:e===`uv`?E.uv.version:E[e].version,onProgress:t=>F(n=>({...n,[e]:t}))}),await u()}catch(e){L(e instanceof Error?e.message:String(e))}finally{N(null)}},H=async()=>{j(!0),L(null);try{await S(),await u()}catch(e){L(e instanceof Error?e.message:String(e))}finally{j(!1)}};return(0,w.jsxs)(v,{gap:`gap-6`,children:[(0,w.jsx)(_,{title:e.title,subtitle:e.subtitle,actions:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(a,{onClick:()=>void u(),disabled:M!==null,children:[(0,w.jsx)(m,{className:`size-4`}),e.refresh]}),(0,w.jsx)(a,{onClick:()=>void H(),disabled:A||M!==null,children:A?e.pruning:e.prune}),(0,w.jsx)(a,{variant:`primary`,onClick:()=>void B(),disabled:O||M!==null,children:O?e.saving:e.save})]})}),I?(0,w.jsx)(`div`,{className:`rounded-xl border border-danger/30 bg-danger/10 px-4 py-3 text-sm text-danger`,children:I}):null,(0,w.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-subtle p-4`,children:(0,w.jsxs)(`label`,{className:`flex items-center justify-between gap-4`,children:[(0,w.jsxs)(`span`,{children:[(0,w.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.enabled}),(0,w.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.enabledHint})]}),(0,w.jsx)(`input`,{type:`checkbox`,checked:E.enabled,onChange:e=>D({...E,enabled:e.target.checked}),className:`size-4 accent-accent`})]})}),(0,w.jsxs)(`section`,{className:`grid gap-4 rounded-xl border border-edge bg-surface-subtle p-4 md:grid-cols-2`,children:[(0,w.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.downloadSource,(0,w.jsxs)(r,{value:E.download.source,onChange:e=>D({...E,download:{...E.download,source:e.target.value}}),children:[(0,w.jsx)(i,{value:`auto`,children:e.downloadSources.auto}),(0,w.jsx)(i,{value:`website-only`,children:e.downloadSources.websiteOnly}),(0,w.jsx)(i,{value:`direct-only`,children:e.downloadSources.directOnly})]})]}),(0,w.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.gatewayBaseUrl,(0,w.jsx)(`input`,{value:E.download.gatewayBaseUrl,disabled:E.download.source===`direct-only`,onChange:e=>D({...E,download:{...E.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,w.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.offlineBundle,(0,w.jsx)(`input`,{value:E.download.bundleDir??``,placeholder:e.offlineBundlePlaceholder,onChange:e=>D({...E,download:{...E.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,w.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.proxy,(0,w.jsx)(`input`,{value:E.download.proxy??``,placeholder:`http://127.0.0.1:7890`,onChange:e=>D({...E,download:{...E.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,w.jsx)(`div`,{className:`grid gap-4 xl:grid-cols-3`,children:T.map(t=>{let n=R.get(t),o=n?.state===`ready`,s=P[t],c=t===`uv`?E.uv:E[t];return(0,w.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e.runtimeNames[t]}),(0,w.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:n?.message??e.unknown})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o?(0,w.jsx)(h,{className:`size-5 shrink-0 text-success`}):(0,w.jsx)(f,{className:`size-5 shrink-0 text-warning`}),(0,w.jsx)(`input`,{type:`checkbox`,"aria-label":`${e.runtimeNames[t]} ${e.enabled}`,checked:c.enabled,onChange:e=>{t===`uv`?D({...E,uv:{...E.uv,enabled:e.target.checked}}):z(t,{enabled:e.target.checked})},className:`size-4 accent-accent`})]})]}),(0,w.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.version,(0,w.jsx)(`input`,{value:c.version??``,placeholder:n?.requestedVersion,onChange:e=>{let n=e.target.value||void 0;t===`uv`?D({...E,uv:{...E.uv,version:n}}):z(t,{version:n})},className:`h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none focus:border-edge-strong`})]}),t===`uv`?null:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.sourcePolicy,(0,w.jsxs)(r,{value:E[t].preference,onChange:e=>z(t,{preference:e.target.value}),children:[(0,w.jsx)(i,{value:`managed-first`,children:e.preferences.managedFirst}),(0,w.jsx)(i,{value:`system-first`,children:e.preferences.systemFirst}),(0,w.jsx)(i,{value:`managed-only`,children:e.preferences.managedOnly}),(0,w.jsx)(i,{value:`system-only`,children:e.preferences.systemOnly})]})]}),(0,w.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg-muted`,children:[e.provisionPolicy,(0,w.jsxs)(r,{value:E[t].provision,onChange:e=>z(t,{provision:e.target.value}),children:[(0,w.jsx)(i,{value:`eager`,children:e.provisions.eager}),(0,w.jsx)(i,{value:`on-demand`,children:e.provisions.onDemand}),(0,w.jsx)(i,{value:`disabled`,children:e.provisions.disabled})]})]})]}),s&&M===t?(0,w.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,w.jsxs)(`div`,{className:`mt-auto flex gap-2`,children:[(0,w.jsxs)(a,{variant:`primary`,disabled:!E.enabled||!c.enabled||M!==null,onClick:()=>void V(t,`install`),children:[(0,w.jsx)(g,{className:`size-4`}),M===t?e.working:e.install]}),n?.repairable?(0,w.jsxs)(a,{disabled:!E.enabled||!c.enabled||M!==null,onClick:()=>void V(t,`repair`),children:[(0,w.jsx)(p,{className:`size-4`}),e.repair]}):null]}),n?.resolved?.executable?(0,w.jsx)(`code`,{className:`break-all text-[11px] text-fg-subtle`,children:n.resolved.executable}):null]},t)})})]})}export{E 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{n as r,r as i}from"./popover-select-BzdnTy3h.js";import{t as a}from"./cn-JdwAhgNB.js";import{Ho as o,zo as s}from"./index-CGbKTCST.js";var c=t();e();var l=n();function u(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e){let t=e[`x-order`];return typeof t==`number`&&!Number.isNaN(t)?t:999}function f(e){let t=e[`x-group`];return typeof t==`string`&&t.length>0?t:``}function p(e){return e[`x-hidden`]===!0}function m(e){let t=e.properties;if(!u(t))return[];let n=[];for(let[e,r]of Object.entries(t))u(r)&&(p(r)||n.push({key:e,sub:r,order:d(r),group:f(r),hidden:!1}));return n.sort((e,t)=>e.order-t.order||e.key.localeCompare(t.key)),n}function h(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 g(e){let t=(0,c.c)(38),{name:n,s:i,value:a,onChange:u,disabled:d}=e,f=typeof i.description==`string`?i.description:void 0,p=(typeof i[`x-placeholder`]==`string`?i[`x-placeholder`]:null)||f,m=i.format;if(Array.isArray(i.enum)&&i.enum.every(v)){let e;t[0]===f?e=t[1]:(e=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[0]=f,t[1]=e);let o;t[2]===u?o=t[3]:(o=e=>u(e.target.value),t[2]=u,t[3]=o);let s;t[4]===i.enum?s=t[5]:(s=i.enum.map(_),t[4]=i.enum,t[5]=s);let c;t[6]!==d||t[7]!==n||t[8]!==o||t[9]!==s||t[10]!==a?(c=(0,l.jsx)(r,{name:n,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg`,value:a,disabled:d,onChange:o,children:s}),t[6]=d,t[7]=n,t[8]=o,t[9]=s,t[10]=a,t[11]=c):c=t[11];let p;return t[12]!==e||t[13]!==c?(p=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,c]}),t[12]=e,t[13]=c,t[14]=p):p=t[14],p}if(m===`password`){let e;t[15]===f?e=t[16]:(e=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[15]=f,t[16]=e);let n;t[17]!==d||t[18]!==u||t[19]!==p||t[20]!==a?(n=(0,l.jsx)(o,{value:a,onChange:u,placeholder:p,labels:s,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]=u,t[19]=p,t[20]=a,t[21]=n):n=t[21];let r;return t[22]!==e||t[23]!==n?(r=(0,l.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,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[25]=f,t[26]=h);let g;t[27]===u?g=t[28]:(g=e=>u(e.target.value),t[27]=u,t[28]=g);let y;t[29]!==d||t[30]!==n||t[31]!==p||t[32]!==g||t[33]!==a?(y=(0,l.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:a,placeholder:p,disabled:d,onChange:g}),t[29]=d,t[30]=n,t[31]=p,t[32]=g,t[33]=a,t[34]=y):y=t[34];let b;return t[35]!==h||t[36]!==y?(b=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[h,y]}),t[35]=h,t[36]=y,t[37]=b):b=t[37],b}function _(e){return(0,l.jsx)(i,{value:e,children:e},e)}function v(e){return typeof e==`string`}function y(e){let t=(0,c.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,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:o}):null,t[0]=o,t[1]=s);let u=Number.isFinite(r)?r:0,d;t[2]===i?d=t[3]:(d=e=>i(Number(e.target.value)),t[2]=i,t[3]=d);let f;t[4]!==a||t[5]!==u||t[6]!==d?(f=(0,l.jsx)(`input`,{type:`number`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg`,value:u,disabled:a,onChange:d}),t[4]=a,t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;return t[8]!==s||t[9]!==f?(p=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,f]}),t[8]=s,t[9]=f,t[10]=p):p=t[10],p}function b(e){let t=(0,c.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`),u;t[0]===i?u=t[1]:(u=e=>i(e.target.checked),t[0]=i,t[1]=u);let d;t[2]!==a||t[3]!==u||t[4]!==r?(d=(0,l.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border border-edge`,checked:r,disabled:a,onChange:u}),t[2]=a,t[3]=u,t[4]=r,t[5]=d):d=t[5];let f;t[6]===s?f=t[7]:(f=(0,l.jsx)(`span`,{children:s}),t[6]=s,t[7]=f);let p;return t[8]!==d||t[9]!==f?(p=(0,l.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 x(e){let t=(0,c.c)(27),{s:n,value:r,onChange:i,disabled:a,labels:o}=e,s=typeof n.description==`string`?n.description:void 0,d=n.items,f=u(d)?d.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,l.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,l.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,l.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,l.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,l.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,l.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,l.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 S(e){let t=(0,c.c)(66),{k:n,sub:r,value:i,onValue:a,disabled:o,labels:s}=e,d=r.type,f=(typeof r.title==`string`&&r.title.length>0?r.title:null)??n;if(d===`boolean`){let e;t[0]===f?e=t[1]:(e=(0,l.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 u;t[4]!==o||t[5]!==s||t[6]!==r||t[7]!==n||t[8]!==c?(u=(0,l.jsx)(b,{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]=u):u=t[9];let d;return t[10]!==e||t[11]!==u?(d=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,u]}),t[10]=e,t[11]=u,t[12]=d):d=t[12],d}if(d===`number`||d===`integer`){let e;t[13]===f?e=t[14]:(e=(0,l.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,l.jsx)(y,{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,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,s]}),t[20]=e,t[21]=s,t[22]=c):c=t[22],c}if(d===`string`){let e;t[23]===f?e=t[24]:(e=(0,l.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,l.jsx)(g,{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 u;return t[31]!==e||t[32]!==c?(u=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[31]=e,t[32]=c,t[33]=u):u=t[33],u}if(d===`array`){let e=r.items,n=u(e)?e.type:void 0;if(n===`string`||Array.isArray(n)&&n.includes(`string`)){let e;t[34]===f?e=t[35]:(e=(0,l.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(C)?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,l.jsx)(x,{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 u;return t[44]!==e||t[45]!==c?(u=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[44]=e,t[45]=c,t[46]=u):u=t[46],u}}if(d===`object`){let e;t[47]===i?e=t[48]:(e=u(i)?i:{},t[47]=i,t[48]=e);let n=e,c;t[49]===f?c=t[50]:(c=(0,l.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 d;t[51]!==o||t[52]!==s||t[53]!==n||t[54]!==a||t[55]!==r?(d=(0,l.jsx)(`div`,{className:`border-t border-edge p-3`,children:(0,l.jsx)(w,{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]=d):d=t[56];let p;return t[57]!==c||t[58]!==d?(p=(0,l.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[c,d]}),t[57]=c,t[58]=d,t[59]=p):p=t[59],p}let p;t[60]!==s||t[61]!==d||t[62]!==f?(p=s?.unsupportedFieldType?.(f,typeof d==`string`?d:void 0)??`${f}: unsupported field type${typeof d==`string`?` (${d})`:``}`,t[60]=s,t[61]=d,t[62]=f,t[63]=p):p=t[63];let m;return t[64]===p?m=t[65]:(m=(0,l.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[64]=p,t[65]=m),m}function C(e){return typeof e==`string`||typeof e==`number`}function w(e){let t=(0,c.c)(28),{schema:n,values:r,onChange:i,disabled:o,className:s,labels:d}=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=m(n),t[1]=n,t[2]=e),p=e}let g=p,_;bb1:{if(g.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=new Map,t[3]=e):e=t[3],_=e;break bb1}let e;t[4]===g?e=t[5]:(e=h(g),t[4]=g,t[5]=e),_=e}let v=_,y;t[6]!==i||t[7]!==r?(y=(e,t)=>{i({...r,[e]:t})},t[6]=i,t[7]=r,t[8]=y):y=t[8];let b=y;if(n.type!==`object`||!u(n.properties)||g.length===0)return null;let x,C;if(t[9]!==s||t[10]!==f||t[11]!==v||t[12]!==d||t[13]!==b||t[14]!==r){let e=Array.from(v.keys()).sort(T);t[17]===s?x=t[18]:(x=a(`flex flex-col gap-4`,s),t[17]=s,t[18]=x);let n;t[19]!==f||t[20]!==v||t[21]!==d||t[22]!==b||t[23]!==r?(n=e=>{let t=(v.get(e)??[]).map(e=>(0,l.jsx)(S,{k:e.key,sub:e.sub,value:r[e.key],onValue:t=>b(e.key,t),disabled:f,labels:d},e.key));return e===``?(0,l.jsx)(`div`,{children:t},`default`):(0,l.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[(0,l.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,l.jsx)(`div`,{className:`space-y-4 border-t border-edge p-3`,children:t})]},e)},t[19]=f,t[20]=v,t[21]=d,t[22]=b,t[23]=r,t[24]=n):n=t[24],C=e.map(n),t[9]=s,t[10]=f,t[11]=v,t[12]=d,t[13]=b,t[14]=r,t[15]=x,t[16]=C}else x=t[15],C=t[16];let w;return t[25]!==x||t[26]!==C?(w=(0,l.jsx)(`div`,{className:x,children:C}),t[25]=x,t[26]=C,t[27]=w):w=t[27],w}function T(e,t){return e===``?-1:t===``?1:e.localeCompare(t)}export{w as t};
1
+ import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r,r as i}from"./popover-select-BzdnTy3h.js";import{t as a}from"./cn-JdwAhgNB.js";import{Go as o,Ho as s}from"./index-DRrjYYzZ.js";var c=t();e();var l=n();function u(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e){let t=e[`x-order`];return typeof t==`number`&&!Number.isNaN(t)?t:999}function f(e){let t=e[`x-group`];return typeof t==`string`&&t.length>0?t:``}function p(e){return e[`x-hidden`]===!0}function m(e){let t=e.properties;if(!u(t))return[];let n=[];for(let[e,r]of Object.entries(t))u(r)&&(p(r)||n.push({key:e,sub:r,order:d(r),group:f(r),hidden:!1}));return n.sort((e,t)=>e.order-t.order||e.key.localeCompare(t.key)),n}function h(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 g(e){let t=(0,c.c)(38),{name:n,s:i,value:a,onChange:u,disabled:d}=e,f=typeof i.description==`string`?i.description:void 0,p=(typeof i[`x-placeholder`]==`string`?i[`x-placeholder`]:null)||f,m=i.format;if(Array.isArray(i.enum)&&i.enum.every(v)){let e;t[0]===f?e=t[1]:(e=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[0]=f,t[1]=e);let o;t[2]===u?o=t[3]:(o=e=>u(e.target.value),t[2]=u,t[3]=o);let s;t[4]===i.enum?s=t[5]:(s=i.enum.map(_),t[4]=i.enum,t[5]=s);let c;t[6]!==d||t[7]!==n||t[8]!==o||t[9]!==s||t[10]!==a?(c=(0,l.jsx)(r,{name:n,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg`,value:a,disabled:d,onChange:o,children:s}),t[6]=d,t[7]=n,t[8]=o,t[9]=s,t[10]=a,t[11]=c):c=t[11];let p;return t[12]!==e||t[13]!==c?(p=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,c]}),t[12]=e,t[13]=c,t[14]=p):p=t[14],p}if(m===`password`){let e;t[15]===f?e=t[16]:(e=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[15]=f,t[16]=e);let n;t[17]!==d||t[18]!==u||t[19]!==p||t[20]!==a?(n=(0,l.jsx)(o,{value:a,onChange:u,placeholder:p,labels:s,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]=u,t[19]=p,t[20]=a,t[21]=n):n=t[21];let r;return t[22]!==e||t[23]!==n?(r=(0,l.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,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[25]=f,t[26]=h);let g;t[27]===u?g=t[28]:(g=e=>u(e.target.value),t[27]=u,t[28]=g);let y;t[29]!==d||t[30]!==n||t[31]!==p||t[32]!==g||t[33]!==a?(y=(0,l.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:a,placeholder:p,disabled:d,onChange:g}),t[29]=d,t[30]=n,t[31]=p,t[32]=g,t[33]=a,t[34]=y):y=t[34];let b;return t[35]!==h||t[36]!==y?(b=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[h,y]}),t[35]=h,t[36]=y,t[37]=b):b=t[37],b}function _(e){return(0,l.jsx)(i,{value:e,children:e},e)}function v(e){return typeof e==`string`}function y(e){let t=(0,c.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,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:o}):null,t[0]=o,t[1]=s);let u=Number.isFinite(r)?r:0,d;t[2]===i?d=t[3]:(d=e=>i(Number(e.target.value)),t[2]=i,t[3]=d);let f;t[4]!==a||t[5]!==u||t[6]!==d?(f=(0,l.jsx)(`input`,{type:`number`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg`,value:u,disabled:a,onChange:d}),t[4]=a,t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;return t[8]!==s||t[9]!==f?(p=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,f]}),t[8]=s,t[9]=f,t[10]=p):p=t[10],p}function b(e){let t=(0,c.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`),u;t[0]===i?u=t[1]:(u=e=>i(e.target.checked),t[0]=i,t[1]=u);let d;t[2]!==a||t[3]!==u||t[4]!==r?(d=(0,l.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border border-edge`,checked:r,disabled:a,onChange:u}),t[2]=a,t[3]=u,t[4]=r,t[5]=d):d=t[5];let f;t[6]===s?f=t[7]:(f=(0,l.jsx)(`span`,{children:s}),t[6]=s,t[7]=f);let p;return t[8]!==d||t[9]!==f?(p=(0,l.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 x(e){let t=(0,c.c)(27),{s:n,value:r,onChange:i,disabled:a,labels:o}=e,s=typeof n.description==`string`?n.description:void 0,d=n.items,f=u(d)?d.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,l.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,l.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,l.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,l.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,l.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,l.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,l.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 S(e){let t=(0,c.c)(66),{k:n,sub:r,value:i,onValue:a,disabled:o,labels:s}=e,d=r.type,f=(typeof r.title==`string`&&r.title.length>0?r.title:null)??n;if(d===`boolean`){let e;t[0]===f?e=t[1]:(e=(0,l.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 u;t[4]!==o||t[5]!==s||t[6]!==r||t[7]!==n||t[8]!==c?(u=(0,l.jsx)(b,{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]=u):u=t[9];let d;return t[10]!==e||t[11]!==u?(d=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,u]}),t[10]=e,t[11]=u,t[12]=d):d=t[12],d}if(d===`number`||d===`integer`){let e;t[13]===f?e=t[14]:(e=(0,l.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,l.jsx)(y,{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,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,s]}),t[20]=e,t[21]=s,t[22]=c):c=t[22],c}if(d===`string`){let e;t[23]===f?e=t[24]:(e=(0,l.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,l.jsx)(g,{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 u;return t[31]!==e||t[32]!==c?(u=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[31]=e,t[32]=c,t[33]=u):u=t[33],u}if(d===`array`){let e=r.items,n=u(e)?e.type:void 0;if(n===`string`||Array.isArray(n)&&n.includes(`string`)){let e;t[34]===f?e=t[35]:(e=(0,l.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(C)?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,l.jsx)(x,{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 u;return t[44]!==e||t[45]!==c?(u=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[44]=e,t[45]=c,t[46]=u):u=t[46],u}}if(d===`object`){let e;t[47]===i?e=t[48]:(e=u(i)?i:{},t[47]=i,t[48]=e);let n=e,c;t[49]===f?c=t[50]:(c=(0,l.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 d;t[51]!==o||t[52]!==s||t[53]!==n||t[54]!==a||t[55]!==r?(d=(0,l.jsx)(`div`,{className:`border-t border-edge p-3`,children:(0,l.jsx)(w,{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]=d):d=t[56];let p;return t[57]!==c||t[58]!==d?(p=(0,l.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[c,d]}),t[57]=c,t[58]=d,t[59]=p):p=t[59],p}let p;t[60]!==s||t[61]!==d||t[62]!==f?(p=s?.unsupportedFieldType?.(f,typeof d==`string`?d:void 0)??`${f}: unsupported field type${typeof d==`string`?` (${d})`:``}`,t[60]=s,t[61]=d,t[62]=f,t[63]=p):p=t[63];let m;return t[64]===p?m=t[65]:(m=(0,l.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[64]=p,t[65]=m),m}function C(e){return typeof e==`string`||typeof e==`number`}function w(e){let t=(0,c.c)(28),{schema:n,values:r,onChange:i,disabled:o,className:s,labels:d}=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=m(n),t[1]=n,t[2]=e),p=e}let g=p,_;bb1:{if(g.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=new Map,t[3]=e):e=t[3],_=e;break bb1}let e;t[4]===g?e=t[5]:(e=h(g),t[4]=g,t[5]=e),_=e}let v=_,y;t[6]!==i||t[7]!==r?(y=(e,t)=>{i({...r,[e]:t})},t[6]=i,t[7]=r,t[8]=y):y=t[8];let b=y;if(n.type!==`object`||!u(n.properties)||g.length===0)return null;let x,C;if(t[9]!==s||t[10]!==f||t[11]!==v||t[12]!==d||t[13]!==b||t[14]!==r){let e=Array.from(v.keys()).sort(T);t[17]===s?x=t[18]:(x=a(`flex flex-col gap-4`,s),t[17]=s,t[18]=x);let n;t[19]!==f||t[20]!==v||t[21]!==d||t[22]!==b||t[23]!==r?(n=e=>{let t=(v.get(e)??[]).map(e=>(0,l.jsx)(S,{k:e.key,sub:e.sub,value:r[e.key],onValue:t=>b(e.key,t),disabled:f,labels:d},e.key));return e===``?(0,l.jsx)(`div`,{children:t},`default`):(0,l.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[(0,l.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,l.jsx)(`div`,{className:`space-y-4 border-t border-edge p-3`,children:t})]},e)},t[19]=f,t[20]=v,t[21]=d,t[22]=b,t[23]=r,t[24]=n):n=t[24],C=e.map(n),t[9]=s,t[10]=f,t[11]=v,t[12]=d,t[13]=b,t[14]=r,t[15]=x,t[16]=C}else x=t[15],C=t[16];let w;return t[25]!==x||t[26]!==C?(w=(0,l.jsx)(`div`,{className:x,children:C}),t[25]=x,t[26]=C,t[27]=w):w=t[27],w}function T(e,t){return e===``?-1:t===``?1:e.localeCompare(t)}export{w as t};
@@ -0,0 +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}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as a,r as o}from"./popover-select-BzdnTy3h.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./button-CSEbl4zT.js";import{s as l}from"./form-field-width-DJw_jULe.js";import{n as u,t as d}from"./interaction-BmQogeqz.js";import{t as f}from"./messages-D7kOD_o_.js";import{l as p,n as m,r as h,s as g}from"./locale-store-CnamlR07.js";import{i as _,o as v}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{a as y,n as b,o as ee,r as x,s as te,t as S}from"./dist-BPoKqzeH.js";import{i as C}from"./vendor-swr-BIWyz7Rc.js";import{n as w,r as T}from"./gateway-config-swr-Cv2ywpdb.js";import{n as E,r as D,t as O}from"./settings-form-draft-Dy10ldo8.js";import{Bi as k,Bt as A,Dc as j,Gi as M,Hi as N,Ht as P,Ji as F,Jo as I,Js as L,Kc as R,Ki as z,Ma as B,Na as V,Ns as H,Qi as U,Tc as W,Ui as ne,Ut as G,Vi as re,Vt as ie,Wi as ae,Ws as oe,X as K,Xi as se,Xl as ce,Yi as le,Yo as q,Ys as ue,Zi as de,Zl as fe,_l as pe,al as me,ks as J,lc as he,ls as ge,ol as Y,sc as _e,wc as ve}from"./index-DRrjYYzZ.js";import{n as ye,t as be}from"./use-autosave-D6UkH_Ga.js";import{t as xe}from"./settings-advanced-gate-BTB_fxjt.js";import{n as Se,t as X}from"./settings-form-section-C7w2WS-A.js";import{t as Ce}from"./page-tabs-BaEQMYm_.js";var Z=e(t(),1),we=n(),Q=r();function Te(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 Ee(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function De(e){let t=(0,we.c)(105),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:c,onAction:l}=e,u;t[0]!==i.unnamedSession||t[1]!==n.name?(u=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=u):u=t[2];let f=u,p;t[3]===n.name?p=t[4]:(p=n.name?.trim(),t[3]=n.name,t[4]=p);let m=!!p,h=n.status===`archived`,g=n.status===`pinned`,_=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,v;t[5]===_?v=t[6]:(v=s(`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`,_),t[5]=_,t[6]=v);let y;t[7]===c?y=t[8]:(y=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=y);let b=r===`list`&&`sm:py-3`,ee;t[9]===b?ee=t[10]:(ee=s(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,b),t[9]=b,t[10]=ee);let x;t[11]===n.sourceChannel?x=t[12]:(x=(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Q.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.sourceChannel})}),t[11]=n.sourceChannel,t[12]=x);let te;t[13]===g?te=t[14]:(te=g?(0,Q.jsx)(ue,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=g,t[14]=te);let S;t[15]===n.updatedAt?S=t[16]:(S=Te(n.updatedAt),t[15]=n.updatedAt,t[16]=S);let C;t[17]===S?C=t[18]:(C=(0,Q.jsx)(`span`,{children:S}),t[17]=S,t[18]=C);let w;t[19]!==C||t[20]!==te?(w=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[te,C]}),t[19]=C,t[20]=te,t[21]=w):w=t[21];let T;t[22]!==w||t[23]!==ee||t[24]!==x?(T=(0,Q.jsxs)(`div`,{className:ee,children:[x,w]}),t[22]=w,t[23]=ee,t[24]=x,t[25]=T):T=t[25];let E=r===`list`&&`sm:py-3`,D;t[26]===E?D=t[27]:(D=s(`min-w-0 flex-1 px-3 py-2`,E),t[26]=E,t[27]=D);let O=r===`list`&&`sm:items-start`,k;t[28]===O?k=t[29]:(k=s(`flex gap-3`,O),t[28]=O,t[29]=k);let A;t[30]!==o||t[31]!==a?(A=(0,Q.jsx)(U,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=o,t[31]=a,t[32]=A):A=t[32];let j;t[33]===f?j=t[34]:(j=(0,Q.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:f,children:f}),t[33]=f,t[34]=j);let M;t[35]!==n.key||t[36]!==m?(M=m?(0,Q.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[35]=n.key,t[36]=m,t[37]=M):M=t[37];let N;t[38]!==j||t[39]!==M?(N=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[j,M]}),t[38]=j,t[39]=M,t[40]=N):N=t[40];let P;t[41]!==k||t[42]!==A||t[43]!==N?(P=(0,Q.jsxs)(`div`,{className:k,children:[A,N]}),t[41]=k,t[42]=A,t[43]=N,t[44]=P):P=t[44];let F;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Q.jsx)(he,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=F):F=t[45];let R;t[46]===n.messageCount?R=t[47]:(R=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[F,n.messageCount]}),t[46]=n.messageCount,t[47]=R);let z;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Q.jsx)(I,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=z):z=t[48];let B;t[49]===n.estimatedTokens?B=t[50]:(B=Ee(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=B);let V;t[51]===B?V=t[52]:(V=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[z,B]}),t[51]=B,t[52]=V);let H;t[53]!==R||t[54]!==V?(H=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[R,V]}),t[53]=R,t[54]=V,t[55]=H):H=t[55];let W;t[56]===n.tags?W=t[57]:(W=n.tags.length>0?(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Ae),n.tags.length>3?(0,Q.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=W);let ne;t[58]!==D||t[59]!==P||t[60]!==H||t[61]!==W?(ne=(0,Q.jsxs)(`div`,{className:D,children:[P,H,W]}),t[58]=D,t[59]=P,t[60]=H,t[61]=W,t[62]=ne):ne=t[62];let G;t[63]===l?G=t[64]:(G=()=>l(`continue`),t[63]=l,t[64]=G);let re;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Q.jsx)(he,{className:`size-4`,strokeWidth:1.75}),t[65]=re):re=t[65];let ie;t[66]!==i.continueChat||t[67]!==G?(ie=(0,Q.jsx)(`button`,{type:`button`,className:d,title:i.continueChat,"aria-label":i.continueChat,onClick:G,children:re}),t[66]=i.continueChat,t[67]=G,t[68]=ie):ie=t[68];let ae;t[69]!==h||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==l?(ae=h?(0,Q.jsx)(`button`,{type:`button`,className:d,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Q.jsx)(fe,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:d,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Q.jsx)(ce,{className:`size-4`,strokeWidth:1.75})}),t[69]=h,t[70]=i.archive,t[71]=i.unarchive,t[72]=l,t[73]=ae):ae=t[73];let oe;t[74]!==g||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==l?(oe=g?(0,Q.jsx)(`button`,{type:`button`,className:d,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Q.jsx)(L,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:d,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Q.jsx)(ue,{className:`size-4`,strokeWidth:1.75})}),t[74]=g,t[75]=i.pin,t[76]=i.unpin,t[77]=l,t[78]=oe):oe=t[78];let K;t[79]===l?K=t[80]:(K=()=>l(`export`),t[79]=l,t[80]=K);let se;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsx)(me,{className:`size-4`,strokeWidth:1.75}),t[81]=se):se=t[81];let le;t[82]!==i.export||t[83]!==K?(le=(0,Q.jsx)(`button`,{type:`button`,className:d,title:i.export,"aria-label":i.export,onClick:K,children:se}),t[82]=i.export,t[83]=K,t[84]=le):le=t[84];let q;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(q=s(d,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=q):q=t[85];let de;t[86]===l?de=t[87]:(de=()=>l(`delete`),t[86]=l,t[87]=de);let pe;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Q.jsx)(ge,{className:`size-4`,strokeWidth:1.75}),t[88]=pe):pe=t[88];let J;t[89]!==i.delete||t[90]!==de?(J=(0,Q.jsx)(`button`,{type:`button`,className:q,title:i.delete,"aria-label":i.delete,onClick:de,children:pe}),t[89]=i.delete,t[90]=de,t[91]=J):J=t[91];let Y;t[92]!==ie||t[93]!==ae||t[94]!==oe||t[95]!==le||t[96]!==J?(Y=(0,Q.jsxs)(`div`,{role:`group`,className:`flex flex-wrap items-center gap-0.5 border-t border-edge-subtle/80 bg-surface-hover/25 p-2 dark:border-edge-subtle`,onClick:ke,onKeyDown:Oe,children:[ie,ae,oe,le,J]}),t[92]=ie,t[93]=ae,t[94]=oe,t[95]=le,t[96]=J,t[97]=Y):Y=t[97];let _e;return t[98]!==c||t[99]!==T||t[100]!==ne||t[101]!==v||t[102]!==Y||t[103]!==y?(_e=(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,className:v,onClick:c,onKeyDown:y,children:[T,ne,Y]}),t[98]=c,t[99]=T,t[100]=ne,t[101]=v,t[102]=Y,t[103]=y,t[104]=_e):_e=t[104],_e}function Oe(e){return e.stopPropagation()}function ke(e){return e.stopPropagation()}function Ae(e){return(0,Q.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}var je={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:2e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Me(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ne(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Pe(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function Fe(e){let t=Me(e)?e:{},n=Me(t.userContext)?t.userContext:{},r=Me(n.memory)?n.memory:{},i=Me(r.retention)?r.retention:{},a=Me(i.compaction)?i.compaction:{},o=je,s=typeof a.model==`string`&&a.model.trim()?a.model.trim():void 0,c=Array.isArray(a.postCompactionSections)&&a.postCompactionSections.length<=12&&a.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(a.postCompactionSections.map(e=>e.trim()))]:[...o.postCompactionSections];return{enabled:typeof a.enabled==`boolean`?a.enabled:o.enabled,triggerThreshold:Ne(a.triggerThreshold,o.triggerThreshold,.1,.98),reserveTokens:Pe(a.reserveTokens,o.reserveTokens,1024),minMessagesBeforeCompact:Pe(a.minMessagesBeforeCompact,o.minMessagesBeforeCompact,2),keepRecentTokens:Pe(a.keepRecentTokens,o.keepRecentTokens,1e3),recentTurnsPreserve:Pe(a.recentTurnsPreserve,o.recentTurnsPreserve,1,12),summaryMaxTokens:Pe(a.summaryMaxTokens,o.summaryMaxTokens,256),summaryChunkTokens:Pe(a.summaryChunkTokens,o.summaryChunkTokens,1e3),summaryTimeoutMs:Pe(a.summaryTimeoutMs,o.summaryTimeoutMs,1e3,6e5),summaryRetries:Pe(a.summaryRetries,o.summaryRetries,0,5),qualityGuard:typeof a.qualityGuard==`boolean`?a.qualityGuard:o.qualityGuard,...s?{model:s}:{},minToolResultKeepChars:Pe(a.minToolResultKeepChars,o.minToolResultKeepChars,200),maxActiveTranscriptBytes:Pe(a.maxActiveTranscriptBytes,o.maxActiveTranscriptBytes,64e3),postCompactionSections:c}}function Ie(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function Le(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{memory:{retention:{compaction:t}}}}}async function Re(e){await g(h(`/api/config`),{method:`PATCH`,body:JSON.stringify(Le(e))}),await w()}var ze=128e3,Be={balanced:je,preserve:{...je,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...je,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Ve=O();function He(){return s(`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`,l,`dark:border-edge`)}function Ue(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function We(e){let t=Ue(e);for(let[e,n]of Object.entries(Be))if(t===Ue(n))return e;return`custom`}function Ge(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,we.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=He(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,Q.jsx)(`input`,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Q.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Ke(e){let t=(0,we.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,c=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,l;t[0]===c?l=t[1]:(l=s(`flex items-start gap-2 text-sm text-fg`,c),t[0]=c,t[1]=l);let u;t[2]===o?u=t[3]:(u=e=>o(e.target.checked),t[2]=o,t[3]=u);let d;t[4]!==i||t[5]!==a||t[6]!==u?(d=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:u}),t[4]=i,t[5]=a,t[6]=u,t[7]=d):d=t[7];let f;t[8]===n?f=t[9]:(f=(0,Q.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=f);let p;t[10]===r?p=t[11]:(p=(0,Q.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,Q.jsxs)(`span`,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;return t[15]!==l||t[16]!==d||t[17]!==m?(h=(0,Q.jsxs)(`label`,{className:l,children:[d,m]}),t[15]=l,t[16]=d,t[17]=m,t[18]=h):h=t[18],h}function qe({hasToken:e}){let t=f(m(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=T(e),{data:i=[],isLoading:a}=C(e?P:null,G,{revalidateOnFocus:!1}),o=(0,Z.useMemo)(()=>n?.payload?.config===void 0?null:Fe(n.payload.config),[n]),[l,d]=(0,Z.useReducer)(Ve,{form:null,baseline:null}),[p,h]=(0,Z.useState)(``),g=(0,Z.useRef)(!1),_=(0,Z.useRef)(l.form);_.current=l.form;let v=(0,Z.useRef)(null);E({enabled:e,parsed:o,dirty:g.current,trackedParsedRef:v,dispatch:d,onResetDirty:()=>{g.current=!1}});let y=l.form,b=l.baseline,ee=!!(y&&b&&JSON.stringify(y)!==JSON.stringify(b)),x=(0,Z.useCallback)(e=>{g.current=!0,d({type:`patch`,patch:e})},[]),te=(0,Z.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),S=be({value:y,dirty:ee,onSave:(0,Z.useCallback)(async e=>{try{await Re(e),d({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=Ie(e);return n?t.invalidValue.replace(`{{field}}`,te(n)):null}});if(!e||!y)return r?(0,Q.jsx)(X,{children:(0,Q.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Q.jsx)(V,{className:`h-5 w-48`}),(0,Q.jsx)(V,{className:`h-20 w-full rounded-xl`}),(0,Q.jsx)(V,{className:`h-36 w-full rounded-xl`})]})}):null;let w=We(y),D=Math.max(0,ze-y.reserveTokens),O=Math.min(Math.floor(ze*y.triggerThreshold),D),k=Math.min(100,O/ze*100),A=Math.min(100,D/ze*100),j=y.model?i.find(e=>e.id===y.model):void 0,M=j?.contextWindow&&y.summaryChunkTokens+y.summaryMaxTokens+4096>j.contextWindow,N=y.keepRecentTokens+y.reserveTokens>O,F=Math.round(y.summaryTimeoutMs*(y.summaryRetries+1)/1e3),I=e=>{let t=Be[e];x({...t,...y.model?{model:y.model}:{model:void 0},postCompactionSections:y.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=p.trim();!e||y.postCompactionSections.includes(e)||y.postCompactionSections.length>=12||(x({postCompactionSections:[...y.postCompactionSections,e]}),h(``))};return(0,Q.jsxs)(X,{onBlurCapture:S.onBlurCapture,children:[(0,Q.jsx)(Se,{icon:_e,title:t.title,subtitle:t.hint,trailing:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(ye,{status:S.status,error:S.error}),(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:y.enabled,onChange:e=>x({enabled:e.target.checked})}),y.enabled?t.enabled:t.disabled]})]})}),S.error?(0,Q.jsx)(`p`,{className:`mb-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:S.error}):null,y.enabled?null:(0,Q.jsx)(`p`,{className:`mb-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Q.jsxs)(`fieldset`,{disabled:!y.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),w===`custom`?(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Q.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":w===e,className:s(`rounded-xl border px-3 py-3 text-left`,u.transition,u.focusRingPanel,w===e?`border-accent/50 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg hover:bg-surface-hover`),onClick:()=>I(e),children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium`,children:L[e].title}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:L[e].hint})]},e))})]}),(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-hover/35 p-4 dark:border-edge`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Q.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:t.compactionTrigger}),(0,Q.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(O)})]}),(0,Q.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${k}%`}})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:t.hardInputLimit}),(0,Q.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(D)})]}),(0,Q.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${A}%`}})})]})]}),(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((y.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>x({triggerThreshold:e/100})}),(0,Q.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ge(y.reserveTokens)),value:y.reserveTokens,min:1024,step:1024,onChange:e=>x({reserveTokens:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:y.recentTurnsPreserve,min:1,max:12,onChange:e=>x({recentTurnsPreserve:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ge(y.keepRecentTokens)),value:y.keepRecentTokens,min:1e3,step:1e3,onChange:e=>x({keepRecentTokens:Math.floor(e)})})]}),N?(0,Q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Q.jsx)(K,{value:y.model??``,disabled:!y.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=>x({model:e})}),y.model?(0,Q.jsx)(c,{type:`button`,variant:`secondary`,onClick:()=>x({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Q.jsx)(Ke,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:y.qualityGuard,onChange:e=>x({qualityGuard:e})})]}),y.qualityGuard?null:(0,Q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,Q.jsx)(xe,{children:(0,Q.jsxs)(`div`,{className:`space-y-5 border-t border-edge pt-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:y.minMessagesBeforeCompact,min:2,onChange:e=>x({minMessagesBeforeCompact:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((y.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>x({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Q.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:y.summaryMaxTokens,min:256,step:256,onChange:e=>x({summaryMaxTokens:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:y.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>x({summaryChunkTokens:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(F)),value:y.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>x({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Q.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:y.summaryRetries,min:0,max:5,onChange:e=>x({summaryRetries:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:y.minToolResultKeepChars,min:200,step:100,onChange:e=>x({minToolResultKeepChars:Math.floor(e)})})]}),M?(0,Q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Q.jsxs)(`div`,{className:`border-t border-edge pt-5`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),y.postCompactionSections.length>0?(0,Q.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:y.postCompactionSections.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Q.jsx)(`button`,{type:`button`,className:s(`text-fg-muted hover:text-fg`,u.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>x({postCompactionSections:y.postCompactionSections.filter(t=>t!==e)}),children:(0,Q.jsx)(q,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Q.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Q.jsx)(`input`,{className:He(),value:p,maxLength:120,disabled:y.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),R())}}),(0,Q.jsxs)(c,{type:`button`,variant:`secondary`,disabled:!p.trim()||y.postCompactionSections.length>=12,onClick:R,children:[(0,Q.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function Je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ye(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function Xe(e){let t=Je(e)?e:{},n=Je(t.session)?t.session:{},r=Je(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:Ye(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Ze(e){await g(h(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),w()}function Qe(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,l,`dark:border-edge`)}var $e=O();function et({hasToken:e}){let t=f(m(e=>e.language)).sessions.config,{data:n,isLoading:r}=T(e),i=(0,Z.useMemo)(()=>n?.payload?.config===void 0?null:Xe(n.payload.config),[n]),[s,c]=(0,Z.useReducer)($e,{form:null,baseline:null}),l=s.form,u=s.baseline,d=(0,Z.useRef)(!1),p=(0,Z.useRef)(l);p.current=l;let h=(0,Z.useRef)(null);E({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:h,dispatch:c,onResetDirty:()=>{d.current=!1}});let g=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),_=(0,Z.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),v=be({value:l,dirty:g,onSave:(0,Z.useCallback)(async e=>{try{await Ze(e),c({type:`saved`,value:e}),d.current=!!(p.current&&JSON.stringify(p.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!l?r?(0,Q.jsx)(X,{children:(0,Q.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Q.jsx)(V,{className:`h-5 w-40`}),(0,Q.jsx)(V,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Q.jsxs)(X,{onBlurCapture:v.onBlurCapture,children:[(0,Q.jsx)(Se,{icon:Y,title:t.title,subtitle:t.hint,trailing:(0,Q.jsx)(ye,{status:v.status,error:v.error})}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Q.jsxs)(a,{className:Qe(),value:l.dmScope,onChange:e=>_({dmScope:e.target.value}),children:[(0,Q.jsx)(o,{value:`main`,children:t.dmScopeMain}),(0,Q.jsx)(o,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Q.jsx)(o,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Q.jsx)(o,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Q.jsx)(`input`,{type:`number`,min:0,className:Qe(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Q.jsx)(`input`,{type:`number`,min:1,className:Qe(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function tt(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function nt(e){let t=(0,we.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:l,onClose:u,onArchive:d,onUnarchive:f,onPin:p,onUnpin:m,onExport:h,onDelete:g}=e,C=i?.status===`archived`,w=i?.status===`pinned`,T;t[0]===u?T=t[1]:(T=e=>!e&&u(),t[0]=u,t[1]=T);let E;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Q.jsx)(y,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim`,v)}),t[2]=E):E=t[2];let D;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(D=s(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-panel shadow-popover outline-none`,_,`dark:border-edge`),t[3]=D):D=t[3];let O;t[4]!==i||t[5]!==o||t[6]!==a?(O=i&&a?(0,Q.jsx)(U,{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]=O):O=t[7];let k;t[8]!==l.unnamedSession||t[9]!==i?.name?(k=i?.name?.trim()||l.unnamedSession,t[8]=l.unnamedSession,t[9]=i?.name,t[10]=k):k=t[10];let A;t[11]===k?A=t[12]:(A=(0,Q.jsx)(te,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:k}),t[11]=k,t[12]=A);let j;t[13]!==O||t[14]!==A?(j=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[O,A]}),t[13]=O,t[14]=A,t[15]=j):j=t[15];let M;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(q,{className:`size-5`,strokeWidth:1.75}),t[16]=M):M=t[16];let N;t[17]===l.close?N=t[18]:(N=(0,Q.jsx)(b,{asChild:!0,children:(0,Q.jsx)(c,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l.close,children:M})}),t[17]=l.close,t[18]=N);let P;t[19]!==j||t[20]!==N?(P=(0,Q.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[j,N]}),t[19]=j,t[20]=N,t[21]=P):P=t[21];let F;t[22]!==l.detailLoading||t[23]!==l.detailMessages||t[24]!==r||t[25]!==i?(F=r?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.detailLoading}):i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Q.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Q.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Q.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:l.detailMessages}),(0,Q.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(rt)})]}):null,t[22]=l.detailLoading,t[23]=l.detailMessages,t[24]=r,t[25]=i,t[26]=F):F=t[26];let I;t[27]===F?I=t[28]:(I=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:F}),t[27]=F,t[28]=I);let L;t[29]!==l.detailExport||t[30]!==h?(L=(0,Q.jsx)(c,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:l.detailExport}),t[29]=l.detailExport,t[30]=h,t[31]=L):L=t[31];let R;t[32]!==C||t[33]!==l.archive||t[34]!==l.unarchive||t[35]!==d||t[36]!==f?(R=C?(0,Q.jsx)(c,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:l.unarchive}):(0,Q.jsx)(c,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:l.archive}),t[32]=C,t[33]=l.archive,t[34]=l.unarchive,t[35]=d,t[36]=f,t[37]=R):R=t[37];let z;t[38]!==w||t[39]!==l.pin||t[40]!==l.unpin||t[41]!==p||t[42]!==m?(z=w?(0,Q.jsx)(c,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:l.unpin}):(0,Q.jsx)(c,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:l.pin}),t[38]=w,t[39]=l.pin,t[40]=l.unpin,t[41]=p,t[42]=m,t[43]=z):z=t[43];let B;t[44]!==l.delete||t[45]!==g?(B=(0,Q.jsx)(c,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:g,children:l.delete}),t[44]=l.delete,t[45]=g,t[46]=B):B=t[46];let V;t[47]!==L||t[48]!==R||t[49]!==z||t[50]!==B?(V=(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[L,R,z,B]})}),t[47]=L,t[48]=R,t[49]=z,t[50]=B,t[51]=V):V=t[51];let H;t[52]!==P||t[53]!==I||t[54]!==V?(H=(0,Q.jsxs)(ee,{children:[E,(0,Q.jsxs)(x,{className:D,"aria-describedby":void 0,children:[P,I,V]})]}),t[52]=P,t[53]=I,t[54]=V,t[55]=H):H=t[55];let W;return t[56]!==n||t[57]!==T||t[58]!==H?(W=(0,Q.jsx)(S,{open:n,onOpenChange:T,children:H}),t[56]=n,t[57]=T,t[58]=H,t[59]=W):W=t[59],W}function rt(e){return(0,Q.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Q.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:tt(e.content)})]},`${e.timestamp??``}-${e.role}-${tt(e.content).slice(0,24)}`)}var it=20;function at(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ot=new Set([`all`,`active`,`pinned`,`archived`]),st=new Set([`grid`,`list`]),ct=[`sessions`,`settings`];function lt(e){return e&&ct.includes(e)?e:`sessions`}function ut(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function dt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function ft(e){let t=(0,we.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=ct.map(e=>({id:e,label:ut(n,e),icon:e===`sessions`?j:J})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Q.jsx)(Ce,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function pt(e){let t=(0,we.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a===void 0?!1:a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mb-5`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ut(n,r)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:dt(n,r)})]}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Q.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function mt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ot.has(t)?t:`all`,viewMode:st.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function ht(){let e=f(m(e=>e.language)),t=e.sessions,n=p(e=>e.token),r=!!n,{data:a,mutate:o}=C(r?[`gateway-chat-agents`,n]:null,B,{revalidateOnFocus:!1}),l=a?.defaultId??`main`,d=a?.items??[],[h,g]=i(),b=lt(h.get(`tab`)),w=(0,Z.useCallback)(e=>{let t=new URLSearchParams(h);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),g(t,{replace:!0})},[h,g]),[T,E]=(0,Z.useReducer)(D,h,mt),{searchInput:O,debouncedSearch:P,statusFilter:I,viewMode:L,channelFilter:V,sessions:U,loading:G,error:oe,hasMore:K,stats:q,detailOpen:fe,detailLoading:me,detailSession:J,confirmOpen:he,confirmKey:ge}=T;(0,Z.useEffect)(()=>{let e=setTimeout(()=>{let e=O.trim();P!==e&&E({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[O,P]);let Y=h.toString(),_e=(0,Z.useRef)(Y);if(_e.current!==Y){_e.current=Y;let e=h.get(`q`)??``,t=h.get(`status`),n=h.get(`view`),r=(h.get(`channel`)??``).trim(),i=ot.has(t)?t:`all`,a=st.has(n)?n:`grid`,o=e.trim();E({type:`patch`,patch:{...O===e?{}:{searchInput:e},...P===o?{}:{debouncedSearch:o},...I===i?{}:{statusFilter:i},...L===a?{}:{viewMode:a},...V===r?{}:{channelFilter:r}}})}(0,Z.useEffect)(()=>{let e=new URLSearchParams(h),t=P.trim();t?e.set(`q`,t):e.delete(`q`),I===`all`?e.delete(`status`):e.set(`status`,I),L===`grid`?e.delete(`view`):e.set(`view`,L),V?e.set(`channel`,V):e.delete(`channel`),e.toString()!==h.toString()&&g(e,{replace:!0})},[P,h,g,I,L,V]),(0,Z.useEffect)(()=>{if(!r||b!==`sessions`)return;let e=!1;return(async()=>{E({type:`patch`,patch:{loading:!0,error:null}});try{let t=await M({limit:it,offset:0,...P?{search:P}:{},...I===`all`?{}:{status:I},...V?{channel:V}:{}});if(e)return;E({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||E({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||E({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,b,P,I,V,t.loadError]),(0,Z.useEffect)(()=>{!r||b!==`sessions`||ae().then(e=>E({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,b]),(0,Z.useEffect)(()=>{if(!r||b!==`sessions`)return;let e=()=>void o();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,b,o]),(0,Z.useEffect)(()=>{if(!r||b!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||E({type:`patch`,patch:{sessions:U.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:J&&J.key===t.key?{...J,name:t.name}:J}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,b,U,J]);let ye=(0,Z.useCallback)(async()=>{if(!(!r||G||!K)){E({type:`patch`,patch:{loading:!0,error:null}});try{let e=await M({limit:it,offset:U.length,...P?{search:P}:{},...I===`all`?{}:{status:I},...V?{channel:V}:{}});E({type:`patch`,patch:{sessions:[...U,...e.items],hasMore:e.hasMore}})}catch(e){E({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{E({type:`patch`,patch:{loading:!1}})}}},[r,G,K,U.length,P,I,V,t.loadError]),be=(0,Z.useCallback)((e,t)=>{E({type:`patch`,patch:{sessions:U.map(n=>n.key===e?{...n,status:t}:n),detailSession:J&&J.key===e?{...J,status:t}:J}})},[U,J]),xe=(0,Z.useCallback)(async e=>{E({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{E({type:`patch`,patch:{detailSession:await ne(e)}})}catch{E({type:`patch`,patch:{detailOpen:!1}})}finally{E({type:`patch`,patch:{detailLoading:!1}})}},[]),Se=e=>{xe(e)},X=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){E({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await k(e),be(e,`archived`);break;case`unarchive`:await F(e),be(e,`active`);break;case`pin`:await z(e),be(e,`pinned`);break;case`unpin`:await le(e),be(e,`active`);break;case`export`:{let t=await N(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}ae().then(e=>E({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ce=async e=>{try{await re(e),E({type:`patch`,patch:{sessions:U.filter(t=>t.key!==e),detailSession:J?.key===e?null:J,...J?.key===e?{detailOpen:!1}:{}}}),ae().then(e=>E({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,unnamedSession:e.chat.newSession},Te={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},Ee=[{key:`all`,label:t.filterAll,icon:j},{key:`active`,label:t.filterActive,icon:pe},{key:`pinned`,label:t.filterPinned,icon:ue},{key:`archived`,label:t.filterArchived,icon:ce}],Oe=(()=>{let e=Object.entries(q?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Q.jsx)(`header`,{className:`flex flex-col gap-2`,children:(0,Q.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title})}),(0,Q.jsx)(ft,{s:t,activeTab:b,onChange:w}),(0,Q.jsx)(pt,{s:t,id:`settings`,activeTab:b,plain:!0,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(qe,{hasToken:r}),(0,Q.jsx)(et,{hasToken:r})]})}),(0,Q.jsxs)(pt,{s:t,id:`sessions`,activeTab:b,plain:!0,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Ee.map(({key:e,label:t,icon:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":I===e,onClick:()=>E({type:`patch`,patch:{statusFilter:e}}),className:s(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,u.transition,u.focusRingPanel,I===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,Q.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Q.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Q.jsx)(H,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,value:O,onChange:e=>E({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":P||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!V,onClick:()=>E({type:`patch`,patch:{channelFilter:``}}),className:s(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,u.transition,u.focusRingPanel,V?`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}),Oe.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":V===e,onClick:()=>E({type:`patch`,patch:{channelFilter:e}}),className:s(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,u.transition,u.focusRingPanel,V===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,q?.byChannel?.[e]==null?null:(0,Q.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:q.byChannel[e]})]},e))]}),q?(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[q.totalSessions,t.totalSessions],[q.activeSessions,t.activeSessions],[q.pinnedSessions,t.pinnedSessions],[q.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Q.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Q.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,oe?(0,Q.jsx)(`div`,{className:`rounded-lg border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,children:oe}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:at(t.sessionCount,{count:U.length})}),(0,Q.jsxs)(`div`,{className:ie,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Q.jsx)(c,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":L===`grid`,onClick:()=>E({type:`patch`,patch:{viewMode:`grid`}}),className:s(A,`size-7 p-0`,L===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,L===`grid`&&`text-accent-fg`),children:(0,Q.jsx)(W,{className:`size-3.5`,strokeWidth:1.5})}),(0,Q.jsx)(c,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":L===`list`,onClick:()=>E({type:`patch`,patch:{viewMode:`list`}}),className:s(A,`size-9 p-0`,L===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,L===`list`&&`text-accent-fg`),children:(0,Q.jsx)(ve,{className:`size-3.5`,strokeWidth:1.5})})]})]}),G&&U.length===0?(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,Q.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):U.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,Q.jsx)(R,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Q.jsx)(c,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:s(`grid min-w-0 gap-3`,L===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":P||void 0,children:U.map(e=>{let t=de(e,l);return(0,Q.jsx)(De,{session:e,variant:L,labels:we,sessionAgentId:t,sessionAgentAvatar:se(t,d),onOpen:()=>Se(e.key),onAction:t=>void X(e.key,t)},e.key)})}),K?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(c,{type:`button`,variant:`secondary`,disabled:G,onClick:()=>void ye(),children:t.loadMore})}):null]})]})]}),(0,Q.jsx)(nt,{open:fe,loading:me,session:J,sessionAgentId:J?de(J,l):void 0,sessionAgentAvatar:J?se(de(J,l),d):void 0,labels:Te,onClose:()=>{E({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>J&&void X(J.key,`archive`),onUnarchive:()=>J&&void X(J.key,`unarchive`),onPin:()=>J&&void X(J.key,`pin`),onUnpin:()=>J&&void X(J.key,`unpin`),onExport:()=>J&&void X(J.key,`export`),onDelete:()=>J&&E({type:`patch`,patch:{confirmKey:J.key,confirmOpen:!0}})}),(0,Q.jsx)(S,{open:he,onOpenChange:e=>E({type:`patch`,patch:{confirmOpen:e}}),children:(0,Q.jsxs)(ee,{children:[(0,Q.jsx)(y,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim`,v)}),(0,Q.jsxs)(x,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,_),children:[(0,Q.jsx)(te,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:ge?at(t.deleteSessionMessage,{name:U.find(e=>e.key===ge)?.name?.trim()||e.chat.newSession}):``}),(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(c,{type:`button`,variant:`secondary`,onClick:()=>E({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Q.jsx)(c,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{ge&&Ce(ge),E({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Q.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{ht as SessionsPage};
@@ -0,0 +1 @@
1
+ import{Jn as e}from"./index-DRrjYYzZ.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{n as r}from"./interaction-BmQogeqz.js";import{qs as i}from"./index-CGbKTCST.js";var a=e();function o(){return`rounded-2xl border border-edge-subtle bg-surface-base px-4 py-5 sm:px-5`}var s=t();function c(e){let t=(0,a.c)(7),{children:r,className:i,id:c,onBlurCapture:l}=e,u;t[0]===i?u=t[1]:(u=n(o(),i),t[0]=i,t[1]=u);let d;return t[2]!==r||t[3]!==c||t[4]!==l||t[5]!==u?(d=(0,s.jsx)(`section`,{id:c,className:u,onBlurCapture:l,children:r}),t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d):d=t[6],d}var l=`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted transition-colors dark:bg-surface-hover/70`;function u(e){let t=(0,a.c)(29),{icon:o,title:c,subtitle:u,trailing:d,titleAccessory:f,className:p,iconInteractive:m,iconLeading:h}=e,g;t[0]===o?g=t[1]:(g=(0,s.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=o,t[1]=g);let _=h??g,v;t[2]===h?v=t[3]:(v=h?n(`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel p-0 ring-1 ring-inset ring-edge-subtle transition-[box-shadow] hover:ring-accent/40 dark:ring-edge-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,r.press):n(l,`hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,r.press),t[2]=h,t[3]=v);let y=v,b=!!(m&&h),x;t[4]===p?x=t[5]:(x=n(`mb-5 flex items-start gap-3`,p),t[4]=p,t[5]=x);let S;t[6]!==m||t[7]!==h||t[8]!==_||t[9]!==y||t[10]!==b?(S=m?b?(0,s.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:y,children:_}),(0,s.jsx)(`span`,{className:`pointer-events-none absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-md border border-edge bg-surface-panel text-fg-muted shadow-sm dark:border-edge dark:bg-surface-base`,"aria-hidden":!0,children:(0,s.jsx)(i,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:y,children:_}):(0,s.jsx)(`div`,{className:n(h?`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel ring-1 ring-inset ring-edge-subtle dark:ring-edge-subtle`:l),"aria-hidden":!h,children:_}),t[6]=m,t[7]=h,t[8]=_,t[9]=y,t[10]=b,t[11]=S):S=t[11];let C;t[12]===c?C=t[13]:(C=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c}),t[12]=c,t[13]=C);let w;t[14]!==C||t[15]!==f?(w=(0,s.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[C,f]}),t[14]=C,t[15]=f,t[16]=w):w=t[16];let T;t[17]===u?T=t[18]:(T=u?(0,s.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u}):null,t[17]=u,t[18]=T);let E;t[19]!==w||t[20]!==T?(E=(0,s.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,T]}),t[19]=w,t[20]=T,t[21]=E):E=t[21];let D;t[22]===d?D=t[23]:(D=d?(0,s.jsx)(`div`,{className:`shrink-0`,children:d}):null,t[22]=d,t[23]=D);let O;return t[24]!==x||t[25]!==S||t[26]!==E||t[27]!==D?(O=(0,s.jsxs)(`div`,{className:x,children:[S,E,D]}),t[24]=x,t[25]=S,t[26]=E,t[27]=D,t[28]=O):O=t[28],O}export{u as n,o as r,c as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{n as r}from"./interaction-BmQogeqz.js";import{Xs as i}from"./index-DRrjYYzZ.js";var a=e();function o(){return`rounded-2xl border border-edge-subtle bg-surface-base px-4 py-5 sm:px-5`}var s=t();function c(e){let t=(0,a.c)(7),{children:r,className:i,id:c,onBlurCapture:l}=e,u;t[0]===i?u=t[1]:(u=n(o(),i),t[0]=i,t[1]=u);let d;return t[2]!==r||t[3]!==c||t[4]!==l||t[5]!==u?(d=(0,s.jsx)(`section`,{id:c,className:u,onBlurCapture:l,children:r}),t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d):d=t[6],d}var l=`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted transition-colors dark:bg-surface-hover/70`;function u(e){let t=(0,a.c)(29),{icon:o,title:c,subtitle:u,trailing:d,titleAccessory:f,className:p,iconInteractive:m,iconLeading:h}=e,g;t[0]===o?g=t[1]:(g=(0,s.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=o,t[1]=g);let _=h??g,v;t[2]===h?v=t[3]:(v=h?n(`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel p-0 ring-1 ring-inset ring-edge-subtle transition-[box-shadow] hover:ring-accent/40 dark:ring-edge-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,r.press):n(l,`hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,r.press),t[2]=h,t[3]=v);let y=v,b=!!(m&&h),x;t[4]===p?x=t[5]:(x=n(`mb-5 flex items-start gap-3`,p),t[4]=p,t[5]=x);let S;t[6]!==m||t[7]!==h||t[8]!==_||t[9]!==y||t[10]!==b?(S=m?b?(0,s.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:y,children:_}),(0,s.jsx)(`span`,{className:`pointer-events-none absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-md border border-edge bg-surface-panel text-fg-muted shadow-sm dark:border-edge dark:bg-surface-base`,"aria-hidden":!0,children:(0,s.jsx)(i,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:y,children:_}):(0,s.jsx)(`div`,{className:n(h?`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel ring-1 ring-inset ring-edge-subtle dark:ring-edge-subtle`:l),"aria-hidden":!h,children:_}),t[6]=m,t[7]=h,t[8]=_,t[9]=y,t[10]=b,t[11]=S):S=t[11];let C;t[12]===c?C=t[13]:(C=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c}),t[12]=c,t[13]=C);let w;t[14]!==C||t[15]!==f?(w=(0,s.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[C,f]}),t[14]=C,t[15]=f,t[16]=w):w=t[16];let T;t[17]===u?T=t[18]:(T=u?(0,s.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u}):null,t[17]=u,t[18]=T);let E;t[19]!==w||t[20]!==T?(E=(0,s.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,T]}),t[19]=w,t[20]=T,t[21]=E):E=t[21];let D;t[22]===d?D=t[23]:(D=d?(0,s.jsx)(`div`,{className:`shrink-0`,children:d}):null,t[22]=d,t[23]=D);let O;return t[24]!==x||t[25]!==S||t[26]!==E||t[27]!==D?(O=(0,s.jsxs)(`div`,{className:x,children:[S,E,D]}),t[24]=x,t[25]=S,t[26]=E,t[27]=D,t[28]=O):O=t[28],O}export{u as n,o as r,c as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{Aa as n}from"./index-CGbKTCST.js";var r=e(),i=t();function a(e){let t=(0,r.c)(2),{rows:n}=e,a=n===void 0?3:n,s;return t[0]===a?s=t[1]:(s=(0,i.jsx)(`div`,{className:`flex flex-col gap-2.5`,"aria-busy":`true`,children:Array.from({length:a}).map(o)}),t[0]=a,t[1]=s),s}function o(e,t){return(0,i.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,i.jsx)(n,{className:`h-4 w-48 max-w-full`}),(0,i.jsx)(n,{className:`mt-2 h-3 w-72 max-w-full`})]},t)}function s(e){let t=(0,r.c)(3),{sections:a}=e,o=a===void 0?2:a,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,i.jsxs)(`div`,{className:`space-y-2`,children:[(0,i.jsx)(n,{className:`h-6 w-48 max-w-full`}),(0,i.jsx)(n,{className:`h-4 w-80 max-w-full`})]}),t[0]=s):s=t[0];let l;return t[1]===o?l=t[2]:(l=(0,i.jsxs)(`div`,{className:`flex flex-col gap-6`,"aria-busy":`true`,children:[s,Array.from({length:o}).map(c)]}),t[1]=o,t[2]=l),l}function c(e,t){return(0,i.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,children:[(0,i.jsx)(n,{className:`h-5 w-40 max-w-full`}),(0,i.jsx)(n,{className:`mt-2 h-4 w-72 max-w-full`}),(0,i.jsx)(`div`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:Array.from({length:4}).map(l)})]},t)}function l(e,t){return(0,i.jsxs)(`div`,{className:`space-y-2`,children:[(0,i.jsx)(n,{className:`h-3 w-24`}),(0,i.jsx)(n,{className:`h-10 w-full rounded-lg`})]},t)}function u(e){let t=(0,r.c)(2),{rows:n}=e,a=n===void 0?3:n,o;return t[0]===a?o=t[1]:(o=(0,i.jsx)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:Array.from({length:a}).map(d)}),t[0]=a,t[1]=o),o}function d(e,t){return(0,i.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/70 p-3 shadow-surface`,children:[(0,i.jsx)(n,{className:`h-4 w-40 max-w-full`}),(0,i.jsx)(n,{className:`mt-2 h-3 w-64 max-w-full`})]},t)}export{s as n,a as r,u as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{Na as n}from"./index-DRrjYYzZ.js";var r=e(),i=t();function a(e){let t=(0,r.c)(2),{rows:n}=e,a=n===void 0?3:n,s;return t[0]===a?s=t[1]:(s=(0,i.jsx)(`div`,{className:`flex flex-col gap-2.5`,"aria-busy":`true`,children:Array.from({length:a}).map(o)}),t[0]=a,t[1]=s),s}function o(e,t){return(0,i.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,i.jsx)(n,{className:`h-4 w-48 max-w-full`}),(0,i.jsx)(n,{className:`mt-2 h-3 w-72 max-w-full`})]},t)}function s(e){let t=(0,r.c)(3),{sections:a}=e,o=a===void 0?2:a,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,i.jsxs)(`div`,{className:`space-y-2`,children:[(0,i.jsx)(n,{className:`h-6 w-48 max-w-full`}),(0,i.jsx)(n,{className:`h-4 w-80 max-w-full`})]}),t[0]=s):s=t[0];let l;return t[1]===o?l=t[2]:(l=(0,i.jsxs)(`div`,{className:`flex flex-col gap-6`,"aria-busy":`true`,children:[s,Array.from({length:o}).map(c)]}),t[1]=o,t[2]=l),l}function c(e,t){return(0,i.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,children:[(0,i.jsx)(n,{className:`h-5 w-40 max-w-full`}),(0,i.jsx)(n,{className:`mt-2 h-4 w-72 max-w-full`}),(0,i.jsx)(`div`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:Array.from({length:4}).map(l)})]},t)}function l(e,t){return(0,i.jsxs)(`div`,{className:`space-y-2`,children:[(0,i.jsx)(n,{className:`h-3 w-24`}),(0,i.jsx)(n,{className:`h-10 w-full rounded-lg`})]},t)}function u(e){let t=(0,r.c)(2),{rows:n}=e,a=n===void 0?3:n,o;return t[0]===a?o=t[1]:(o=(0,i.jsx)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:Array.from({length:a}).map(d)}),t[0]=a,t[1]=o),o}function d(e,t){return(0,i.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/70 p-3 shadow-surface`,children:[(0,i.jsx)(n,{className:`h-4 w-40 max-w-full`}),(0,i.jsx)(n,{className:`mt-2 h-3 w-64 max-w-full`})]},t)}export{s as n,a as r,u as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,r as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./messages-3qRsLZuX.js";import{n as s}from"./locale-store-xULEcFVs.js";import{Ao as c,Co as l,Do as u,Eo as d,Oo as f,So as p,To as m,bo as h,ko as g,vo as _,wo as v,xo as y,yo as b}from"./index-CGbKTCST.js";var x=n(),S=e(t(),1),C=r(),w=[`overview`,`appearance`,`keyboard-shortcuts`,`system`,`desktop-pet`,`desktop-app`,`capability-presets`,`gateway`,`runtimes`,`devices`,`heartbeat`,`remote-access`,`shares`],T=(0,S.lazy)(()=>f().then(e=>({default:e.SetupStatusPanel}))),E=(0,S.lazy)(()=>b().then(e=>({default:e.AppearanceSettingsPanel}))),D=(0,S.lazy)(()=>m().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),O=(0,S.lazy)(()=>c().then(e=>({default:e.SystemSettingsPanel}))),k=(0,S.lazy)(()=>y().then(e=>({default:e.DesktopPetSettings}))),A=(0,S.lazy)(()=>_().then(e=>({default:e.AppManagementSettingsPanel}))),j=(0,S.lazy)(()=>l().then(e=>({default:e.GatewaySettingsPanel}))),M=(0,S.lazy)(()=>u().then(e=>({default:e.RuntimeToolsSettingsPanel}))),N=(0,S.lazy)(()=>v().then(e=>({default:e.HeartbeatSettingsPanel}))),P=(0,S.lazy)(()=>d().then(e=>({default:e.RemoteAccessHub}))),F=(0,S.lazy)(()=>g().then(e=>({default:e.SharesSettingsPanel}))),I=(0,S.lazy)(()=>h().then(e=>({default:e.CapabilityPresetsSettingsPanel}))),L=(0,S.lazy)(()=>p().then(e=>({default:e.EndpointToolsManagementSettings})));function R(){let e=(0,x.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,C.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,C.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,C.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,C.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function z(e){return(0,C.jsx)(S.Suspense,{fallback:(0,C.jsx)(R,{}),children:(0,C.jsx)(e,{})})}function B(){let e=(0,x.c)(28),{section:t}=i(),n=s(V),r,c,l,u,d;if(e[0]!==n||e[1]!==t){d=Symbol.for(`react.early_return_sentinel`);bb0:{let i=o(n);if(!t||!w.includes(t)){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,C.jsx)(a,{to:`/settings/overview`,replace:!0}),e[7]=t):t=e[7],d=t;break bb0}let s=t;if(s===`overview`){let t;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(T),e[8]=t):t=e[8],d=t;break bb0}let f=i.settingsSections[s];if(s===`appearance`){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(E),e[9]=t):t=e[9],d=t;break bb0}if(s===`keyboard-shortcuts`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(D),e[10]=t):t=e[10],d=t;break bb0}if(s===`system`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(O),e[11]=t):t=e[11],d=t;break bb0}if(s===`desktop-pet`){let t;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(k),e[12]=t):t=e[12],d=t;break bb0}if(s===`desktop-app`){let t;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(A),e[13]=t):t=e[13],d=t;break bb0}if(s===`capability-presets`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(I),e[14]=t):t=e[14],d=t;break bb0}if(s===`gateway`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(j),e[15]=t):t=e[15],d=t;break bb0}if(s===`runtimes`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(M),e[16]=t):t=e[16],d=t;break bb0}if(s===`devices`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(L),e[17]=t):t=e[17],d=t;break bb0}if(s===`heartbeat`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(N),e[18]=t):t=e[18],d=t;break bb0}if(s===`remote-access`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(P),e[19]=t):t=e[19],d=t;break bb0}if(s===`shares`){let t;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(F),e[20]=t):t=e[20],d=t;break bb0}l=`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,u=(0,C.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:f}),r=`text-sm text-fg-muted`,c=i.settingsPage.comingSoon.replace(`{{title}}`,f)}e[0]=n,e[1]=t,e[2]=r,e[3]=c,e[4]=l,e[5]=u,e[6]=d}else r=e[2],c=e[3],l=e[4],u=e[5],d=e[6];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;e[21]!==r||e[22]!==c?(f=(0,C.jsx)(`p`,{className:r,children:c}),e[21]=r,e[22]=c,e[23]=f):f=e[23];let p;return e[24]!==l||e[25]!==u||e[26]!==f?(p=(0,C.jsxs)(`div`,{className:l,children:[u,f]}),e[24]=l,e[25]=u,e[26]=f,e[27]=p):p=e[27],p}function V(e){return e.language}export{B as SettingsPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,r as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./messages-D7kOD_o_.js";import{n as s}from"./locale-store-CnamlR07.js";import{Ao as c,Co as l,Do as u,Eo as d,Mo as f,No as p,Oo as m,So as h,To as g,jo as _,ko as v,wo as y,xo as b}from"./index-DRrjYYzZ.js";var x=n(),S=e(t(),1),C=r(),w=[`overview`,`appearance`,`keyboard-shortcuts`,`system`,`desktop-pet`,`desktop-app`,`capability-presets`,`gateway`,`runtimes`,`devices`,`heartbeat`,`remote-access`,`shares`],T=(0,S.lazy)(()=>_().then(e=>({default:e.SetupStatusPanel}))),E=(0,S.lazy)(()=>h().then(e=>({default:e.AppearanceSettingsPanel}))),D=(0,S.lazy)(()=>m().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),O=(0,S.lazy)(()=>p().then(e=>({default:e.SystemSettingsPanel}))),k=(0,S.lazy)(()=>y().then(e=>({default:e.DesktopPetSettings}))),A=(0,S.lazy)(()=>b().then(e=>({default:e.AppManagementSettingsPanel}))),j=(0,S.lazy)(()=>d().then(e=>({default:e.GatewaySettingsPanel}))),M=(0,S.lazy)(()=>c().then(e=>({default:e.RuntimeToolsSettingsPanel}))),N=(0,S.lazy)(()=>u().then(e=>({default:e.HeartbeatSettingsPanel}))),P=(0,S.lazy)(()=>v().then(e=>({default:e.RemoteAccessHub}))),F=(0,S.lazy)(()=>f().then(e=>({default:e.SharesSettingsPanel}))),I=(0,S.lazy)(()=>l().then(e=>({default:e.CapabilityPresetsSettingsPanel}))),L=(0,S.lazy)(()=>g().then(e=>({default:e.EndpointToolsManagementSettings})));function R(){let e=(0,x.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,C.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,C.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,C.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,C.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function z(e){return(0,C.jsx)(S.Suspense,{fallback:(0,C.jsx)(R,{}),children:(0,C.jsx)(e,{})})}function B(){let e=(0,x.c)(28),{section:t}=i(),n=s(V),r,c,l,u,d;if(e[0]!==n||e[1]!==t){d=Symbol.for(`react.early_return_sentinel`);bb0:{let i=o(n);if(!t||!w.includes(t)){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,C.jsx)(a,{to:`/settings/overview`,replace:!0}),e[7]=t):t=e[7],d=t;break bb0}let s=t;if(s===`overview`){let t;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(T),e[8]=t):t=e[8],d=t;break bb0}let f=i.settingsSections[s];if(s===`appearance`){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(E),e[9]=t):t=e[9],d=t;break bb0}if(s===`keyboard-shortcuts`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(D),e[10]=t):t=e[10],d=t;break bb0}if(s===`system`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(O),e[11]=t):t=e[11],d=t;break bb0}if(s===`desktop-pet`){let t;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(k),e[12]=t):t=e[12],d=t;break bb0}if(s===`desktop-app`){let t;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(A),e[13]=t):t=e[13],d=t;break bb0}if(s===`capability-presets`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(I),e[14]=t):t=e[14],d=t;break bb0}if(s===`gateway`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(j),e[15]=t):t=e[15],d=t;break bb0}if(s===`runtimes`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(M),e[16]=t):t=e[16],d=t;break bb0}if(s===`devices`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(L),e[17]=t):t=e[17],d=t;break bb0}if(s===`heartbeat`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(N),e[18]=t):t=e[18],d=t;break bb0}if(s===`remote-access`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(P),e[19]=t):t=e[19],d=t;break bb0}if(s===`shares`){let t;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(F),e[20]=t):t=e[20],d=t;break bb0}l=`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,u=(0,C.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:f}),r=`text-sm text-fg-muted`,c=i.settingsPage.comingSoon.replace(`{{title}}`,f)}e[0]=n,e[1]=t,e[2]=r,e[3]=c,e[4]=l,e[5]=u,e[6]=d}else r=e[2],c=e[3],l=e[4],u=e[5],d=e[6];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;e[21]!==r||e[22]!==c?(f=(0,C.jsx)(`p`,{className:r,children:c}),e[21]=r,e[22]=c,e[23]=f):f=e[23];let p;return e[24]!==l||e[25]!==u||e[26]!==f?(p=(0,C.jsxs)(`div`,{className:l,children:[u,f]}),e[24]=l,e[25]=u,e[26]=f,e[27]=p):p=e[27],p}function V(e){return e.language}export{B as SettingsPage};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./loader-circle-CifKLtgG.js";import{t as o}from"./cn-JdwAhgNB.js";import{n as s}from"./interaction-BmQogeqz.js";import{t as c}from"./messages-D7kOD_o_.js";import{l,n as u,r as d,s as f}from"./locale-store-CnamlR07.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{r as m}from"./gateway-config-swr-Cv2ywpdb.js";import{Ac as h,At as g,Da as _,Gn as v,Ht as y,Ko as b,Ls as ee,Ol as x,Ql as S,Tl as C,Ut as w,_l as T,_s as E,cs as D,vl as O}from"./index-DRrjYYzZ.js";import{n as k,r as A}from"./settings-page-layout-BRQNel6r.js";import{n as j}from"./settings-loading-skeleton-zwibve4m.js";import{n as M,t as N}from"./settings-form-section-C7w2WS-A.js";var P=e(t(),1),F=n();function I(e){if(!e||typeof e!=`object`)return 0;let t=e.providers;return!t||typeof t!=`object`||Array.isArray(t)?0:Object.values(t).filter(e=>typeof e==`string`&&b(e)).length}function L(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t,r=typeof n.defaultPreset==`string`&&n.defaultPreset.trim()?n.defaultPreset.trim():`default`,i=n.capabilityPresets,a=i&&typeof i==`object`&&!Array.isArray(i)?i[r]:void 0,o=a&&typeof a==`object`&&!Array.isArray(a)?a.models:void 0;if(!o||typeof o!=`object`||Array.isArray(o))return``;let s=o,c=s.roles;if(!c||typeof c!=`object`||Array.isArray(c))return``;let l=c,u=typeof s.defaultRole==`string`&&s.defaultRole.trim()?s.defaultRole.trim():Object.keys(l)[0],d=u?l[u]:void 0;if(!d||typeof d!=`object`||Array.isArray(d))return``;let f=d.model;return typeof f==`string`?f.trim():``}function R(e){if(!e||typeof e!=`object`)return!1;let t=e.channels;return!t||typeof t!=`object`||Array.isArray(t)?!1:Object.values(t).some(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(`configured`in t||`config`in t||`schema`in t||`uiHints`in t){if(t.configured===!0)return!0;let e=t.config;if(!e||typeof e!=`object`||Array.isArray(e))return!1;let n=e;return n.enabled===!0||Object.keys(n).length>0}return t.enabled===!0||Object.keys(t).length>0})}function z(e){if(!e||typeof e!=`object`)return{enabled:!1,backend:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,backend:`extension`};let n=t;return{enabled:n.enabled===!0,backend:typeof n.backend==`string`&&n.backend.trim()?n.backend.trim():`extension`}}function B(e){return e?`pass`:`fail`}function V(e){if(e===`provider-auth`)return`/settings/capabilities/models`;if(e===`config-health`)return`/settings/gateway`;if(e===`state-integrity`||e===`workspace-status`)return`/agents`;if(e===`database-schema`||e===`session-integrity`)return`/settings/sessions`;if(e===`channel-config`||e===`channel-pairing-pending`||e.startsWith(`channel:`))return`/channels`;if(e===`security-audit`||e===`gateway-service`||e===`gateway-health`)return`/settings/gateway`;if(e===`version-check`)return`/settings/desktop-app`}function H(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function te(e){return e.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>({id:e.id,label:e.label,status:e.status,message:e.message,hints:e.hints,path:V(e.id),source:`doctor`})).toSorted((e,t)=>H(t.status)-H(e.status)||e.label.localeCompare(t.label))}function U(e){let t=new Map(e.doctorChecks.map(e=>[e.id,e])),n=[];for(let e of[`security-audit`,`channel-config`,`channel-pairing-pending`,`gateway-health`]){let r=t.get(e);r&&n.push({id:r.id,label:r.label,status:r.status,message:r.message,path:V(r.id)})}if(e.logsHealth){let t=e.logsHealth.stats?.errorsLast24h??0;n.push({id:`logs-health`,label:`Logs`,status:e.logsHealth.shuttingDown||t>0?`warn`:`pass`,message:e.logsHealth.shuttingDown?`Logger is shutting down.`:t>0?`${t} error(s) in the last 24 hours.`:`Log system is healthy.`,path:`/settings/logs`})}for(let t of e.browserDiagnostics??[])n.push(t);return n}function ne(e){let t=I(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=L(e.config),o=a.length>0,s=e.hasToken&&e.realtimeConnected,c=R(e.config),l=e.skillCount>0,u=e.doctorChecks??[],d=te(u),f=[{id:`gateway`,done:s,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline},{id:`provider`,done:i,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing},{id:`defaultModel`,done:o,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing},{id:`channel`,done:c,optional:!0,detail:c?e.labels.channelConfigured:e.labels.channelMissing},{id:`skill`,done:l,optional:!0,detail:l?e.labels.skillsConfigured(e.skillCount):e.labels.skillsMissing}],p=f.filter(e=>!e.optional).every(e=>e.done),m=f.every(e=>e.done),h=[{id:`gateway`,status:B(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:B(i),title:`Model provider`,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing,path:`/settings/capabilities/models`},{id:`defaultModel`,status:B(o),title:`Default model`,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing,path:`/settings/capabilities/models`},{id:`ready`,status:p?`pass`:`fail`,title:`Chat readiness`,detail:p?e.labels.readyToChat:e.labels.modelMissing,path:`/chat`}],g=d.some(e=>e.status===`fail`),_=d.some(e=>e.status===`warn`),v=g?`blocked`:_?`attention`:p?`ready`:`setup`,y=U({doctorChecks:u,logsHealth:e.logsHealth,browserDiagnostics:e.browserDiagnostics});return{gatewayConnected:s,providerConfigured:i,providerCount:t,providerMetaConfigured:n,providerMetaTotal:r,defaultModel:a,defaultModelConfigured:o,channelConfigured:c,skillInstalled:l,skillCount:e.skillCount,checklist:f,readiness:h,issues:d,healthTier:v,diagnosticSignals:y,requiredComplete:p,allComplete:m}}function re(e){return z(e)}function W(e){return!e.id||!e.label||!e.status||!e.message||![`pass`,`warn`,`fail`,`skip`].includes(e.status)?null:{id:e.id,label:e.label,status:e.status,message:e.message,hints:Array.isArray(e.hints)?e.hints.filter(e=>typeof e==`string`):[],fixed:e.fixed===!0,findings:Array.isArray(e.findings)?e.findings:void 0}}function ie(){return d(`/api/doctor`)}async function ae(){return((await f(ie())).checks??[]).map(W).filter(e=>e!==null)}function oe(){return d(`/api/logs/health`)}async function se(){return f(oe())}function G(e){return e?`pass`:`warn`}function K(e){return`/settings/agent-browser?tab=${encodeURIComponent(e)}`}function ce(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function q(e){if(!e.enabled)return[];if(e.backend===`local`){let e=await f(d(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:G(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:K(`local`)}]}if(e.backend===`cloakbrowser`){let e=await f(d(`/api/browser/cloakbrowser/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-cloakbrowser`,label:`Browser: CloakBrowser`,status:G(t),message:t?`CloakBrowser ${e.payload?.version??``}`.trim():`CloakBrowser is not installed.`,path:K(`cloakbrowser`)}]}if(e.backend===`extension`){let e=await f(d(`/api/browser/extension-status?probe=true`)),t=e.artifacts?.installed===!0,n=e.connected===!0,r=e.artifacts?.needsRefresh===!0||e.artifacts?.needsChromeReload===!0;return[{id:`browser-extension`,label:`Browser: Chrome extension`,status:n?`pass`:`warn`,message:n?`Chrome extension bridge is connected.`:t?r?`Chrome extension needs refresh.`:`Chrome extension is installed but not connected.`:`Chrome extension is not installed.`,path:K(`extension`)}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser backend "${e.backend}" is not checked on this overview.`,path:K(e.backend||`overview`)}]}function J(){let e=(0,F.c)(57),t=l(me),n=u(pe),r;e[0]===n?r=e[1]:(r=c(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,o=_(fe),{data:s,error:d,isLoading:f,mutate:h}=m(!!t),v;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},e[2]=v):v=e[2];let{data:b,error:ee,isLoading:x,mutate:S}=p(t?`setup-checklist-skills`:null,de,v),C;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(C={revalidateOnFocus:!1},e[3]=C):C=e[3];let{data:T,error:E,isLoading:D,mutate:O}=p(t?`setup-checklist-provider-meta`:null,g,C),k;e[4]===t?k=e[5]:(k=t?ie():null,e[4]=t,e[5]=k);let A;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1},e[6]=A):A=e[6];let{data:j,error:M,isLoading:N,mutate:P}=p(k,ae,A),I;e[7]===t?I=e[8]:(I=t?oe():null,e[7]=t,e[8]=I);let L;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(L={revalidateOnFocus:!1},e[9]=L):L=e[9];let{data:R,isLoading:z,mutate:B}=p(I,se,L);s?.payload?.config;let V=s?.payload?.config,H;e[10]===V?H=e[11]:(H=re(V),e[10]=V,e[11]=H);let te=t?H:null,U;e[12]===te?U=e[13]:(U=ce(te),e[12]=te,e[13]=U);let W;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(W={revalidateOnFocus:!1},e[14]=W):W=e[14];let{data:G,isLoading:K,mutate:q}=p(U,ue,W),J;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(J={revalidateOnFocus:!1},e[15]=J):J=e[15],p(t?y:null,w,J);let Y=!t||!f&&!x&&!D&&!N&&!z&&!K,X=!!(d||ee||E||M),Z;bb0:{if(!t||!Y){Z=null;break bb0}let n=b?.catalog?.length??0,r;if(e[16]!==G||e[17]!==s?.payload?.config||e[18]!==j||e[19]!==a.channelConfigured||e[20]!==a.channelMissing||e[21]!==a.gatewayOffline||e[22]!==a.gatewayOnline||e[23]!==a.modelConfigured||e[24]!==a.modelMissing||e[25]!==a.providersConfigured||e[26]!==a.providersMetaReady||e[27]!==a.providersMissing||e[28]!==a.skillsConfigured||e[29]!==a.skillsMissing||e[30]!==R||e[31]!==i.setupStatus.requiredCompleteMessage||e[32]!==T||e[33]!==o||e[34]!==n||e[35]!==t){let c=T?.filter(le).length??0,l=T?.length??0,u;e[37]===a.providersConfigured?u=e[38]:(u=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[37]=a.providersConfigured,e[38]=u);let d;e[39]===a.providersMetaReady?d=e[40]:(d=(e,t)=>a.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[39]=a.providersMetaReady,e[40]=d);let f;e[41]===a.modelConfigured?f=e[42]:(f=e=>a.modelConfigured.replace(`{{model}}`,e),e[41]=a.modelConfigured,e[42]=f);let p;e[43]===a.skillsConfigured?p=e[44]:(p=e=>a.skillsConfigured.replace(`{{count}}`,String(e)),e[43]=a.skillsConfigured,e[44]=p),r=ne({hasToken:!!t,realtimeConnected:o,config:s?.payload?.config,skillCount:n,providerMeta:l>0?{configured:c,total:l}:null,doctorChecks:j,logsHealth:R,browserDiagnostics:G,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:u,providersMetaReady:d,providersMissing:a.providersMissing,modelConfigured:f,modelMissing:a.modelMissing,channelConfigured:a.channelConfigured,channelMissing:a.channelMissing,skillsConfigured:p,skillsMissing:a.skillsMissing,readyToChat:i.setupStatus.requiredCompleteMessage}}),e[16]=G,e[17]=s?.payload?.config,e[18]=j,e[19]=a.channelConfigured,e[20]=a.channelMissing,e[21]=a.gatewayOffline,e[22]=a.gatewayOnline,e[23]=a.modelConfigured,e[24]=a.modelMissing,e[25]=a.providersConfigured,e[26]=a.providersMetaReady,e[27]=a.providersMissing,e[28]=a.skillsConfigured,e[29]=a.skillsMissing,e[30]=R,e[31]=i.setupStatus.requiredCompleteMessage,e[32]=T,e[33]=o,e[34]=n,e[35]=t,e[36]=r}else r=e[36];Z=r}let he=Z,Q;e[45]!==q||e[46]!==h||e[47]!==P||e[48]!==B||e[49]!==O||e[50]!==S?(Q=async()=>{await Promise.all([h(),S(),O(),P(),B(),q()])},e[45]=q,e[46]=h,e[47]=P,e[48]=B,e[49]=O,e[50]=S,e[51]=Q):Q=e[51];let ge=Q,$;return e[52]!==X||e[53]!==Y||e[54]!==ge||e[55]!==he?($={ready:Y,error:X,snapshot:he,refresh:ge},e[52]=X,e[53]=Y,e[54]=ge,e[55]=he,e[56]=$):$=e[56],$}function le(e){return e.configured}function ue(e){let[,t]=e;return q(t)}function de(){return v()}function fe(e){return e.connectionState===`connected`}function pe(e){return e.language}function me(e){return e.token}var Y=r();function X(e){return e===`pass`?`border-success/30 bg-success-soft text-success`:e===`warn`?`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`fail`?`border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300`:`border-edge bg-surface-hover text-fg-muted`}function Z(e){return e===`pass`?C:e===`warn`?D:e===`fail`?O:h}function he(e,t){return e===`blocked`?{icon:O,className:`bg-red-500/10 text-red-950 dark:text-red-100`,title:t.health.blockedTitle,body:t.health.blockedBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`attention`?{icon:D,className:`bg-amber-500/10 text-amber-950 dark:text-amber-100`,title:t.health.attentionTitle,body:t.health.attentionBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`setup`?{icon:T,className:`bg-surface-base text-fg shadow-surface`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:C,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function Q(e){let t=(0,F.c)(48),{tier:n,issueCount:r,onRunDoctor:l,ready:d,doctorRunning:f,doctorRunState:p}=e,m=u(ge),h,g,_,v,y,b,S,C,w,T,E;if(t[0]!==r||t[1]!==m||t[2]!==n){g=c(m).setupStatus;let e=he(n,g),a=e.icon,s=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,l=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;h=s?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(s)?.scrollIntoView({block:`start`,behavior:`smooth`}),className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,Y.jsx)(x,{className:`size-4`,"aria-hidden":!0})]}):(0,Y.jsxs)(i,{to:l,className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,Y.jsx)(x,{className:`size-4`,"aria-hidden":!0})]}),E=o(`rounded-xl p-4`,e.className),T=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,C=`flex min-w-0 gap-3`,w=(0,Y.jsx)(a,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),y=`min-w-0`,b=(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),S=(0,Y.jsx)(`p`,{className:`mt-1 text-sm opacity-85`,children:e.body}),_=`mt-2 text-xs opacity-75`,v=g.health.issueCount.replace(`{{count}}`,String(r)),t[0]=r,t[1]=m,t[2]=n,t[3]=h,t[4]=g,t[5]=_,t[6]=v,t[7]=y,t[8]=b,t[9]=S,t[10]=C,t[11]=w,t[12]=T,t[13]=E}else h=t[3],g=t[4],_=t[5],v=t[6],y=t[7],b=t[8],S=t[9],C=t[10],w=t[11],T=t[12],E=t[13];let D;t[14]!==_||t[15]!==v?(D=(0,Y.jsx)(`p`,{className:_,children:v}),t[14]=_,t[15]=v,t[16]=D):D=t[16];let O;t[17]!==D||t[18]!==y||t[19]!==b||t[20]!==S?(O=(0,Y.jsxs)(`div`,{className:y,children:[b,S,D]}),t[17]=D,t[18]=y,t[19]=b,t[20]=S,t[21]=O):O=t[21];let k;t[22]!==O||t[23]!==C||t[24]!==w?(k=(0,Y.jsxs)(`div`,{className:C,children:[w,O]}),t[22]=O,t[23]=C,t[24]=w,t[25]=k):k=t[25];let A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=o(`inline-flex items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,s.press),t[26]=A):A=t[26];let j=!d||f,M;t[27]===f?M=t[28]:(M=f?(0,Y.jsx)(a,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[27]=f,t[28]=M);let N=f?g.health.runDoctorRunning:g.health.runDoctor,P;t[29]!==f||t[30]!==l||t[31]!==j||t[32]!==M||t[33]!==N?(P=(0,Y.jsxs)(`button`,{type:`button`,className:A,onClick:l,disabled:j,"aria-busy":f,children:[M,N]}),t[29]=f,t[30]=l,t[31]=j,t[32]=M,t[33]=N,t[34]=P):P=t[34];let I;t[35]!==h||t[36]!==P?(I=(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[h,P]}),t[35]=h,t[36]=P,t[37]=I):I=t[37];let L;t[38]!==k||t[39]!==I||t[40]!==T?(L=(0,Y.jsxs)(`div`,{className:T,children:[k,I]}),t[38]=k,t[39]=I,t[40]=T,t[41]=L):L=t[41];let R=f?g.health.doctorRunningMessage:p===`success`?g.health.doctorCompleteMessage:p===`error`?g.health.doctorFailedMessage:g.health.doctorIdleMessage,z;t[42]===R?z=t[43]:(z=(0,Y.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:R}),t[42]=R,t[43]=z);let B;return t[44]!==L||t[45]!==z||t[46]!==E?(B=(0,Y.jsxs)(`section`,{className:E,children:[L,z]}),t[44]=L,t[45]=z,t[46]=E,t[47]=B):B=t[47],B}function ge(e){return e.language}function $(e){let t=(0,F.c)(34),{issue:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let s=a,c;t[2]===s?c=t[3]:(c=(0,Y.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=s,t[3]=c);let l;t[4]===n.label?l=t[5]:(l=(0,Y.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=l);let u;t[6]===n.status?u=t[7]:(u=o(`rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,X(n.status)),t[6]=n.status,t[7]=u);let d;t[8]!==n.status||t[9]!==u?(d=(0,Y.jsx)(`span`,{className:u,children:n.status}),t[8]=n.status,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==l||t[12]!==d?(f=(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13];let p;t[14]===n.message?p=t[15]:(p=(0,Y.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[14]=n.message,t[15]=p);let m;t[16]===n.hints[0]?m=t[17]:(m=n.hints[0]?(0,Y.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[16]=n.hints[0],t[17]=m);let h;t[18]!==f||t[19]!==p||t[20]!==m?(h=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[18]=f,t[19]=p,t[20]=m,t[21]=h):h=t[21];let g;t[22]!==r||t[23]!==n.path?(g=n.path?(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,Y.jsx)(x,{className:`size-4`,"aria-hidden":!0})]}):null,t[22]=r,t[23]=n.path,t[24]=g):g=t[24];let _;t[25]!==g||t[26]!==c||t[27]!==h?(_=(0,Y.jsxs)(Y.Fragment,{children:[c,h,g]}),t[25]=g,t[26]=c,t[27]=h,t[28]=_):_=t[28];let v=_;if(n.path){let e;return t[29]!==v||t[30]!==n.path?(e=(0,Y.jsx)(i,{to:n.path,className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:v}),t[29]=v,t[30]=n.path,t[31]=e):e=t[31],e}let y;return t[32]===v?y=t[33]:(y=(0,Y.jsx)(`div`,{className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`,children:v}),t[32]=v,t[33]=y),y}function _e(e){let t=(0,F.c)(27),{item:n,labels:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let s=a,c=r[n.id]??n.title,l;t[2]===n.status?l=t[3]:(l=o(`flex size-7 shrink-0 items-center justify-center rounded-full border`,X(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===s?u=t[5]:(u=(0,Y.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t[4]=s,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,Y.jsx)(`span`,{className:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===c?f=t[10]:(f=(0,Y.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:c}),t[9]=c,t[10]=f);let p;t[11]===n.detail?p=t[12]:(p=(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.detail}),t[11]=n.detail,t[12]=p);let m;t[13]!==f||t[14]!==p?(m=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p]}),t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===n.path?h=t[17]:(h=n.path?(0,Y.jsx)(x,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=h);let g;t[18]!==d||t[19]!==m||t[20]!==h?(g=(0,Y.jsxs)(Y.Fragment,{children:[d,m,h]}),t[18]=d,t[19]=m,t[20]=h,t[21]=g):g=t[21];let _=g;if(n.path){let e;return t[22]!==_||t[23]!==n.path?(e=(0,Y.jsx)(i,{to:n.path,className:`flex items-center gap-3 rounded-lg p-3 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:_}),t[22]=_,t[23]=n.path,t[24]=e):e=t[24],e}let v;return t[25]===_?v=t[26]:(v=(0,Y.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:_}),t[25]=_,t[26]=v),v}function ve(e){let t=(0,F.c)(29),{signal:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let s=a,c;t[2]===s?c=t[3]:(c=(0,Y.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=s,t[3]=c);let l;t[4]===n.label?l=t[5]:(l=(0,Y.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=l);let u;t[6]===n.message?u=t[7]:(u=(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=u);let d;t[8]!==l||t[9]!==u?(d=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10];let f;t[11]===n.status?f=t[12]:(f=o(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,X(n.status)),t[11]=n.status,t[12]=f);let p;t[13]!==n.status||t[14]!==f?(p=(0,Y.jsx)(`span`,{className:f,children:n.status}),t[13]=n.status,t[14]=f,t[15]=p):p=t[15];let m;t[16]!==r||t[17]!==n.path?(m=n.path?(0,Y.jsx)(`span`,{className:`sr-only`,children:r}):null,t[16]=r,t[17]=n.path,t[18]=m):m=t[18];let h;t[19]!==c||t[20]!==d||t[21]!==p||t[22]!==m?(h=(0,Y.jsxs)(Y.Fragment,{children:[c,d,p,m]}),t[19]=c,t[20]=d,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g=h;if(n.path){let e;return t[24]!==g||t[25]!==n.path?(e=(0,Y.jsx)(i,{to:n.path,className:`flex min-w-0 items-start gap-2 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:g}),t[24]=g,t[25]=n.path,t[26]=e):e=t[26],e}let _;return t[27]===g?_=t[28]:(_=(0,Y.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:g}),t[27]=g,t[28]=_),_}function ye(){let e=c(u(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=J(),[a,l]=(0,P.useState)(!1),[d,f]=(0,P.useState)(`idle`),p=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],m=async()=>{if(!(a||!t)){l(!0),f(`idle`);try{await i(),f(`success`)}catch{f(`error`)}finally{l(!1)}}};return(0,Y.jsxs)(A,{gap:`gap-6`,children:[(0,Y.jsx)(k,{title:e.title,subtitle:e.subtitle,actions:(0,Y.jsxs)(`button`,{type:`button`,className:o(`inline-flex shrink-0 items-center gap-2 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,s.press),onClick:()=>void m(),disabled:!t||a,"aria-busy":a,children:[(0,Y.jsx)(ee,{className:o(`size-4`,(!t||a)&&`animate-spin`),"aria-hidden":!0}),a?e.health.runDoctorRunning:e.refresh]})}),n?(0,Y.jsx)(`p`,{className:`rounded-xl border border-red-300/40 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:e.loadError}):null,!t||!r?(0,Y.jsx)(j,{sections:2}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void m(),doctorRunning:a,doctorRunState:d}),(0,Y.jsxs)(N,{id:`next-steps`,children:[(0,Y.jsx)(M,{icon:r.issues.length?D:S,title:e.nextStepsTitle,subtitle:r.issues.length?e.nextStepsIssuesSubtitle:e.nextStepsReadySubtitle}),r.issues.length?(0,Y.jsx)(`div`,{className:`mt-4 flex flex-col gap-2`,children:r.issues.slice(0,8).map(t=>(0,Y.jsx)($,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,Y.jsx)(`div`,{className:`mt-4 rounded-lg bg-surface-panel/80 shadow-surface`,children:r.readiness.map(t=>(0,Y.jsx)(_e,{item:t,labels:e.readinessLabels},t.id))})]}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(M,{icon:E,title:e.diagnosticsTitle,subtitle:e.diagnosticsSubtitle}),p.length?(0,Y.jsx)(`div`,{className:`mt-4 grid gap-2 md:grid-cols-2`,children:p.map(t=>(0,Y.jsx)(ve,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,Y.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-panel/80 p-3 text-sm text-fg-muted shadow-surface`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})]})]})}export{ye as SetupStatusPanel};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-B2_kr5EA.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-zJ_50EbN.js","assets/excel-worksheet-utils-EyvwNT4X.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./preload-helper-zJ_50EbN.js";import{d as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./external-link-DjqjBmc3.js";import{n as o,r as s}from"./locale-store-xULEcFVs.js";import{Aa as c,Ea as l,Ei as u,Oi as d,bi as f,ki as p,nl as m}from"./index-CGbKTCST.js";var h=e(t(),1),g=n();function _(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function v(){let{token:e}=i(),t=o(e=>e.language),n=t===`zh`?b:x,[v,S]=(0,h.useState)(null),[C,w]=(0,h.useState)(_),[T,E]=(0,h.useState)(!0),[D,O]=(0,h.useState)(null),k=(0,h.useMemo)(()=>{if(!v||!e||v.kind!==`file`)return null;let t=d(v.fileName,v.mimeType);return{id:`share:${e}:${v.fileName}`,context:`share`,fileName:v.fileName,mimeType:t,size:v.fileSize,type:u(v.fileName,t),source:{kind:`share`,token:e}}},[v,e]);(0,h.useEffect)(()=>{if(!e){O(n.invalidLink),E(!1);return}let t=!1;return(async()=>{try{E(!0),O(null),w(_());let i=await fetch(s(`/s/${encodeURIComponent(e)}/meta`));if(!i.ok){t||O(i.status===404?n.notFound:n.expired);return}let a=await i.json();if(t)return;if(S(a),!a.valid){O(n.expired);return}if(a.kind!==`file`)return;let o=d(a.fileName,a.mimeType),c=u(a.fileName,o),f=p(c),m=s(`/s/${encodeURIComponent(e)}?inline=1`);if(f===`text`){if(a.fileSize>5242880){O(n.tooLarge);return}let e=await fetch(m);if(!e.ok){O(n.expired);return}let r=await e.text();t||w({..._(),textContent:r});return}if(f===`binary`){if(a.fileSize>33554432){O(n.tooLarge);return}let e=await fetch(m);if(!e.ok){O(n.expired);return}let i=await e.arrayBuffer();if(t)return;if(c===`pptx`){let{processPptx:e}=await r(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-B2_kr5EA.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(i,a.fileName),n=t.length>l;w({textContent:null,binaryBuffer:i,extractedText:n?t.slice(0,l):t,extractedTextTruncated:n});return}w({..._(),binaryBuffer:i})}}catch(e){t||O(e instanceof Error?e.message:String(e))}finally{t||E(!1)}})(),()=>{t=!0}},[e,n.expired,n.invalidLink,n.notFound,n.tooLarge]);let A=e?s(`/s/${encodeURIComponent(e)}?dl=1`):`#`,j=e?s(`/s/${encodeURIComponent(e)}?inline=1`):`#`;return(0,g.jsxs)(`div`,{className:`flex min-h-screen flex-col bg-surface-base`,children:[(0,g.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-edge px-4`,children:[(0,g.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:`#`}),(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v?(0,g.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:v.fileName,children:v.fileName}):T?(0,g.jsx)(c,{className:`h-4 w-48 max-w-full`}):(0,g.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:n.error}),v?(0,g.jsxs)(`div`,{className:`truncate text-xs text-fg-muted`,children:[y(v.fileSize),` · `,n.expiresAt,` `,new Date(v.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}):null]}),v?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`a`,{href:j,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[(0,g.jsx)(a,{className:`size-3.5`,"aria-hidden":!0}),n.openInline]}),(0,g.jsxs)(`a`,{href:A,className:`inline-flex items-center gap-1 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white hover:opacity-90`,download:v.fileName,children:[(0,g.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),n.download]})]}):null]}),(0,g.jsx)(`main`,{className:`flex min-h-0 w-full flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,children:T?(0,g.jsxs)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel p-4 shadow-surface`,"aria-busy":`true`,children:[(0,g.jsx)(c,{className:`h-5 w-56 max-w-full`}),(0,g.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,g.jsx)(c,{className:`h-4 w-full`}),(0,g.jsx)(c,{className:`h-4 w-11/12`}),(0,g.jsx)(c,{className:`h-4 w-10/12`}),(0,g.jsx)(c,{className:`h-4 w-3/4`})]}),(0,g.jsx)(c,{className:`mt-6 min-h-0 flex-1 rounded-lg`})]}):D?(0,g.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg`,children:[(0,g.jsx)(`p`,{className:`font-medium`,children:n.error}),(0,g.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:D})]}):v?.kind===`directory`?(0,g.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg-muted`,children:n.directoryHint}):k?(0,g.jsx)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:(0,g.jsx)(f,{language:t,descriptor:k,loading:!1,loadError:null,textContent:C.textContent,binaryBuffer:C.binaryBuffer,extractedText:C.extractedText,extractedTextTruncated:C.extractedTextTruncated,actions:{onDownload:()=>{window.location.href=A},canDownload:!0}})}):null})]})}function y(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}var b={error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,download:`下载`,openInline:`在新窗口打开`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`},x={error:`Failed to load`,expired:`Link no longer valid`,notFound:`Link not found`,invalidLink:`Invalid link`,expiresAt:`Expires`,download:`Download`,openInline:`Open raw`,directoryHint:`Directory shares are browsed from the main page.`,tooLarge:`This file is too large to preview here. Please download it instead.`};export{v as SharePreviewPage};
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./preload-helper-zJ_50EbN.js";import{d as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./external-link-DjqjBmc3.js";import{n as o,r as s}from"./locale-store-CnamlR07.js";import{Ci as c,Mi as l,Na as u,al as d,ji as f,ka as p,ki as m}from"./index-DRrjYYzZ.js";var h=e(t(),1),g=n();function _(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function v(){let{token:e}=i(),t=o(e=>e.language),n=t===`zh`?b:x,[v,S]=(0,h.useState)(null),[C,w]=(0,h.useState)(_),[T,E]=(0,h.useState)(!0),[D,O]=(0,h.useState)(null),k=(0,h.useMemo)(()=>{if(!v||!e||v.kind!==`file`)return null;let t=f(v.fileName,v.mimeType);return{id:`share:${e}:${v.fileName}`,context:`share`,fileName:v.fileName,mimeType:t,size:v.fileSize,type:m(v.fileName,t),source:{kind:`share`,token:e}}},[v,e]);(0,h.useEffect)(()=>{if(!e){O(n.invalidLink),E(!1);return}let t=!1;return(async()=>{try{E(!0),O(null),w(_());let i=await fetch(s(`/s/${encodeURIComponent(e)}/meta`));if(!i.ok){t||O(i.status===404?n.notFound:n.expired);return}let a=await i.json();if(t)return;if(S(a),!a.valid){O(n.expired);return}if(a.kind!==`file`)return;let o=f(a.fileName,a.mimeType),c=m(a.fileName,o),u=l(c),d=s(`/s/${encodeURIComponent(e)}?inline=1`);if(u===`text`){if(a.fileSize>5242880){O(n.tooLarge);return}let e=await fetch(d);if(!e.ok){O(n.expired);return}let r=await e.text();t||w({..._(),textContent:r});return}if(u===`binary`){if(a.fileSize>33554432){O(n.tooLarge);return}let e=await fetch(d);if(!e.ok){O(n.expired);return}let i=await e.arrayBuffer();if(t)return;if(c===`pptx`){let{processPptx:e}=await r(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-B2_kr5EA.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(i,a.fileName),n=t.length>p;w({textContent:null,binaryBuffer:i,extractedText:n?t.slice(0,p):t,extractedTextTruncated:n});return}w({..._(),binaryBuffer:i})}}catch(e){t||O(e instanceof Error?e.message:String(e))}finally{t||E(!1)}})(),()=>{t=!0}},[e,n.expired,n.invalidLink,n.notFound,n.tooLarge]);let A=e?s(`/s/${encodeURIComponent(e)}?dl=1`):`#`,j=e?s(`/s/${encodeURIComponent(e)}?inline=1`):`#`;return(0,g.jsxs)(`div`,{className:`flex min-h-screen flex-col bg-surface-base`,children:[(0,g.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-edge px-4`,children:[(0,g.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:`#`}),(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v?(0,g.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:v.fileName,children:v.fileName}):T?(0,g.jsx)(u,{className:`h-4 w-48 max-w-full`}):(0,g.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:n.error}),v?(0,g.jsxs)(`div`,{className:`truncate text-xs text-fg-muted`,children:[y(v.fileSize),` · `,n.expiresAt,` `,new Date(v.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}):null]}),v?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`a`,{href:j,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[(0,g.jsx)(a,{className:`size-3.5`,"aria-hidden":!0}),n.openInline]}),(0,g.jsxs)(`a`,{href:A,className:`inline-flex items-center gap-1 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white hover:opacity-90`,download:v.fileName,children:[(0,g.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),n.download]})]}):null]}),(0,g.jsx)(`main`,{className:`flex min-h-0 w-full flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,children:T?(0,g.jsxs)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel p-4 shadow-surface`,"aria-busy":`true`,children:[(0,g.jsx)(u,{className:`h-5 w-56 max-w-full`}),(0,g.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,g.jsx)(u,{className:`h-4 w-full`}),(0,g.jsx)(u,{className:`h-4 w-11/12`}),(0,g.jsx)(u,{className:`h-4 w-10/12`}),(0,g.jsx)(u,{className:`h-4 w-3/4`})]}),(0,g.jsx)(u,{className:`mt-6 min-h-0 flex-1 rounded-lg`})]}):D?(0,g.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg`,children:[(0,g.jsx)(`p`,{className:`font-medium`,children:n.error}),(0,g.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:D})]}):v?.kind===`directory`?(0,g.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg-muted`,children:n.directoryHint}):k?(0,g.jsx)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:(0,g.jsx)(c,{language:t,descriptor:k,loading:!1,loadError:null,textContent:C.textContent,binaryBuffer:C.binaryBuffer,extractedText:C.extractedText,extractedTextTruncated:C.extractedTextTruncated,actions:{onDownload:()=>{window.location.href=A},canDownload:!0}})}):null})]})}function y(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}var b={error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,download:`下载`,openInline:`在新窗口打开`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`},x={error:`Failed to load`,expired:`Link no longer valid`,notFound:`Link not found`,invalidLink:`Invalid link`,expiresAt:`Expires`,download:`Download`,openInline:`Open raw`,directoryHint:`Directory shares are browsed from the main page.`,tooLarge:`This file is too large to preview here. Please download it instead.`};export{v as SharePreviewPage};