@xopcai/xopc 0.0.205 → 0.0.206

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 (151) 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-DJBadfSX.js → activity-store-URW-e_me.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Br6C32BX.js → agent-avatar-dicebear-BLK6kRCJ.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-D5HVmdNx.js +68 -0
  6. package/dist/gateway/static/root/assets/{api-B5O7fKXa.js → api-C_MS4arC.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-Le1vJ1OO.js → app-management-settings-panel-CnUN6BJk.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-CZlAU60t.js → appearance-settings-C8Nx8hZE.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-DKCA_LFY.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-CRzXRXPE.js → archive-plugin-C7FqeJZD.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-CYAAQ6Qi.js → attachment-load-DCYQgsYE.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-page-BEOE4ZKM.js +6 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-CVR5cUmS.js → binary-plugins-Bf1WROsh.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-CFe74rWi.js → block-editor-BPK08Pjv.js} +46 -46
  15. package/dist/gateway/static/root/assets/browser-settings-page-CLRmMdU9.js +8 -0
  16. package/dist/gateway/static/root/assets/{browser-workflow-inputs-Bd68yluo.js → browser-workflow-inputs-cqVoDHyp.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflows-page-B0uiDLga.js → browser-workflows-page-Des1UTsS.js} +2 -2
  18. package/dist/gateway/static/root/assets/capabilities-settings-panel-BNcVi4ar.js +7 -0
  19. package/dist/gateway/static/root/assets/{capability-presets-api-BerPMp6f.js → capability-presets-api-D4MjqV2a.js} +1 -1
  20. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-DJjVOCJY.js → capability-presets-settings-panel-uFwW2ah5.js} +2 -2
  21. package/dist/gateway/static/root/assets/{channel-recipient-api-D2d21_XA.js → channel-recipient-api-CcimZduy.js} +1 -1
  22. package/dist/gateway/static/root/assets/channels-settings-DSLP8OjS.js +1 -0
  23. package/dist/gateway/static/root/assets/channels-status-swr-D0OR6Ylw.js +1 -0
  24. package/dist/gateway/static/root/assets/chat-terminal-dock-B1njb2Cr.css +1 -0
  25. package/dist/gateway/static/root/assets/chat-terminal-dock-wpi7abPg.js +38 -0
  26. package/dist/gateway/static/root/assets/{connectors-api-Bq_vUzxP.js → connectors-api-CUvFu8jh.js} +1 -1
  27. package/dist/gateway/static/root/assets/connectors-page-BJoHjWnu.js +2 -0
  28. package/dist/gateway/static/root/assets/{cron-expression-DZBxmKGR.js → cron-expression-hFSZZpvM.js} +1 -1
  29. package/dist/gateway/static/root/assets/{date-picker-BNHd7HT7.js → date-picker-CKZ0gc-Y.js} +1 -1
  30. package/dist/gateway/static/root/assets/{dependency-picker-D1kJBknt.js → dependency-picker-zv1oHtg4.js} +1 -1
  31. package/dist/gateway/static/root/assets/{desktop-pet-Di75oHkC.js → desktop-pet-DY9ykMtD.js} +1 -1
  32. package/dist/gateway/static/root/assets/{desktop-pet-settings-D6tD1uym.js → desktop-pet-settings-XiSmmt26.js} +1 -1
  33. package/dist/gateway/static/root/assets/directory-picker-path-field-CZkgk15r.js +1 -0
  34. package/dist/gateway/static/root/assets/{extension-debug-page-D91_S7NQ.js → extension-debug-page-CTppsTEi.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-page-DHzmmr_N.js → extension-page-CHRTUvAa.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-settings-page-BpJNtePi.js → extension-settings-page-z2UBx25A.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-config-api-BAzLYTKZ.js → gateway-config-api-DzFPJTnm.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-config-swr-VVcfd3sG.js → gateway-config-swr-CGpoH1gU.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-settings-C5-aKkTp.js → gateway-settings-DBa2I6VM.js} +1 -1
  40. package/dist/gateway/static/root/assets/{gateway-startup-retry-qAX_T2t2.js → gateway-startup-retry-Te-TREBt.js} +1 -1
  41. package/dist/gateway/static/root/assets/heartbeat-settings-DyQGGdBu.js +1 -0
  42. package/dist/gateway/static/root/assets/home-page-EkT4eGeP.js +3 -0
  43. package/dist/gateway/static/root/assets/index-BpLqHdfz.css +2 -0
  44. package/dist/gateway/static/root/assets/index-CrwXzRpA.js +85 -0
  45. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-fpNjXnJK.js → keyboard-shortcuts-settings-fb0zS8pk.js} +1 -1
  46. package/dist/gateway/static/root/assets/local-app-workbench-page-CCC3Cvb8.js +2 -0
  47. package/dist/gateway/static/root/assets/{local-apps-page-DBpQIfNd.js → local-apps-page-DFdheruU.js} +1 -1
  48. package/dist/gateway/static/root/assets/{locale-store-CbPVxonP.js → locale-store-CieddUjx.js} +1 -1
  49. package/dist/gateway/static/root/assets/{logs-page-BmXcJCKz.js → logs-page-B6jfkNDF.js} +2 -2
  50. package/dist/gateway/static/root/assets/{management-settings-CiK7Xkvi.js → management-settings-D3PsQ612.js} +1 -1
  51. package/dist/gateway/static/root/assets/{markdown-split-DVgpcOze.js → markdown-split-x5K52Thz.js} +1 -1
  52. package/dist/gateway/static/root/assets/{markdown-view-Dl-0_9JR.js → markdown-view-Cjjey5Y6.js} +1 -1
  53. package/dist/gateway/static/root/assets/{media-plugins-DMj1lW-n.js → media-plugins-DNtEkRAh.js} +1 -1
  54. package/dist/gateway/static/root/assets/messages-CySMn8WL.js +3 -0
  55. package/dist/gateway/static/root/assets/{notes-page-DvX1sTlf.js → notes-page-nWEqlwDw.js} +1 -1
  56. package/dist/gateway/static/root/assets/notes-workbench-QstkgWsW.js +4 -0
  57. package/dist/gateway/static/root/assets/{preview-open-alternatives-DvsLigha.js → preview-open-alternatives-CXcIKVi9.js} +1 -1
  58. package/dist/gateway/static/root/assets/{product-open-page-DbCraAI3.js → product-open-page-CZLJudPk.js} +1 -1
  59. package/dist/gateway/static/root/assets/project-detail-page-Cf1v94LO.js +1 -0
  60. package/dist/gateway/static/root/assets/projects-page-BRMZkNht.js +1 -0
  61. package/dist/gateway/static/root/assets/remote-access-hub-D55FTXZw.js +1 -0
  62. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DzuUglQo.js → runtime-tools-settings-panel-RYjduQV6.js} +1 -1
  63. package/dist/gateway/static/root/assets/{schema-form-plDnazVj.js → schema-form--1ZXg4qC.js} +1 -1
  64. package/dist/gateway/static/root/assets/sessions-page-C5Yy6eIn.js +1 -0
  65. package/dist/gateway/static/root/assets/settings-advanced-gate-BqO_8bUh.js +1 -0
  66. package/dist/gateway/static/root/assets/{settings-form-section-BwAxX_7e.js → settings-form-section-71-8j3zt.js} +1 -1
  67. package/dist/gateway/static/root/assets/{settings-loading-skeleton-B3OiTnF9.js → settings-loading-skeleton-C5Jn1l0q.js} +1 -1
  68. package/dist/gateway/static/root/assets/{settings-page-DvIWXBvp.js → settings-page-TYYGe6kZ.js} +1 -1
  69. package/dist/gateway/static/root/assets/{setup-status-panel-DThKKjLV.js → setup-status-panel-jA5I-17g.js} +1 -1
  70. package/dist/gateway/static/root/assets/{share-preview-page-CFnoGHJb.js → share-preview-page-BMUQIGfk.js} +1 -1
  71. package/dist/gateway/static/root/assets/shares-settings-Dru1a2rZ.js +1 -0
  72. package/dist/gateway/static/root/assets/skill-reload-api-C8iqS6kF.js +1 -0
  73. package/dist/gateway/static/root/assets/{skills-page-B38fY22S.js → skills-page-BzZT1SKg.js} +1 -1
  74. package/dist/gateway/static/root/assets/{skills-page.utils-vLIlk1c3.js → skills-page.utils-DnaBw5Ji.js} +1 -1
  75. package/dist/gateway/static/root/assets/{system-settings-panel-DRV2wljT.js → system-settings-panel-DqiPQgVI.js} +1 -1
  76. package/dist/gateway/static/root/assets/task-detail-page-DQP5vDr-.js +1 -0
  77. package/dist/gateway/static/root/assets/{theme-store-Bc_eRUev.js → theme-store-BP3_RpaY.js} +1 -1
  78. package/dist/gateway/static/root/assets/{use-autosave-DTu23D9J.js → use-autosave-BJkQ-vpu.js} +1 -1
  79. package/dist/gateway/static/root/assets/{user-context-page-DCwqzN03.js → user-context-page-BP8-sOPi.js} +1 -1
  80. package/dist/gateway/static/root/assets/{voice-api-key-field-CVDMesWc.js → voice-api-key-field-C6c8e7Mx.js} +1 -1
  81. package/dist/gateway/static/root/assets/{work-discovery-overlay-cyt93k0V.js → work-discovery-overlay-CCNjWKql.js} +1 -1
  82. package/dist/gateway/static/root/assets/work-discovery-page-DL_Ie0s2.js +1 -0
  83. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DrdcfX_N.js → workflow-run-setup-panel-DLO-dMSN.js} +2 -2
  84. package/dist/gateway/static/root/assets/workflows-page-B4-k2FHB.js +5 -0
  85. package/dist/gateway/static/root/assets/{working-directory-picker-modal-CYWdZUJ5.js → working-directory-picker-modal-vWi33CZJ.js} +1 -1
  86. package/dist/gateway/static/root/index.html +10 -10
  87. package/dist/package.js +1 -1
  88. package/dist/src/agent/agent-manager.d.ts +11 -0
  89. package/dist/src/agent/agent-manager.js +36 -6
  90. package/dist/src/agent/service.d.ts +4 -1
  91. package/dist/src/agent/service.js +12 -0
  92. package/dist/src/agent/tools/xopc-use-tool.js +6 -2
  93. package/dist/src/automations/api/routes.js +8 -0
  94. package/dist/src/automations/domain/index.js +2 -2
  95. package/dist/src/automations/domain/types.d.ts +17 -12
  96. package/dist/src/automations/domain/validation.d.ts +30 -32
  97. package/dist/src/automations/domain/validation.js +8 -10
  98. package/dist/src/automations/draft/automation-draft-prompt.js +9 -5
  99. package/dist/src/automations/draft/automation-draft-validator.d.ts +3 -8
  100. package/dist/src/automations/draft/automation-draft-validator.js +3 -3
  101. package/dist/src/automations/index.js +2 -2
  102. package/dist/src/automations/service/action-executor.js +13 -4
  103. package/dist/src/automations/service/automation-service.d.ts +5 -1
  104. package/dist/src/automations/service/automation-service.js +19 -12
  105. package/dist/src/automations/storage/automation-repository.js +8 -4
  106. package/dist/src/automations/storage/automation-run-repository.d.ts +5 -0
  107. package/dist/src/automations/storage/automation-run-repository.js +24 -8
  108. package/dist/src/automations/storage/index.js +2 -2
  109. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  110. package/dist/src/gateway/automation-agent-session.d.ts +4 -0
  111. package/dist/src/gateway/automation-agent-session.js +40 -0
  112. package/dist/src/gateway/dreaming-automation-reconciler.js +3 -2
  113. package/dist/src/gateway/hono/routes/commands-skills.js +36 -2
  114. package/dist/src/gateway/hono/routes/lazy-bundles.js +1 -0
  115. package/dist/src/gateway/service/marketplace-service.d.ts +4 -1
  116. package/dist/src/gateway/service/marketplace-service.js +9 -0
  117. package/dist/src/gateway/service.js +19 -2
  118. package/dist/src/mobile/notification-service.js +7 -4
  119. package/dist/src/storage/sqlite/migrations/121_automation_inbox.sql +24 -0
  120. package/dist/src/storage/sqlite/migrations/122_automation_session_projects.sql +18 -0
  121. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  122. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  123. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  124. package/dist/src/storage/sqlite/schema.js +1 -1
  125. package/package.json +3 -2
  126. package/dist/gateway/static/root/assets/agents-DnFIy8Ye.js +0 -68
  127. package/dist/gateway/static/root/assets/apps-page-CONlVc-f.js +0 -1
  128. package/dist/gateway/static/root/assets/automations-page-DuG69tIj.js +0 -6
  129. package/dist/gateway/static/root/assets/browser-settings-page-Cvt-8fqE.js +0 -8
  130. package/dist/gateway/static/root/assets/capabilities-settings-panel-yk3QkGBP.js +0 -7
  131. package/dist/gateway/static/root/assets/channels-settings-CaNnYUQo.js +0 -1
  132. package/dist/gateway/static/root/assets/channels-status-swr-CZ5P9jbB.js +0 -1
  133. package/dist/gateway/static/root/assets/connectors-page-DTpCnOsQ.js +0 -2
  134. package/dist/gateway/static/root/assets/directory-picker-path-field-Ly0TUflq.js +0 -1
  135. package/dist/gateway/static/root/assets/heartbeat-settings-CMZr1_Op.js +0 -1
  136. package/dist/gateway/static/root/assets/home-page-CBG9Bk-1.js +0 -3
  137. package/dist/gateway/static/root/assets/index-BBw9QL0p.js +0 -85
  138. package/dist/gateway/static/root/assets/index-Dm-cvIpl.css +0 -2
  139. package/dist/gateway/static/root/assets/local-app-workbench-page-Bi_0Sknt.js +0 -2
  140. package/dist/gateway/static/root/assets/messages-9zCa8KkW.js +0 -3
  141. package/dist/gateway/static/root/assets/notes-workbench-CMyosgjY.js +0 -4
  142. package/dist/gateway/static/root/assets/project-detail-page-DkS-kbpj.js +0 -1
  143. package/dist/gateway/static/root/assets/projects-page-B3NxP6S4.js +0 -1
  144. package/dist/gateway/static/root/assets/remote-access-hub-DwhrMhjl.js +0 -1
  145. package/dist/gateway/static/root/assets/sessions-page-BOfXXmBL.js +0 -1
  146. package/dist/gateway/static/root/assets/settings-advanced-gate-sPrZfZVR.js +0 -1
  147. package/dist/gateway/static/root/assets/shares-settings-Dvl13Udt.js +0 -1
  148. package/dist/gateway/static/root/assets/skill-reload-api-D9elkZOz.js +0 -1
  149. package/dist/gateway/static/root/assets/task-detail-page-Xd8PlB24.js +0 -1
  150. package/dist/gateway/static/root/assets/work-discovery-page--DTi90d5.js +0 -1
  151. package/dist/gateway/static/root/assets/workflows-page-DXyButkm.js +0 -5
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{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-9zCa8KkW.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-CbPVxonP.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-VVcfd3sG.js";import{r as F}from"./settings-form-draft-Dy10ldo8.js";import{$n as I,Aa as L,Ba as R,Cl as z,Ds as B,Ho as V,Lo as H,Ns as ee,Qn as te,Qs as U,Rs as W,Sc as ne,ar as G,bi as re,cr as K,cs as q,er as J,ir as Y,is as X,jt as ie,lr as ae,nr as oe,oi as se,or as ce,rr as le,sr as ue,tr as de,ul as fe,ur as pe,xl as me,xs as he,ys as ge}from"./index-BBw9QL0p.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-sPrZfZVR.js";import{n as xe,r as Se,t as Ce}from"./settings-form-section-BwAxX_7e.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)(z,{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 oe();if(!n.ok)throw Error(`Failed to enable LAN pairing`);if(n.requiresRestart){let t=await te();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 J():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,z;t[6]===A?z=t[7]:(z=e=>{A(e.recommended.url)},t[6]=A,t[7]=z);let B=De(r,z),V,H,te,U,W;if(t[8]!==k||t[9]!==O||t[10]!==j||t[11]!==B||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){W=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(V=c&&!l,V&&!S){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ge,{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],W=i;break bb0}let p=v?.pairTitle??_.pairTitle,m=l?v?.pairSubtitle??_.pairSubtitle:S?_.pairTunnelActive:_.pairSubtitle,h=!!(s&&(l||c&&S)),g=V?`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)(ge,{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]!==V||t[68]!==m||t[69]!==_.pairSubtitle?(A=V?(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]=V,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)(ee,{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?(H=(0,$.jsxs)(`div`,{className:y,children:[P,F]}),t[78]=y,t[79]=P,t[80]=F,t[81]=H):H=t[81],te=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:B.busy||!r,onClick:()=>B.setConfirmOpen(!0),children:[B.busy?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):null,B.busy?_.pairEnableLanEnabling:_.pairEnableLanButton]})}),B.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:B.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,U=S&&!l?V?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]=B,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]=V,t[50]=H,t[51]=te,t[52]=U,t[53]=W}else V=t[49],H=t[50],te=t[51],U=t[52],W=t[53];if(W!==Symbol.for(`react.early_return_sentinel`))return W;let ne;t[82]===_.pairSecurityNote?ne=t[83]:(ne=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:_.pairSecurityNote}),t[82]=_.pairSecurityNote,t[83]=ne);let G;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?(G=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)(re,{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]=G):G=t[93];let K;t[94]!==V||t[95]!==F||t[96]!==_.deeplinkTitle?(K=F&&!V?(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]=V,t[95]=F,t[96]=_.deeplinkTitle,t[97]=K):K=t[97];let q;t[98]!==V||t[99]!==_.pairMobileProbeHint||t[100]!==_.pairSchemeHint?(q=V?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]=V,t[99]=_.pairMobileProbeHint,t[100]=_.pairSchemeHint,t[101]=q):q=t[101];let J,Y;t[102]===B?(J=t[103],Y=t[104]):(J=()=>void B.runEnableLanPairing(),Y=()=>{B.busy||B.setConfirmOpen(!1)},t[102]=B,t[103]=J,t[104]=Y);let X;t[105]!==B.confirmOpen||t[106]!==_.consentCancel||t[107]!==_.pairEnableLanButton||t[108]!==_.pairEnableLanConfirmBody||t[109]!==_.pairEnableLanConfirmTitle||t[110]!==J||t[111]!==Y?(X=(0,$.jsx)(se,{open:B.confirmOpen,title:_.pairEnableLanConfirmTitle,description:_.pairEnableLanConfirmBody,confirmLabel:_.pairEnableLanButton,cancelLabel:_.consentCancel,onConfirm:J,onCancel:Y}),t[105]=B.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 ie;return t[113]!==ne||t[114]!==G||t[115]!==K||t[116]!==q||t[117]!==X||t[118]!==H||t[119]!==te||t[120]!==U?(ie=(0,$.jsx)(Ce,{children:(0,$.jsxs)($.Fragment,{children:[H,te,U,ne,G,K,q,X]})}),t[113]=ne,t[114]=G,t[115]=K,t[116]=q,t[117]=X,t[118]=H,t[119]=te,t[120]=U,t[121]=ie):ie=t[121],ie}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)(fe,{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 V;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?(V=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)(re,{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)(W,{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)(X,{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)(W,{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]=V):V=t[54];let H;return t[55]!==R||t[56]!==z||t[57]!==B||t[58]!==V||t[59]!==T?(H=(0,$.jsxs)(`section`,{className:T,children:[R,z,B,V]}),t[55]=R,t[56]=z,t[57]=B,t[58]=V,t[59]=T,t[60]=H):H=t[60],H}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&&!ie(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 H=S?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,ee;t[23]===H?ee=t[24]:(ee=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:H}),t[23]=H,t[24]=ee);let te=S?n.brokerSecretReadyHint:n.brokerSecretHint,U;t[25]===te?U=t[26]:(U=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:te}),t[25]=te,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]!==ee||t[31]!==U||t[32]!==W?(G=(0,$.jsxs)(`div`,{children:[ee,U,W]}),t[30]=ee,t[31]=U,t[32]=W,t[33]=G):G=t[33];let re;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(c,{className:`size-3`,"aria-hidden":!0}),t[34]=re):re=t[34];let K;t[35]===n.brokerSecretConsoleLink?K=t[36]:(K=(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,re]}),t[35]=n.brokerSecretConsoleLink,t[36]=K);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 J;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?(J=D?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:b,children:n.brokerSecretTitle}),(0,$.jsx)(V,{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)(V,{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]=J):J=t[66];let Y;t[67]===m?Y=t[68]:(Y=m?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:m}):null,t[67]=m,t[68]=Y);let X;t[69]!==G||t[70]!==K||t[71]!==q||t[72]!==J||t[73]!==Y?(X=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[G,K,q,J,Y]}),t[69]=G,t[70]=K,t[71]=q,t[72]=J,t[73]=Y,t[74]=X):X=t[74];let ae;t[75]!==B||t[76]!==X?(ae=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[B,X]}),t[75]=B,t[76]=X,t[77]=ae):ae=t[77];let oe;t[78]!==ae||t[79]!==I?(oe=(0,$.jsx)(Ce,{className:I,children:ae}),t[78]=ae,t[79]=I,t[80]=oe):oe=t[80];let se;return t[81]!==y||t[82]!==oe?(se=(0,$.jsx)(`div`,{ref:y,id:`tunnel-broker-secret-setup`,children:oe}),t[81]=y,t[82]=oe,t[83]=se):se=t[83],se}function $e(){return K().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=H(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,G,{refreshInterval:6e4}),{data:s,mutate:c}=M(r?`tunnel-pair-context`:null,le,{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,Y,{refreshInterval:4*6e4}),{data:p,mutate:m}=M(!u&&r&&s?.pairingReady?`tunnel-pair`:null,de,{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=R(()=>it(F),[F],{enabled:!!F,initial:null,errorData:null}),L=F?I.data:null,z=!!(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:z,encoding:!!(F&&!L&&!z),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,G,{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=ie(L),z=O?.registrationSecret?.source===`env`,B=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 H=(0,Q.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),ee=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{actionError:null}}),o({type:`patch`,patch:{starting:!0}});try{let e=await ae();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]),te=(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}ee()},[V,O?.consentRequired,ee,n.brokerSecretRequiredBeforeStart]),U=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{consentOpen:!1}}),o({type:`patch`,patch:{actionError:null}});try{await ue(),await Promise.all([j(),ee()])}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[j,ee]),W=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{actionError:null}}),o({type:`patch`,patch:{stopping:!0}});try{await pe(),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]),ne=(0,Q.useCallback)(async e=>{o({type:`patch`,patch:{savingAutoStart:!0}}),o({type:`patch`,patch:{actionError:null}});try{await ce({autoStart:e}),N()}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{savingAutoStart:!1}})}},[]),re=(0,Q.useCallback)(()=>{if(I){ne(!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}})},[ne,O?.canAutoStart,O?.consentRequired,n,I]),K=(0,Q.useCallback)(async()=>{let e=S.trim();if(e){o({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await ce({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]),q=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await ce({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]),J=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await pe({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]),Y=(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 X=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`}},oe=O?.consentRequired&&(X.enabled||I||O?.consent?.acceptedAt),le=(0,$.jsx)(Qe,{t:n,brokerSecretFromEnv:z,brokerSecretMissing:B,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 K(),onClear:()=>void q(),sectionRef:T}),de=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ne,{open:g,title:n.consentTitle,intro:n.consentIntro,bullets:H,checkboxLabel:n.consentCheckbox,confirmLabel:oe?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void U(),onCancel:()=>o({type:`patch`,patch:{consentOpen:!1}})},g?`consent-open`:`consent-closed`),(0,$.jsx)(se,{open:_,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{o({type:`patch`,patch:{autoStartConfirmOpen:!1}}),ne(!0)},onCancel:()=>o({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(se,{open:b,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void J(),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,le,(0,$.jsx)(Ye,{t:n,status:X,isLoading:A,statusErr:k,starting:c,stopping:p,showConsentExpired:!!oe,copyLabels:Y,startDisabled:!V,startDisabledReason:V?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:te,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:re}),n.autoStart]}),!O?.canAutoStart&&!I?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,X.subdomain||X.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 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`})]})}),de]}):(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,le,(0,$.jsx)(Ye,{t:n,status:X,isLoading:A,statusErr:k,starting:c,stopping:p,showConsentExpired:!!oe,copyLabels:Y,startDisabled:!V,startDisabledReason:V?void 0:n.brokerSecretRequiredBeforeStart,onStart:te,onStop:()=>void W()}),(0,$.jsx)(ke,{pairQr:E,gatewayToken:r??``}),X.subdomain||X.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,X.subdomain||X.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:re}),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`})]}),de]})}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)(L,{className:`h-20 rounded-lg`}),(0,$.jsx)(L,{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)(re,{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)(W,{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:B,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:q,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:q,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,G,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,le,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:U,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:he,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:q,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:B,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)(me,{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:U,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:he,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:q,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:B,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,le,{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,()=>de(),{refreshInterval:4*6e4,revalidateOnFocus:!1}),D=(0,Q.useMemo)(()=>!S||!T?.pairingSecret?``:_({baseUrl:S,pairingSecret:T.pairingSecret,lanUrl:w}),[S,w,T?.pairingSecret]),O=R(()=>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)(ee,{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)(re,{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 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{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"./download-Dk-ZjtO6.js";import{t as c}from"./plus-Q2yW6OE7.js";import{t as l}from"./x-B_N4OPjy.js";import{t as u}from"./cn-JdwAhgNB.js";import{t as d}from"./button-CSEbl4zT.js";import{s as f}from"./form-field-width-DJw_jULe.js";import{n as p,t as m}from"./interaction-BmQogeqz.js";import{t as h}from"./messages-9zCa8KkW.js";import{l as g,n as _,r as v,s as y}from"./locale-store-CbPVxonP.js";import{i as ee,o as b}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{a as x,n as S,o as C,r as te,s as w,t as T}from"./dist-BPoKqzeH.js";import{i as E}from"./vendor-swr-BIWyz7Rc.js";import{n as D,r as O}from"./gateway-config-swr-VVcfd3sG.js";import{n as k,r as A,t as j}from"./settings-form-draft-Dy10ldo8.js";import{$c as M,Aa as N,Bc as P,Bi as F,Bt as I,Gi as L,Go as R,Hi as z,Ht as B,Ji as V,Ki as H,Li as U,Ri as W,Ts as G,Ui as ne,Ul as re,Us as K,Ut as ie,Vi as q,Vt as ae,Wl as oe,Ws as se,X as J,Yi as ce,as as le,ka as ue,ks as de,qi as fe,rc as pe,tc as me,ul as he,vc as ge,xc as _e,yc as ve,zi as ye}from"./index-BBw9QL0p.js";import{n as be,t as xe}from"./use-autosave-DTu23D9J.js";import{t as Se}from"./settings-advanced-gate-sPrZfZVR.js";import{n as Ce,t as Y}from"./settings-form-section-BwAxX_7e.js";import{t as we}from"./page-tabs-BaEQMYm_.js";var X=e(t(),1),Te=n(),Z=r();function Ee(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 De(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Oe(e){let t=(0,Te.c)(105),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:c,onAction:l}=e,d;t[0]!==i.unnamedSession||t[1]!==n.name?(d=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=d):d=t[2];let f=d,p;t[3]===n.name?p=t[4]:(p=n.name?.trim(),t[3]=n.name,t[4]=p);let h=!!p,g=n.status===`archived`,_=n.status===`pinned`,v=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,y;t[5]===v?y=t[6]:(y=u(`group flex min-w-0 w-full max-w-full cursor-pointer flex-col rounded-xl bg-surface-base text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover active:scale-[0.99]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,v),t[5]=v,t[6]=y);let ee;t[7]===c?ee=t[8]:(ee=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=ee);let b=r===`list`&&`sm:py-3`,x;t[9]===b?x=t[10]:(x=u(`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]=x);let S;t[11]===n.sourceChannel?S=t[12]:(S=(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.sourceChannel})}),t[11]=n.sourceChannel,t[12]=S);let C;t[13]===_?C=t[14]:(C=_?(0,Z.jsx)(se,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=_,t[14]=C);let te;t[15]===n.updatedAt?te=t[16]:(te=Ee(n.updatedAt),t[15]=n.updatedAt,t[16]=te);let w;t[17]===te?w=t[18]:(w=(0,Z.jsx)(`span`,{children:te}),t[17]=te,t[18]=w);let T;t[19]!==w||t[20]!==C?(T=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[C,w]}),t[19]=w,t[20]=C,t[21]=T):T=t[21];let E;t[22]!==T||t[23]!==x||t[24]!==S?(E=(0,Z.jsxs)(`div`,{className:x,children:[S,T]}),t[22]=T,t[23]=x,t[24]=S,t[25]=E):E=t[25];let D=r===`list`&&`sm:py-3`,O;t[26]===D?O=t[27]:(O=u(`min-w-0 flex-1 px-3 py-2`,D),t[26]=D,t[27]=O);let k=r===`list`&&`sm:items-start`,A;t[28]===k?A=t[29]:(A=u(`flex gap-3`,k),t[28]=k,t[29]=A);let j;t[30]!==o||t[31]!==a?(j=(0,Z.jsx)(ce,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=o,t[31]=a,t[32]=j):j=t[32];let M;t[33]===f?M=t[34]:(M=(0,Z.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]=M);let N;t[35]!==n.key||t[36]!==h?(N=h?(0,Z.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[35]=n.key,t[36]=h,t[37]=N):N=t[37];let P;t[38]!==M||t[39]!==N?(P=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[M,N]}),t[38]=M,t[39]=N,t[40]=P):P=t[40];let F;t[41]!==A||t[42]!==j||t[43]!==P?(F=(0,Z.jsxs)(`div`,{className:A,children:[j,P]}),t[41]=A,t[42]=j,t[43]=P,t[44]=F):F=t[44];let I;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(pe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=I):I=t[45];let L;t[46]===n.messageCount?L=t[47]:(L=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[I,n.messageCount]}),t[46]=n.messageCount,t[47]=L);let z;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(R,{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=De(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=B);let V;t[51]===B?V=t[52]:(V=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[z,B]}),t[51]=B,t[52]=V);let H;t[53]!==L||t[54]!==V?(H=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[L,V]}),t[53]=L,t[54]=V,t[55]=H):H=t[55];let U;t[56]===n.tags?U=t[57]:(U=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(je),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=U);let W;t[58]!==O||t[59]!==F||t[60]!==H||t[61]!==U?(W=(0,Z.jsxs)(`div`,{className:O,children:[F,H,U]}),t[58]=O,t[59]=F,t[60]=H,t[61]=U,t[62]=W):W=t[62];let G;t[63]===l?G=t[64]:(G=()=>l(`continue`),t[63]=l,t[64]=G);let ne;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(pe,{className:`size-4`,strokeWidth:1.75}),t[65]=ne):ne=t[65];let ie;t[66]!==i.continueChat||t[67]!==G?(ie=(0,Z.jsx)(`button`,{type:`button`,className:m,title:i.continueChat,"aria-label":i.continueChat,onClick:G,children:ne}),t[66]=i.continueChat,t[67]=G,t[68]=ie):ie=t[68];let q;t[69]!==g||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==l?(q=g?(0,Z.jsx)(`button`,{type:`button`,className:m,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Z.jsx)(oe,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:m,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Z.jsx)(re,{className:`size-4`,strokeWidth:1.75})}),t[69]=g,t[70]=i.archive,t[71]=i.unarchive,t[72]=l,t[73]=q):q=t[73];let ae;t[74]!==_||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==l?(ae=_?(0,Z.jsx)(`button`,{type:`button`,className:m,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Z.jsx)(K,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:m,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Z.jsx)(se,{className:`size-4`,strokeWidth:1.75})}),t[74]=_,t[75]=i.pin,t[76]=i.unpin,t[77]=l,t[78]=ae):ae=t[78];let J;t[79]===l?J=t[80]:(J=()=>l(`export`),t[79]=l,t[80]=J);let ue;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75}),t[81]=ue):ue=t[81];let de;t[82]!==i.export||t[83]!==J?(de=(0,Z.jsx)(`button`,{type:`button`,className:m,title:i.export,"aria-label":i.export,onClick:J,children:ue}),t[82]=i.export,t[83]=J,t[84]=de):de=t[84];let fe;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(fe=u(m,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=fe):fe=t[85];let me;t[86]===l?me=t[87]:(me=()=>l(`delete`),t[86]=l,t[87]=me);let he;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,Z.jsx)(le,{className:`size-4`,strokeWidth:1.75}),t[88]=he):he=t[88];let ge;t[89]!==i.delete||t[90]!==me?(ge=(0,Z.jsx)(`button`,{type:`button`,className:fe,title:i.delete,"aria-label":i.delete,onClick:me,children:he}),t[89]=i.delete,t[90]=me,t[91]=ge):ge=t[91];let _e;t[92]!==ie||t[93]!==q||t[94]!==ae||t[95]!==de||t[96]!==ge?(_e=(0,Z.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:Ae,onKeyDown:ke,children:[ie,q,ae,de,ge]}),t[92]=ie,t[93]=q,t[94]=ae,t[95]=de,t[96]=ge,t[97]=_e):_e=t[97];let ve;return t[98]!==c||t[99]!==E||t[100]!==W||t[101]!==y||t[102]!==_e||t[103]!==ee?(ve=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:y,onClick:c,onKeyDown:ee,children:[E,W,_e]}),t[98]=c,t[99]=E,t[100]=W,t[101]=y,t[102]=_e,t[103]=ee,t[104]=ve):ve=t[104],ve}function ke(e){return e.stopPropagation()}function Ae(e){return e.stopPropagation()}function je(e){return(0,Z.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}var Me={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 Ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pe(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Q(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function Fe(e){let t=Ne(e)?e:{},n=Ne(t.userContext)?t.userContext:{},r=Ne(n.memory)?n.memory:{},i=Ne(r.retention)?r.retention:{},a=Ne(i.compaction)?i.compaction:{},o=Me,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:Pe(a.triggerThreshold,o.triggerThreshold,.1,.98),reserveTokens:Q(a.reserveTokens,o.reserveTokens,1024),minMessagesBeforeCompact:Q(a.minMessagesBeforeCompact,o.minMessagesBeforeCompact,2),keepRecentTokens:Q(a.keepRecentTokens,o.keepRecentTokens,1e3),recentTurnsPreserve:Q(a.recentTurnsPreserve,o.recentTurnsPreserve,1,12),summaryMaxTokens:Q(a.summaryMaxTokens,o.summaryMaxTokens,256),summaryChunkTokens:Q(a.summaryChunkTokens,o.summaryChunkTokens,1e3),summaryTimeoutMs:Q(a.summaryTimeoutMs,o.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(a.summaryRetries,o.summaryRetries,0,5),qualityGuard:typeof a.qualityGuard==`boolean`?a.qualityGuard:o.qualityGuard,...s?{model:s}:{},minToolResultKeepChars:Q(a.minToolResultKeepChars,o.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(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 y(v(`/api/config`),{method:`PATCH`,body:JSON.stringify(Le(e))}),await D()}var ze=128e3,Be={balanced:Me,preserve:{...Me,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Me,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Ve=j();function He(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,f,`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,Te.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=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,Z.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,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Ke(e){let t=(0,Te.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=u(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let d;t[4]!==i||t[5]!==a||t[6]!==l?(d=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=d):d=t[7];let f;t[8]===n?f=t[9]:(f=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=f);let p;t[10]===r?p=t[11]:(p=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,Z.jsxs)(`span`,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;return t[15]!==c||t[16]!==d||t[17]!==m?(h=(0,Z.jsxs)(`label`,{className:c,children:[d,m]}),t[15]=c,t[16]=d,t[17]=m,t[18]=h):h=t[18],h}function qe({hasToken:e}){let t=h(_(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=O(e),{data:i=[],isLoading:a}=E(e?B:null,ie,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Fe(n.payload.config),[n]),[s,f]=(0,X.useReducer)(Ve,{form:null,baseline:null}),[m,g]=(0,X.useState)(``),v=(0,X.useRef)(!1),y=(0,X.useRef)(s.form);y.current=s.form;let ee=(0,X.useRef)(null);k({enabled:e,parsed:o,dirty:v.current,trackedParsedRef:ee,dispatch:f,onResetDirty:()=>{v.current=!1}});let b=s.form,x=s.baseline,S=!!(b&&x&&JSON.stringify(b)!==JSON.stringify(x)),C=(0,X.useCallback)(e=>{v.current=!0,f({type:`patch`,patch:e})},[]),te=(0,X.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),w=xe({value:b,dirty:S,onSave:(0,X.useCallback)(async e=>{try{await Re(e),f({type:`saved`,value:e}),v.current=!!(y.current&&JSON.stringify(y.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||!b)return r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(N,{className:`h-5 w-48`}),(0,Z.jsx)(N,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(N,{className:`h-36 w-full rounded-xl`})]})}):null;let T=We(b),D=Math.max(0,ze-b.reserveTokens),A=Math.min(Math.floor(ze*b.triggerThreshold),D),j=Math.min(100,A/ze*100),M=Math.min(100,D/ze*100),P=b.model?i.find(e=>e.id===b.model):void 0,F=P?.contextWindow&&b.summaryChunkTokens+b.summaryMaxTokens+4096>P.contextWindow,I=b.keepRecentTokens+b.reserveTokens>A,L=Math.round(b.summaryTimeoutMs*(b.summaryRetries+1)/1e3),R=e=>{let t=Be[e];C({...t,...b.model?{model:b.model}:{model:void 0},postCompactionSections:b.postCompactionSections})},z={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},V=()=>{let e=m.trim();!e||b.postCompactionSections.includes(e)||b.postCompactionSections.length>=12||(C({postCompactionSections:[...b.postCompactionSections,e]}),g(``))};return(0,Z.jsxs)(Y,{onBlurCapture:w.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:me,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(be,{status:w.status,error:w.error}),(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:b.enabled,onChange:e=>C({enabled:e.target.checked})}),b.enabled?t.enabled:t.disabled]})]})}),w.error?(0,Z.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:w.error}):null,b.enabled?null:(0,Z.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,Z.jsxs)(`fieldset`,{disabled:!b.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),T===`custom`?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":T===e,className:u(`rounded-xl border px-3 py-3 text-left`,p.transition,p.focusRingPanel,T===e?`border-accent/50 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg hover:bg-surface-hover`),onClick:()=>R(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:z[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:z[e].hint})]},e))})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-hover/35 p-4 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.compactionTrigger}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(A)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${j}%`}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.hardInputLimit}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(D)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${M}%`}})})]})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((b.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>C({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ge(b.reserveTokens)),value:b.reserveTokens,min:1024,step:1024,onChange:e=>C({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:b.recentTurnsPreserve,min:1,max:12,onChange:e=>C({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ge(b.keepRecentTokens)),value:b.keepRecentTokens,min:1e3,step:1e3,onChange:e=>C({keepRecentTokens:Math.floor(e)})})]}),I?(0,Z.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,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Z.jsx)(J,{value:b.model??``,disabled:!b.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=>C({model:e})}),b.model?(0,Z.jsx)(d,{type:`button`,variant:`secondary`,onClick:()=>C({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Z.jsx)(Ke,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:b.qualityGuard,onChange:e=>C({qualityGuard:e})})]}),b.qualityGuard?null:(0,Z.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,Z.jsx)(Se,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 border-t border-edge pt-5`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:b.minMessagesBeforeCompact,min:2,onChange:e=>C({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((b.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>C({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:b.summaryMaxTokens,min:256,step:256,onChange:e=>C({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:b.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>C({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(L)),value:b.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>C({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:b.summaryRetries,min:0,max:5,onChange:e=>C({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:b.minToolResultKeepChars,min:200,step:100,onChange:e=>C({minToolResultKeepChars:Math.floor(e)})})]}),F?(0,Z.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,Z.jsxs)(`div`,{className:`border-t border-edge pt-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),b.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:b.postCompactionSections.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Z.jsx)(`button`,{type:`button`,className:u(`text-fg-muted hover:text-fg`,p.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>C({postCompactionSections:b.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(l,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`input`,{className:He(),value:m,maxLength:120,disabled:b.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),V())}}),(0,Z.jsxs)(d,{type:`button`,variant:`secondary`,disabled:!m.trim()||b.postCompactionSections.length>=12,onClick:V,children:[(0,Z.jsx)(c,{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 y(v(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),D()}function Qe(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,f,`dark:border-edge`)}var $e=j();function et({hasToken:e}){let t=h(_(e=>e.language)).sessions.config,{data:n,isLoading:r}=O(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Xe(n.payload.config),[n]),[s,c]=(0,X.useReducer)($e,{form:null,baseline:null}),l=s.form,u=s.baseline,d=(0,X.useRef)(!1),f=(0,X.useRef)(l);f.current=l;let p=(0,X.useRef)(null);k({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:p,dispatch:c,onResetDirty:()=>{d.current=!1}});let m=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),g=(0,X.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),v=xe({value:l,dirty:m,onSave:(0,X.useCallback)(async e=>{try{await Ze(e),c({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!l?r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(N,{className:`h-5 w-40`}),(0,Z.jsx)(N,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(Y,{onBlurCapture:v.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:M,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(be,{status:v.status,error:v.error})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Z.jsxs)(a,{className:Qe(),value:l.dmScope,onChange:e=>g({dmScope:e.target.value}),children:[(0,Z.jsx)(o,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(o,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(o,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(o,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Z.jsx)(`input`,{type:`number`,min:0,className:Qe(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();g({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Z.jsx)(`input`,{type:`number`,min:1,className:Qe(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();g({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,Te.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:c,onArchive:f,onUnarchive:p,onPin:m,onUnpin:h,onExport:g,onDelete:_}=e,v=i?.status===`archived`,y=i?.status===`pinned`,E;t[0]===c?E=t[1]:(E=e=>!e&&c(),t[0]=c,t[1]=E);let D;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(x,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,b)}),t[2]=D):D=t[2];let O;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(O=u(`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`,ee,`dark:border-edge`),t[3]=O):O=t[3];let k;t[4]!==i||t[5]!==o||t[6]!==a?(k=i&&a?(0,Z.jsx)(ce,{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]=k):k=t[7];let A;t[8]!==s.unnamedSession||t[9]!==i?.name?(A=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=A):A=t[10];let j;t[11]===A?j=t[12]:(j=(0,Z.jsx)(w,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:A}),t[11]=A,t[12]=j);let M;t[13]!==k||t[14]!==j?(M=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[k,j]}),t[13]=k,t[14]=j,t[15]=M):M=t[15];let N;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(l,{className:`size-5`,strokeWidth:1.75}),t[16]=N):N=t[16];let P;t[17]===s.close?P=t[18]:(P=(0,Z.jsx)(S,{asChild:!0,children:(0,Z.jsx)(d,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:N})}),t[17]=s.close,t[18]=P);let F;t[19]!==M||t[20]!==P?(F=(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[M,P]}),t[19]=M,t[20]=P,t[21]=F):F=t[21];let I;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(I=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Z.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Z.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(rt)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=I):I=t[26];let L;t[27]===I?L=t[28]:(L=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:I}),t[27]=I,t[28]=L);let R;t[29]!==s.detailExport||t[30]!==g?(R=(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:g,children:s.detailExport}),t[29]=s.detailExport,t[30]=g,t[31]=R):R=t[31];let z;t[32]!==v||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==f||t[36]!==p?(z=v?(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:s.unarchive}):(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:s.archive}),t[32]=v,t[33]=s.archive,t[34]=s.unarchive,t[35]=f,t[36]=p,t[37]=z):z=t[37];let B;t[38]!==y||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==m||t[42]!==h?(B=y?(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:s.unpin}):(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:s.pin}),t[38]=y,t[39]=s.pin,t[40]=s.unpin,t[41]=m,t[42]=h,t[43]=B):B=t[43];let V;t[44]!==s.delete||t[45]!==_?(V=(0,Z.jsx)(d,{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:_,children:s.delete}),t[44]=s.delete,t[45]=_,t[46]=V):V=t[46];let H;t[47]!==R||t[48]!==z||t[49]!==B||t[50]!==V?(H=(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[R,z,B,V]})}),t[47]=R,t[48]=z,t[49]=B,t[50]=V,t[51]=H):H=t[51];let U;t[52]!==F||t[53]!==L||t[54]!==H?(U=(0,Z.jsxs)(C,{children:[D,(0,Z.jsxs)(te,{className:O,"aria-describedby":void 0,children:[F,L,H]})]}),t[52]=F,t[53]=L,t[54]=H,t[55]=U):U=t[55];let W;return t[56]!==n||t[57]!==E||t[58]!==U?(W=(0,Z.jsx)(T,{open:n,onOpenChange:E,children:U}),t[56]=n,t[57]=E,t[58]=U,t[59]=W):W=t[59],W}function rt(e){return(0,Z.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children: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,Te.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`?_e:G})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(we,{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,Te.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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ut(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:dt(n,r)})]}),(0,Z.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Z.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function 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=h(_(e=>e.language)),t=e.sessions,n=g(e=>e.token),r=!!n,{data:a,mutate:o}=E(r?[`gateway-chat-agents`,n]:null,ue,{revalidateOnFocus:!1}),s=a?.defaultId??`main`,c=a?.items??[],[l,f]=i(),m=lt(l.get(`tab`)),v=(0,X.useCallback)(e=>{let t=new URLSearchParams(l);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),f(t,{replace:!0})},[l,f]),[y,S]=(0,X.useReducer)(A,l,mt),{searchInput:D,debouncedSearch:O,statusFilter:k,viewMode:j,channelFilter:M,sessions:N,loading:R,error:B,hasMore:G,stats:K,detailOpen:ie,detailLoading:oe,detailSession:J,confirmOpen:ce,confirmKey:le}=y;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=D.trim();O!==e&&S({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[D,O]);let pe=l.toString(),me=(0,X.useRef)(pe);if(me.current!==pe){me.current=pe;let e=l.get(`q`)??``,t=l.get(`status`),n=l.get(`view`),r=(l.get(`channel`)??``).trim(),i=ot.has(t)?t:`all`,a=st.has(n)?n:`grid`,o=e.trim();S({type:`patch`,patch:{...D===e?{}:{searchInput:e},...O===o?{}:{debouncedSearch:o},...k===i?{}:{statusFilter:i},...j===a?{}:{viewMode:a},...M===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(l),t=O.trim();t?e.set(`q`,t):e.delete(`q`),k===`all`?e.delete(`status`):e.set(`status`,k),j===`grid`?e.delete(`view`):e.set(`view`,j),M?e.set(`channel`,M):e.delete(`channel`),e.toString()!==l.toString()&&f(e,{replace:!0})},[O,l,f,k,j,M]),(0,X.useEffect)(()=>{if(!r||m!==`sessions`)return;let e=!1;return(async()=>{S({type:`patch`,patch:{loading:!0,error:null}});try{let t=await z({limit:it,offset:0,...O?{search:O}:{},...k===`all`?{}:{status:k},...M?{channel:M}:{}});if(e)return;S({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||S({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||S({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,m,O,k,M,t.loadError]),(0,X.useEffect)(()=>{!r||m!==`sessions`||q().then(e=>S({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,m]),(0,X.useEffect)(()=>{if(!r||m!==`sessions`)return;let e=()=>void o();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,m,o]),(0,X.useEffect)(()=>{if(!r||m!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||S({type:`patch`,patch:{sessions:N.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,m,N,J]);let be=(0,X.useCallback)(async()=>{if(!(!r||R||!G)){S({type:`patch`,patch:{loading:!0,error:null}});try{let e=await z({limit:it,offset:N.length,...O?{search:O}:{},...k===`all`?{}:{status:k},...M?{channel:M}:{}});S({type:`patch`,patch:{sessions:[...N,...e.items],hasMore:e.hasMore}})}catch(e){S({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{S({type:`patch`,patch:{loading:!1}})}}},[r,R,G,N.length,O,k,M,t.loadError]),xe=(0,X.useCallback)((e,t)=>{S({type:`patch`,patch:{sessions:N.map(n=>n.key===e?{...n,status:t}:n),detailSession:J&&J.key===e?{...J,status:t}:J}})},[N,J]),Se=(0,X.useCallback)(async e=>{S({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{S({type:`patch`,patch:{detailSession:await F(e)}})}catch{S({type:`patch`,patch:{detailOpen:!1}})}finally{S({type:`patch`,patch:{detailLoading:!1}})}},[]),Ce=e=>{Se(e)},Y=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){S({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await U(e),xe(e,`archived`);break;case`unarchive`:await L(e),xe(e,`active`);break;case`pin`:await ne(e),xe(e,`pinned`);break;case`unpin`:await H(e),xe(e,`active`);break;case`export`:{let t=await ye(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}q().then(e=>S({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we=async e=>{try{await W(e),S({type:`patch`,patch:{sessions:N.filter(t=>t.key!==e),detailSession:J?.key===e?null:J,...J?.key===e?{detailOpen:!1}:{}}}),q().then(e=>S({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Te={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,unnamedSession:e.chat.newSession},Ee={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},De=[{key:`all`,label:t.filterAll,icon:_e},{key:`active`,label:t.filterActive,icon:he},{key:`pinned`,label:t.filterPinned,icon:se},{key:`archived`,label:t.filterArchived,icon:re}],ke=(()=>{let e=Object.entries(K?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Z.jsx)(`header`,{className:`flex flex-col gap-2`,children:(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title})}),(0,Z.jsx)(ft,{s:t,activeTab:m,onChange:v}),(0,Z.jsx)(pt,{s:t,id:`settings`,activeTab:m,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(qe,{hasToken:r}),(0,Z.jsx)(et,{hasToken:r})]})}),(0,Z.jsxs)(pt,{s:t,id:`sessions`,activeTab:m,plain:!0,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:De.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":k===e,onClick:()=>S({type:`patch`,patch:{statusFilter:e}}),className:u(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,p.transition,p.focusRingPanel,k===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Z.jsxs)(`div`,{className:`flex 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,Z.jsx)(de,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:D,onChange:e=>S({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":O||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,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":!M,onClick:()=>S({type:`patch`,patch:{channelFilter:``}}),className:u(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,p.transition,p.focusRingPanel,M?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),ke.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":M===e,onClick:()=>S({type:`patch`,patch:{channelFilter:e}}),className:u(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,p.transition,p.focusRingPanel,M===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,K?.byChannel?.[e]==null?null:(0,Z.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:K.byChannel[e]})]},e))]}),K?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[K.totalSessions,t.totalSessions],[K.activeSessions,t.activeSessions],[K.pinnedSessions,t.pinnedSessions],[K.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,B?(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,children:B}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:at(t.sessionCount,{count:N.length})}),(0,Z.jsxs)(`div`,{className:ae,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(d,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":j===`grid`,onClick:()=>S({type:`patch`,patch:{viewMode:`grid`}}),className:u(I,`size-7 p-0`,j===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,j===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(ve,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(d,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":j===`list`,onClick:()=>S({type:`patch`,patch:{viewMode:`list`}}),className:u(I,`size-9 p-0`,j===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,j===`list`&&`text-accent-fg`),children:(0,Z.jsx)(ge,{className:`size-3.5`,strokeWidth:1.5})})]})]}),R&&N.length===0?(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,Z.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):N.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,Z.jsx)(P,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Z.jsx)(d,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:u(`grid min-w-0 gap-3`,j===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":O||void 0,children:N.map(e=>{let t=V(e,s);return(0,Z.jsx)(Oe,{session:e,variant:j,labels:Te,sessionAgentId:t,sessionAgentAvatar:fe(t,c),onOpen:()=>Ce(e.key),onAction:t=>void Y(e.key,t)},e.key)})}),G?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(d,{type:`button`,variant:`secondary`,disabled:R,onClick:()=>void be(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(nt,{open:ie,loading:oe,session:J,sessionAgentId:J?V(J,s):void 0,sessionAgentAvatar:J?fe(V(J,s),c):void 0,labels:Ee,onClose:()=>{S({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>J&&void Y(J.key,`archive`),onUnarchive:()=>J&&void Y(J.key,`unarchive`),onPin:()=>J&&void Y(J.key,`pin`),onUnpin:()=>J&&void Y(J.key,`unpin`),onExport:()=>J&&void Y(J.key,`export`),onDelete:()=>J&&S({type:`patch`,patch:{confirmKey:J.key,confirmOpen:!0}})}),(0,Z.jsx)(T,{open:ce,onOpenChange:e=>S({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(C,{children:[(0,Z.jsx)(x,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,b)}),(0,Z.jsxs)(te,{className:u(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,ee),children:[(0,Z.jsx)(w,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:le?at(t.deleteSessionMessage,{name:N.find(e=>e.key===le)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(d,{type:`button`,variant:`secondary`,onClick:()=>S({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(d,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{le&&we(le),S({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Z.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{ht as SessionsPage};
@@ -1 +0,0 @@
1
- import{Jn as e}from"./index-BBw9QL0p.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./check-DUBLcKHA.js";import{n as o,r as s}from"./popover-select-BzdnTy3h.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./cn-JdwAhgNB.js";import{t as p}from"./button-CSEbl4zT.js";import{s as m}from"./form-field-width-DJw_jULe.js";import{t as h}from"./copy-to-clipboard-HOJ79TWv.js";import{t as g}from"./messages-9zCa8KkW.js";import{l as _,n as v,r as y,s as b}from"./locale-store-CbPVxonP.js";import{a as x,n as S,o as ee,r as C,s as w,t as T}from"./dist-BPoKqzeH.js";import{i as te}from"./vendor-swr-BIWyz7Rc.js";import{n as E,r as D}from"./gateway-config-swr-VVcfd3sG.js";import{r as O}from"./settings-form-draft-Dy10ldo8.js";import{Aa as k,An as A,Bc as j,Cl as M,Gc as N,Ln as P,Ns as ne,Pi as F,_i as I,as as re,di as ie,fi as L,gi as ae,hi as R,li as oe,mi as se,oi as z,ol as B,pi as ce,vi as V,yi as H}from"./index-BBw9QL0p.js";import{n as U,r as W,t as G}from"./settings-page-layout-BRQNel6r.js";import{t as K}from"./settings-loading-skeleton-B3OiTnF9.js";import{t as q}from"./settings-form-section-BwAxX_7e.js";import{t as le}from"./page-tabs-BaEQMYm_.js";var J=e(t(),1),ue=n(),Y={enabled:!0,defaultTtlHours:24,maxTtlDays:30,maxActiveShares:500,maxFileSizeMb:500,directoryMaxFolderSizeMb:2048,directoryMaxFileCount:1e4,inlinePreviewMimes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`application/pdf`,`text/html`,`text/markdown`,`text/plain`,`application/json`],siteEnabled:!0,siteDefaultTtlHours:24,siteMaxTtlDays:30,maxActiveSites:50,siteMaxRootDirSizeMb:1024,siteMaxFileCount:2e4};function de(){return structuredClone(Y)}var fe=36e5,X=864e5,Z=1048576;function pe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function me(e,t=32){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function he(e){let t=pe(e)?e:{},n=pe(t.gateway)?t.gateway:{},r=pe(n.share)?n.share:{},i=pe(r.directory)?r.directory:{},a=pe(n.siteShare)?n.siteShare:{},o=pe(a.static)?a.static:{},s=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):Y.defaultTtlHours*fe,c=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):Y.maxTtlDays*X,l=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):Y.maxFileSizeMb*Z,u=typeof i.maxFolderSize==`number`&&Number.isFinite(i.maxFolderSize)?Math.floor(i.maxFolderSize):Y.directoryMaxFolderSizeMb*Z,d=typeof a.defaultTtlMs==`number`&&Number.isFinite(a.defaultTtlMs)?Math.floor(a.defaultTtlMs):Y.siteDefaultTtlHours*fe,f=typeof a.maxTtlMs==`number`&&Number.isFinite(a.maxTtlMs)?Math.floor(a.maxTtlMs):Y.siteMaxTtlDays*X,p=typeof o.maxRootDirSize==`number`&&Number.isFinite(o.maxRootDirSize)?Math.floor(o.maxRootDirSize):Y.siteMaxRootDirSizeMb*Z;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(s/fe)),maxTtlDays:Math.max(1,Math.round(c/X)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):Y.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(l/Z)),directoryMaxFolderSizeMb:Math.max(1,Math.round(u/Z)),directoryMaxFileCount:typeof i.maxFileCount==`number`&&Number.isFinite(i.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(i.maxFileCount))):Y.directoryMaxFileCount,inlinePreviewMimes:me(r.inlinePreviewMimes,32).length?me(r.inlinePreviewMimes,32):[...Y.inlinePreviewMimes],siteEnabled:a.enabled!==!1,siteDefaultTtlHours:Math.max(1,Math.round(d/fe)),siteMaxTtlDays:Math.max(1,Math.round(f/X)),maxActiveSites:typeof a.maxActiveSites==`number`&&Number.isFinite(a.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(a.maxActiveSites))):Y.maxActiveSites,siteMaxRootDirSizeMb:Math.max(1,Math.round(p/Z)),siteMaxFileCount:typeof o.maxFileCount==`number`&&Number.isFinite(o.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(o.maxFileCount))):Y.siteMaxFileCount}}function ge(e){let t=e.defaultTtlHours*fe,n=e.maxTtlDays*X,r=e.siteDefaultTtlHours*fe,i=e.siteMaxTtlDays*X;return t<6e4||t>6048e5?`Default share TTL must be between 1 minute and 7 days.`:n<6e4||n>2592e6?`Maximum share TTL must be between 1 minute and 30 days.`:t>n?`Default TTL cannot exceed maximum TTL.`:e.maxActiveShares<1||e.maxActiveShares>1e4?`Maximum active shares must be between 1 and 10,000.`:e.maxActiveSites<1||e.maxActiveSites>1e3?`Maximum active site shares must be between 1 and 1,000.`:e.maxFileSizeMb<1||e.maxFileSizeMb>10240?`Maximum file size must be between 1 MB and 10 GB.`:e.directoryMaxFolderSizeMb<1||e.directoryMaxFolderSizeMb>10240?`Maximum folder size must be between 1 MB and 10 GB.`:e.directoryMaxFileCount<1||e.directoryMaxFileCount>1e5?`Maximum directory file count must be between 1 and 100,000.`:r<6e4||r>6048e5?`Default site share TTL must be between 1 minute and 7 days.`:i<6e4||i>2592e6?`Maximum site share TTL must be between 1 minute and 30 days.`:r>i?`Default site TTL cannot exceed maximum site TTL.`:e.siteMaxRootDirSizeMb<1||e.siteMaxRootDirSizeMb>10240?`Maximum static site size must be between 1 MB and 10 GB.`:e.siteMaxFileCount<1||e.siteMaxFileCount>1e5?`Maximum static site file count must be between 1 and 100,000.`:null}async function _e(e){let t=ge(e);if(t)throw Error(t);await b(y(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*fe,maxTtlMs:e.maxTtlDays*X,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*Z,inlinePreviewMimes:e.inlinePreviewMimes,directory:{maxFolderSize:e.directoryMaxFolderSizeMb*Z,maxFileCount:e.directoryMaxFileCount}},siteShare:{enabled:e.siteEnabled,defaultTtlMs:e.siteDefaultTtlHours*fe,maxTtlMs:e.siteMaxTtlDays*X,maxActiveSites:e.maxActiveSites,static:{maxRootDirSize:e.siteMaxRootDirSizeMb*Z,maxFileCount:e.siteMaxFileCount}}}})}),E()}var Q=r();function ve(){return f(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m,`dark:border-edge`)}function ye({hasToken:e}){let t=g(v(e=>e.language)).sharesSettings,{data:n,isLoading:r}=D(e),i=(0,J.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(he(n.payload.config)),[n]),a=(0,J.useRef)(!1),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(null),[f,m]=(0,J.useState)(!1),h=o??i,_=i,y=(0,J.useMemo)(()=>!h||!_?!1:JSON.stringify(h)!==JSON.stringify(_),[h,_]),b=(0,J.useCallback)(e=>{a.current=!0,s(t=>{let n=t??_;return n?{...n,...e}:null})},[_]),x=(0,J.useCallback)(async()=>{if(!(!h||c)){l(!0),d(null),m(!1);try{await _e(h),a.current=!1,s(null),m(!0),window.setTimeout(()=>m(!1),2500)}catch(e){d(e instanceof Error?e.message:t.policySaveError)}finally{l(!1)}}},[h,c,t.policySaveError]),S=(0,J.useCallback)(()=>{a.current=!1,s(null),d(null),m(!1)},[]);return!e||!h?r?(0,Q.jsx)(q,{children:(0,Q.jsx)(K,{rows:2})}):null:(0,Q.jsxs)(q,{children:[(0,Q.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[f?(0,Q.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,Q.jsx)(p,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>b(de()),children:t.policyUseRecommended}),(0,Q.jsx)(p,{type:`button`,variant:`secondary`,disabled:!y||c,onClick:S,children:t.policyDiscard}),(0,Q.jsx)(p,{type:`button`,variant:`primary`,disabled:!y||c,onClick:()=>void x(),children:c?t.policySaving:t.policySave})]})]}),y?(0,Q.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,u?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,Q.jsx)(be,{t,form:h,onChange:b})]})}function be(e){let t=(0,ue.c)(150),{t:n,form:r,onChange:i}=e,a;t[0]===n.policyFileSection?a=t[1]:(a=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyFileSection}),t[0]=n.policyFileSection,t[1]=a);let o;t[2]===n.policyFileSectionHint?o=t[3]:(o=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyFileSectionHint}),t[2]=n.policyFileSectionHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.policyEnabled||t[13]!==l?(u=(0,Q.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.policyEnabled]}),t[12]=n.policyEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({defaultTtlHours:e}),t[15]=i,t[16]=f);let p;t[17]!==r.defaultTtlHours||t[18]!==n.policyDefaultTtlHint||t[19]!==n.policyDefaultTtlHours||t[20]!==d||t[21]!==f?(p=(0,Q.jsx)($,{id:`share-default-ttl-hours`,label:n.policyDefaultTtlHours,hint:n.policyDefaultTtlHint,value:r.defaultTtlHours,min:1,max:168,disabled:d,onChange:f}),t[17]=r.defaultTtlHours,t[18]=n.policyDefaultTtlHint,t[19]=n.policyDefaultTtlHours,t[20]=d,t[21]=f,t[22]=p):p=t[22];let m=!r.enabled,h;t[23]===i?h=t[24]:(h=e=>i({maxTtlDays:e}),t[23]=i,t[24]=h);let g;t[25]!==r.maxTtlDays||t[26]!==n.policyMaxTtlDays||t[27]!==n.policyMaxTtlHint||t[28]!==m||t[29]!==h?(g=(0,Q.jsx)($,{id:`share-max-ttl-days`,label:n.policyMaxTtlDays,hint:n.policyMaxTtlHint,value:r.maxTtlDays,min:1,max:30,disabled:m,onChange:h}),t[25]=r.maxTtlDays,t[26]=n.policyMaxTtlDays,t[27]=n.policyMaxTtlHint,t[28]=m,t[29]=h,t[30]=g):g=t[30];let _=!r.enabled,v;t[31]===i?v=t[32]:(v=e=>i({maxActiveShares:e}),t[31]=i,t[32]=v);let y;t[33]!==r.maxActiveShares||t[34]!==n.policyMaxActiveShares||t[35]!==n.policyMaxActiveSharesHint||t[36]!==_||t[37]!==v?(y=(0,Q.jsx)($,{id:`share-max-active`,label:n.policyMaxActiveShares,hint:n.policyMaxActiveSharesHint,value:r.maxActiveShares,min:1,max:1e4,disabled:_,onChange:v}),t[33]=r.maxActiveShares,t[34]=n.policyMaxActiveShares,t[35]=n.policyMaxActiveSharesHint,t[36]=_,t[37]=v,t[38]=y):y=t[38];let b=!r.enabled,x;t[39]===i?x=t[40]:(x=e=>i({maxFileSizeMb:e}),t[39]=i,t[40]=x);let S;t[41]!==r.maxFileSizeMb||t[42]!==n.policyMaxFileSizeHint||t[43]!==n.policyMaxFileSizeMb||t[44]!==b||t[45]!==x?(S=(0,Q.jsx)($,{id:`share-max-file-mb`,label:n.policyMaxFileSizeMb,hint:n.policyMaxFileSizeHint,value:r.maxFileSizeMb,min:1,max:10240,disabled:b,onChange:x}),t[41]=r.maxFileSizeMb,t[42]=n.policyMaxFileSizeHint,t[43]=n.policyMaxFileSizeMb,t[44]=b,t[45]=x,t[46]=S):S=t[46];let ee=!r.enabled,C;t[47]===i?C=t[48]:(C=e=>i({directoryMaxFolderSizeMb:e}),t[47]=i,t[48]=C);let w;t[49]!==r.directoryMaxFolderSizeMb||t[50]!==n.policyDirectoryMaxFolderSizeHint||t[51]!==n.policyDirectoryMaxFolderSizeMb||t[52]!==ee||t[53]!==C?(w=(0,Q.jsx)($,{id:`share-directory-max-size-mb`,label:n.policyDirectoryMaxFolderSizeMb,hint:n.policyDirectoryMaxFolderSizeHint,value:r.directoryMaxFolderSizeMb,min:1,max:10240,disabled:ee,onChange:C}),t[49]=r.directoryMaxFolderSizeMb,t[50]=n.policyDirectoryMaxFolderSizeHint,t[51]=n.policyDirectoryMaxFolderSizeMb,t[52]=ee,t[53]=C,t[54]=w):w=t[54];let T=!r.enabled,te;t[55]===i?te=t[56]:(te=e=>i({directoryMaxFileCount:e}),t[55]=i,t[56]=te);let E;t[57]!==r.directoryMaxFileCount||t[58]!==n.policyDirectoryMaxFileCount||t[59]!==n.policyDirectoryMaxFileCountHint||t[60]!==T||t[61]!==te?(E=(0,Q.jsx)($,{id:`share-directory-max-files`,label:n.policyDirectoryMaxFileCount,hint:n.policyDirectoryMaxFileCountHint,value:r.directoryMaxFileCount,min:1,max:1e5,disabled:T,onChange:te}),t[57]=r.directoryMaxFileCount,t[58]=n.policyDirectoryMaxFileCount,t[59]=n.policyDirectoryMaxFileCountHint,t[60]=T,t[61]=te,t[62]=E):E=t[62];let D;t[63]!==g||t[64]!==y||t[65]!==S||t[66]!==w||t[67]!==E||t[68]!==p?(D=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[p,g,y,S,w,E]}),t[63]=g,t[64]=y,t[65]=S,t[66]=w,t[67]=E,t[68]=p,t[69]=D):D=t[69];let O=!r.enabled,k;t[70]===i?k=t[71]:(k=e=>i({inlinePreviewMimes:e}),t[70]=i,t[71]=k);let A;t[72]!==r.inlinePreviewMimes||t[73]!==n||t[74]!==O||t[75]!==k?(A=(0,Q.jsx)(xe,{t:n,values:r.inlinePreviewMimes,disabled:O,onChange:k}),t[72]=r.inlinePreviewMimes,t[73]=n,t[74]=O,t[75]=k,t[76]=A):A=t[76];let j;t[77]!==D||t[78]!==A||t[79]!==s||t[80]!==u?(j=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[s,u,D,A]}),t[77]=D,t[78]=A,t[79]=s,t[80]=u,t[81]=j):j=t[81];let M;t[82]===n.policySiteSection?M=t[83]:(M=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policySiteSection}),t[82]=n.policySiteSection,t[83]=M);let N;t[84]===n.policySiteSectionHint?N=t[85]:(N=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policySiteSectionHint}),t[84]=n.policySiteSectionHint,t[85]=N);let P;t[86]!==M||t[87]!==N?(P=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[M,N]}),t[86]=M,t[87]=N,t[88]=P):P=t[88];let ne;t[89]===i?ne=t[90]:(ne=e=>i({siteEnabled:e.target.checked}),t[89]=i,t[90]=ne);let F;t[91]!==r.siteEnabled||t[92]!==ne?(F=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.siteEnabled,onChange:ne}),t[91]=r.siteEnabled,t[92]=ne,t[93]=F):F=t[93];let I;t[94]!==n.policySiteEnabled||t[95]!==F?(I=(0,Q.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[F,n.policySiteEnabled]}),t[94]=n.policySiteEnabled,t[95]=F,t[96]=I):I=t[96];let re=!r.siteEnabled,ie;t[97]===i?ie=t[98]:(ie=e=>i({siteDefaultTtlHours:e}),t[97]=i,t[98]=ie);let L;t[99]!==r.siteDefaultTtlHours||t[100]!==n.policySiteDefaultTtlHint||t[101]!==n.policySiteDefaultTtlHours||t[102]!==re||t[103]!==ie?(L=(0,Q.jsx)($,{id:`site-share-default-ttl-hours`,label:n.policySiteDefaultTtlHours,hint:n.policySiteDefaultTtlHint,value:r.siteDefaultTtlHours,min:1,max:168,disabled:re,onChange:ie}),t[99]=r.siteDefaultTtlHours,t[100]=n.policySiteDefaultTtlHint,t[101]=n.policySiteDefaultTtlHours,t[102]=re,t[103]=ie,t[104]=L):L=t[104];let ae=!r.siteEnabled,R;t[105]===i?R=t[106]:(R=e=>i({siteMaxTtlDays:e}),t[105]=i,t[106]=R);let oe;t[107]!==r.siteMaxTtlDays||t[108]!==n.policySiteMaxTtlDays||t[109]!==n.policySiteMaxTtlHint||t[110]!==ae||t[111]!==R?(oe=(0,Q.jsx)($,{id:`site-share-max-ttl-days`,label:n.policySiteMaxTtlDays,hint:n.policySiteMaxTtlHint,value:r.siteMaxTtlDays,min:1,max:30,disabled:ae,onChange:R}),t[107]=r.siteMaxTtlDays,t[108]=n.policySiteMaxTtlDays,t[109]=n.policySiteMaxTtlHint,t[110]=ae,t[111]=R,t[112]=oe):oe=t[112];let se=!r.siteEnabled,z;t[113]===i?z=t[114]:(z=e=>i({maxActiveSites:e}),t[113]=i,t[114]=z);let B;t[115]!==r.maxActiveSites||t[116]!==n.policyMaxActiveSites||t[117]!==n.policyMaxActiveSitesHint||t[118]!==se||t[119]!==z?(B=(0,Q.jsx)($,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,disabled:se,onChange:z}),t[115]=r.maxActiveSites,t[116]=n.policyMaxActiveSites,t[117]=n.policyMaxActiveSitesHint,t[118]=se,t[119]=z,t[120]=B):B=t[120];let ce=!r.siteEnabled,V;t[121]===i?V=t[122]:(V=e=>i({siteMaxRootDirSizeMb:e}),t[121]=i,t[122]=V);let H;t[123]!==r.siteMaxRootDirSizeMb||t[124]!==n.policySiteMaxRootDirSizeHint||t[125]!==n.policySiteMaxRootDirSizeMb||t[126]!==ce||t[127]!==V?(H=(0,Q.jsx)($,{id:`site-share-max-root-size-mb`,label:n.policySiteMaxRootDirSizeMb,hint:n.policySiteMaxRootDirSizeHint,value:r.siteMaxRootDirSizeMb,min:1,max:10240,disabled:ce,onChange:V}),t[123]=r.siteMaxRootDirSizeMb,t[124]=n.policySiteMaxRootDirSizeHint,t[125]=n.policySiteMaxRootDirSizeMb,t[126]=ce,t[127]=V,t[128]=H):H=t[128];let U=!r.siteEnabled,W;t[129]===i?W=t[130]:(W=e=>i({siteMaxFileCount:e}),t[129]=i,t[130]=W);let G;t[131]!==r.siteMaxFileCount||t[132]!==n.policySiteMaxFileCount||t[133]!==n.policySiteMaxFileCountHint||t[134]!==U||t[135]!==W?(G=(0,Q.jsx)($,{id:`site-share-max-files`,label:n.policySiteMaxFileCount,hint:n.policySiteMaxFileCountHint,value:r.siteMaxFileCount,min:1,max:1e5,disabled:U,onChange:W}),t[131]=r.siteMaxFileCount,t[132]=n.policySiteMaxFileCount,t[133]=n.policySiteMaxFileCountHint,t[134]=U,t[135]=W,t[136]=G):G=t[136];let K;t[137]!==L||t[138]!==oe||t[139]!==B||t[140]!==H||t[141]!==G?(K=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[L,oe,B,H,G]}),t[137]=L,t[138]=oe,t[139]=B,t[140]=H,t[141]=G,t[142]=K):K=t[142];let q;t[143]!==P||t[144]!==I||t[145]!==K?(q=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[P,I,K]}),t[143]=P,t[144]=I,t[145]=K,t[146]=q):q=t[146];let le;return t[147]!==j||t[148]!==q?(le=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[j,q]}),t[147]=j,t[148]=q,t[149]=le):le=t[149],le}function $(e){let t=(0,ue.c)(21),{id:n,label:r,hint:i,value:a,min:o,max:s,disabled:c,onChange:l}=e,u;t[0]!==n||t[1]!==r?(u=(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]=u):u=t[2];let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=f(ve(),`max-w-xs font-mono text-xs`),t[3]=d):d=t[3];let p;t[4]!==s||t[5]!==o||t[6]!==l?(p=e=>{let t=Number(e.target.value);Number.isFinite(t)&&l(Math.max(o,Math.min(s,Math.floor(t))))},t[4]=s,t[5]=o,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==c||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==p||t[13]!==a?(m=(0,Q.jsx)(`input`,{id:n,type:`number`,min:o,max:s,disabled:c,className:d,value:a,onChange:p}),t[8]=c,t[9]=n,t[10]=s,t[11]=o,t[12]=p,t[13]=a,t[14]=m):m=t[14];let h;t[15]===i?h=t[16]:(h=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=h);let g;return t[17]!==u||t[18]!==m||t[19]!==h?(g=(0,Q.jsxs)(`div`,{children:[u,m,h]}),t[17]=u,t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function xe(e){let t=(0,ue.c)(25),{t:n,values:r,disabled:i,onChange:a}=e,o;t[0]!==a||t[1]!==r?(o=e=>{let t=e.trim();!t||r.includes(t)||r.length>=32||a([...r,t])},t[0]=a,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===n.policyInlinePreviewMimes?c=t[4]:(c=(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.policyInlinePreviewMimes}),t[3]=n.policyInlinePreviewMimes,t[4]=c);let l;t[5]===n.policyInlinePreviewMimesHint?l=t[6]:(l=(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.policyInlinePreviewMimesHint}),t[5]=n.policyInlinePreviewMimesHint,t[6]=l);let u;t[7]!==i||t[8]!==a||t[9]!==r?(u=r.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,i?null:(0,Q.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,"aria-label":`Remove ${e}`,onClick:()=>a(r.filter(t=>t!==e)),children:`×`})]},e)),t[7]=i,t[8]=a,t[9]=r,t[10]=u):u=t[10];let d;t[11]===u?d=t[12]:(d=(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u}),t[11]=u,t[12]=d);let p;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(p=f(ve(),`font-mono text-xs`),t[13]=p):p=t[13];let m=i||r.length>=32,h;t[14]===s?h=t[15]:(h=e=>{e.key===`Enter`&&(e.preventDefault(),s(e.target.value),e.target.value=``)},t[14]=s,t[15]=h);let g;t[16]!==n.policyMimePlaceholder||t[17]!==m||t[18]!==h?(g=(0,Q.jsx)(`input`,{className:p,placeholder:n.policyMimePlaceholder,disabled:m,onKeyDown:h}),t[16]=n.policyMimePlaceholder,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==c||t[21]!==l||t[22]!==d||t[23]!==g?(_=(0,Q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[c,l,d,g]}),t[20]=c,t[21]=l,t[22]=d,t[23]=g,t[24]=_):_=t[24],_}function Se(e){let t=(0,ue.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:a,selectKind:c,sessionKey:u,agentId:m}=e,h=c===void 0?`any`:c,y=g(v(Te)),b=y.workspace,E=y.sharesSettings,D=oe(we),{data:O}=te(_(Ce)?`picker-agents-list`:null,P),k;bb0:{let e;t[0]===m?e=t[1]:(e=m?.trim(),t[0]=m,t[1]=e);let n=e;if(n){k=n;break bb0}let r;t[2]===D?r=t[3]:(r=D.trim(),t[2]=D,t[3]=r);let i=r;if(i){k=i;break bb0}if(O?.defaultId){k=O.defaultId;break bb0}if(O?.agents?.[0]?.id){k=O.agents[0].id;break bb0}k=``}let M=k,[N,I]=(0,J.useState)(M),re,L;t[4]===M?(re=t[5],L=t[6]):(re=()=>{I(M)},L=[M],t[4]=M,t[5]=re,t[6]=L),(0,J.useEffect)(re,L);let{tree:ae,loading:R,error:se,loadRoot:z,loadChildren:B,reset:ce}=ie(N,u??null),V;t[7]===a?V=t[8]:(V=a?{path:a,isDirectory:!1}:null,t[7]=a,t[8]=V);let[H,U]=(0,J.useState)(V),W;t[9]!==a||t[10]!==z||t[11]!==n||t[12]!==ce||t[13]!==U?(W=()=>{if(!n){ce(),U(a?{path:a,isDirectory:!1}:null);return}z()},t[9]=a,t[10]=z,t[11]=n,t[12]=ce,t[13]=U,t[14]=W):W=t[14];let G;t[15]!==a||t[16]!==z||t[17]!==n||t[18]!==N||t[19]!==ce||t[20]!==u?(G=[n,N,u,z,ce,a],t[15]=a,t[16]=z,t[17]=n,t[18]=N,t[19]=ce,t[20]=u,t[21]=G):G=t[21],(0,J.useEffect)(W,G);let K;t[22]===B?K=t[23]:(K=e=>{B(e)},t[22]=B,t[23]=K);let q=K,le=H!==null&&(h===`any`||h===`file`&&!H.isDirectory||h===`directory`&&H.isDirectory),Y;bb1:{if(!H){Y=E.pickerHintNone;break bb1}if(h===`file`&&H.isDirectory){Y=E.pickerHintNeedsFile;break bb1}if(h===`directory`&&!H.isDirectory){Y=E.pickerHintNeedsDirectory;break bb1}Y=`${H.isDirectory?`📁`:`📄`} ${H.path}`}let de=Y,fe=O?.agents??[],X;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Q.jsx)(x,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=X):X=t[24];let Z;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Z=f(`fixed left-1/2 top-1/2 z-[71] w-[min(34rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2`,`flex h-[min(28rem,calc(100vh-3rem))] flex-col overflow-hidden rounded-lg border border-edge bg-surface-panel shadow-popover outline-none`),t[25]=Z):Z=t[25];let pe;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Q.jsx)(j,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=pe):pe=t[26];let me=y.cron.refresh,he=y.cron.refresh,ge;t[27]===z?ge=t[28]:(ge=()=>void z(),t[27]=z,t[28]=ge);let _e=R&&`animate-spin`,ve;t[29]===_e?ve=t[30]:(ve=f(`size-4`,_e),t[29]=_e,t[30]=ve);let ye;t[31]===ve?ye=t[32]:(ye=(0,Q.jsx)(ne,{className:ve,"aria-hidden":!0}),t[31]=ve,t[32]=ye);let be;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Q.jsx)(d,{className:`size-4`}),t[33]=be):be=t[33];let $;t[34]!==se||t[35]!==b.loadError?($=se?(0,Q.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[b.loadError,`: `,se]}):null,t[34]=se,t[35]=b.loadError,t[36]=$):$=t[36];let xe;t[37]!==q||t[38]!==R||t[39]!==H?.path||t[40]!==U||t[41]!==b.emptyDir||t[42]!==b.title||t[43]!==ae?(xe=R&&ae.length===0?(0,Q.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,Q.jsx)(l,{className:`size-4 animate-spin`}),b.title,`…`]}):(0,Q.jsx)(F,{tree:ae,selectedPath:H?.path??null,onSelectFile:e=>U({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>U({path:e,isDirectory:t}),onExpandDir:q,onAction:void 0,emptyHint:b.emptyDir}),t[37]=q,t[38]=R,t[39]=H?.path,t[40]=U,t[41]=b.emptyDir,t[42]=b.title,t[43]=ae,t[44]=xe):xe=t[44];let Se;t[45]!==$||t[46]!==xe?(Se=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[$,xe]}),t[45]=$,t[46]=xe,t[47]=Se):Se=t[47];let Ee;t[48]===de?Ee=t[49]:(Ee=(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:de}),t[48]=de,t[49]=Ee);let De;t[50]===r?De=t[51]:(De=()=>r(!1),t[50]=r,t[51]=De);let Oe;t[52]!==E.cancel||t[53]!==De?(Oe=(0,Q.jsx)(p,{type:`button`,variant:`ghost`,onClick:De,children:E.cancel}),t[52]=E.cancel,t[53]=De,t[54]=Oe):Oe=t[54];let ke=!le,Ae;t[55]!==i||t[56]!==r||t[57]!==N||t[58]!==H?(Ae=()=>{H&&(i({...H,agentId:N}),r(!1))},t[55]=i,t[56]=r,t[57]=N,t[58]=H,t[59]=Ae):Ae=t[59];let je;t[60]!==E.pickerConfirm||t[61]!==ke||t[62]!==Ae?(je=(0,Q.jsx)(p,{type:`button`,disabled:ke,onClick:Ae,children:E.pickerConfirm}),t[60]=E.pickerConfirm,t[61]=ke,t[62]=Ae,t[63]=je):je=t[63];let Me;t[64]!==Oe||t[65]!==je?(Me=(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Oe,je]}),t[64]=Oe,t[65]=je,t[66]=Me):Me=t[66];let Ne;return t[67]!==Ee||t[68]!==Me?(Ne=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[Ee,Me]}),t[67]=Ee,t[68]=Me,t[69]=Ne):Ne=t[69],(0,Q.jsx)(T,{open:n,onOpenChange:r,children:(0,Q.jsxs)(ee,{children:[X,(0,Q.jsxs)(C,{className:Z,children:[(0,Q.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[pe,(0,Q.jsx)(w,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:E.pickerTitle}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:me,"aria-label":he,disabled:R,onClick:ge,children:ye}),(0,Q.jsx)(S,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":b.close,children:be})})]}),fe.length>0?(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,Q.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:E.pickerAgentLabel}),(0,Q.jsx)(o,{id:`picker-agent-select`,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:N,onChange:e=>{I(e.target.value),U(null)},children:fe.map(e=>(0,Q.jsxs)(s,{value:e.id,children:[A(e,y.agentsSettings),e.id===O?.defaultId?` ★`:``]},e.id))})]}):null,Se,Ne]})]})})}function Ce(e){return e.token}function we(e){return e.agentId}function Te(e){return e.language}var Ee=[`shares`,`policy`];function De(e){let t=(e??``).trim();return Ee.includes(t)?t:`shares`}function Oe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function ke(e,t){let n=new Date(e).getTime()-Date.now(),r=Math.abs(n),i=n<0;if(r<6e4)return t===`zh`?`刚刚`:`just now`;let a=Math.floor(r/6e4);if(a<60){let e=t===`zh`?`${a} 分钟`:`${a}m`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let o=Math.floor(a/60);if(o<24){let e=t===`zh`?`${o} 小时`:`${o}h`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let s=Math.floor(o/24),c=t===`zh`?`${s} 天`:`${s}d`;return i?t===`zh`?`${c}前`:`${c} ago`:c}var Ae=[{value:36e5,key:`1h`},{value:216e5,key:`6h`},{value:864e5,key:`24h`},{value:2592e5,key:`3d`},{value:6048e5,key:`7d`},{value:2592e6,key:`30d`}];function je(){let e=(0,ue.c)(24),t=v(Ne),n=g(t).sharesSettings,r=!!_(Me),[a,o]=i(),s;e[0]===a?s=e[1]:(s=De(a.get(`tab`)),e[0]=a,e[1]=s);let c=s,l;e[2]===o?l=e[3]:(l=e=>{o(t=>{let n=new URLSearchParams(t);return e===`shares`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[2]=o,e[3]=l);let u=l;if(!r)return(0,Q.jsx)(W,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let d={shares:n.tabShares,policy:n.tabPolicy},f=Ee.map(e=>({id:e,label:d[e]})),p;e[4]!==n.subtitle||e[5]!==n.title?(p=(0,Q.jsx)(U,{title:n.title,subtitle:n.subtitle}),e[4]=n.subtitle,e[5]=n.title,e[6]=p):p=e[6];let m;e[7]!==c||e[8]!==u||e[9]!==n.tabsAria||e[10]!==f?(m=(0,Q.jsx)(le,{items:f,activeTab:c,onChange:u,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[7]=c,e[8]=u,e[9]=n.tabsAria,e[10]=f,e[11]=m):m=e[11];let h;e[12]!==c||e[13]!==r||e[14]!==t||e[15]!==n?(h=c===`shares`?(0,Q.jsx)(Pe,{t:n,language:t}):(0,Q.jsx)(ye,{hasToken:r}),e[12]=c,e[13]=r,e[14]=t,e[15]=n,e[16]=h):h=e[16];let y;e[17]!==c||e[18]!==h?(y=(0,Q.jsx)(G,{id:c,activeTab:c,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:h}),e[17]=c,e[18]=h,e[19]=y):y=e[19];let b;return e[20]!==p||e[21]!==m||e[22]!==y?(b=(0,Q.jsxs)(W,{children:[p,m,y]}),e[20]=p,e[21]=m,e[22]=y,e[23]=b):b=e[23],b}function Me(e){return e.token}function Ne(e){return e.language}function Pe(e){let t=(0,ue.c)(60),{t:n,language:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:3e4},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,mutate:c}=te(`shares-list`,R,i),l;t[1]===a?.payload?.shares?l=t[2]:(l=a?.payload?.shares??[],t[1]=a?.payload?.shares,t[2]=l);let u=l,[d,m]=(0,J.useState)(!1),h;bb0:{if(d){h=u;break bb0}let e;t[3]===u?e=t[4]:(e=u.filter(ze),t[3]=u,t[4]=e),h=e}let g=h,_;t[5]===u?_=t[6]:(_=u.filter(Re),t[5]=u,t[6]=_);let v=_.length,y;t[7]===u?y=t[8]:(y=u.filter(Le),t[7]=u,t[8]=y);let b=y.length,x;t[9]===c?x=t[10]:(x=()=>void c(),t[9]=c,t[10]=x);let S;t[11]!==n||t[12]!==x?(S=(0,Q.jsx)(Ve,{t:n,onCreated:x}),t[11]=n,t[12]=x,t[13]=S):S=t[13];let ee=d?n.allSharesTitle:n.listTitle,C;t[14]===v?C=t[15]:(C=v>0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,v,`)`]}),t[14]=v,t[15]=C);let w;t[16]!==ee||t[17]!==C?(w=(0,Q.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[ee,C]}),t[16]=ee,t[17]=C,t[18]=w):w=t[18];let T;t[19]===c?T=t[20]:(T=()=>void c(),t[19]=c,t[20]=T);let E=s&&`animate-spin`,D;t[21]===E?D=t[22]:(D=f(`size-3.5`,E),t[21]=E,t[22]=D);let O;t[23]===D?O=t[24]:(O=(0,Q.jsx)(ne,{className:D}),t[23]=D,t[24]=O);let k;t[25]!==s||t[26]!==T||t[27]!==O?(k=(0,Q.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:T,disabled:s,children:O}),t[25]=s,t[26]=T,t[27]=O,t[28]=k):k=t[28];let A;t[29]!==b||t[30]!==d||t[31]!==n.hideExpired||t[32]!==n.showExpired?(A=b>0&&(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>m(Ie),children:d?n.hideExpired:n.showExpired}),t[29]=b,t[30]=d,t[31]=n.hideExpired,t[32]=n.showExpired,t[33]=A):A=t[33];let j;t[34]!==k||t[35]!==A?(j=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[k,A]}),t[34]=k,t[35]=A,t[36]=j):j=t[36];let M;t[37]!==w||t[38]!==j?(M=(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[w,j]}),t[37]=w,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==a||t[41]!==o||t[42]!==g||t[43]!==s||t[44]!==r||t[45]!==c||t[46]!==n?(N=s&&!a?(0,Q.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(Fe)}):o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,Q.jsx)(`span`,{children:n.error}),(0,Q.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void c(),children:n.retry})]}):g.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map(e=>(0,Q.jsx)(Ue,{share:e,t:n,language:r,onRevoked:()=>void c(),onExtended:()=>void c()},e.id))}),t[40]=a,t[41]=o,t[42]=g,t[43]=s,t[44]=r,t[45]=c,t[46]=n,t[47]=N):N=t[47];let P;t[48]!==b||t[49]!==c||t[50]!==d||t[51]!==n?(P=b>0&&d&&(0,Q.jsx)(We,{t:n,onCleaned:()=>void c()}),t[48]=b,t[49]=c,t[50]=d,t[51]=n,t[52]=P):P=t[52];let F;t[53]!==M||t[54]!==N||t[55]!==P?(F=(0,Q.jsxs)(q,{children:[M,N,P]}),t[53]=M,t[54]=N,t[55]=P,t[56]=F):F=t[56];let I;return t[57]!==F||t[58]!==S?(I=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[S,F]}),t[57]=F,t[58]=S,t[59]=I):I=t[59],I}function Fe(e,t){return(0,Q.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(k,{className:`h-4 w-2/3`}),(0,Q.jsx)(k,{className:`mt-2 h-3 w-1/2`})]}),(0,Q.jsx)(k,{className:`h-7 w-20 rounded-md`})]})},t)}function Ie(e){return!e}function Le(e){return e.expired||e.revoked}function Re(e){return!e.expired&&!e.revoked}function ze(e){return!e.expired&&!e.revoked}var Be={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function Ve({t:e,onCreated:t}){let[n,r]=(0,J.useReducer)(O,Be),{expanded:i,path:a,isDirectory:c,agentId:d,ttlMs:m,maxViews:h,description:g,directoryMode:_,creating:v,result:y,errorMsg:b,resultDialogOpen:x,pickerOpen:S}=n,ee=(0,J.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await ce({path:a.trim(),ttlMs:m,maxViews:h,description:g.trim()||void 0,...d?{agentId:d}:{},...c?{kind:`directory`,directoryMode:_}:{}})).payload,resultDialogOpen:!0}}),t()}catch(e){r({type:`patch`,patch:{errorMsg:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{creating:!1}})}}},[a,c,d,m,h,g,_,t]),C=(0,J.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,Q.jsxs)(q,{children:[(0,Q.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:f(`flex min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm`,a?`text-fg`:`text-fg-subtle`),children:a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,children:c?`📁`:`📄`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:a})]}):(0,Q.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,Q.jsxs)(p,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,Q.jsx)(N,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),c?(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,Q.jsxs)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:_,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,Q.jsx)(s,{value:`browse`,children:e.directoryModeBrowse}),(0,Q.jsx)(s,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,Q.jsx)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:m,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:Ae.map(t=>(0,Q.jsx)(s,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,Q.jsxs)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:h??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,Q.jsx)(s,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,Q.jsx)(s,{value:`1`,children:`1`}),(0,Q.jsx)(s,{value:`5`,children:`5`}),(0,Q.jsx)(s,{value:`10`,children:`10`}),(0,Q.jsx)(s,{value:`50`,children:`50`}),(0,Q.jsx)(s,{value:`100`,children:`100`})]})]})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,Q.jsx)(`input`,{type:`text`,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:outline-none focus:ring-2 focus:ring-accent`,placeholder:e.descriptionPlaceholder,value:g,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Q.jsxs)(p,{type:`button`,disabled:v||!a.trim(),onClick:()=>void ee(),children:[v?(0,Q.jsx)(l,{className:`size-4 animate-spin`}):(0,Q.jsx)(u,{className:`size-4`}),v?e.creating:e.createButton]}),(0,Q.jsx)(p,{type:`button`,variant:`ghost`,onClick:()=>{C(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),b&&(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b})]}),(0,Q.jsx)(V,{open:x,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:y}),(0,Q.jsx)(Se,{open:S,onOpenChange:e=>r({type:`patch`,patch:{pickerOpen:e}}),initialPath:a||void 0,selectKind:`any`,onConfirm:e=>r({type:`patch`,patch:{path:e.path,isDirectory:e.isDirectory,agentId:e.agentId,directoryMode:`browse`}})})]}):(0,Q.jsxs)(p,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,Q.jsx)(u,{className:`size-4`}),e.createTitle]})}var He={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function Ue({share:e,t,language:n,onRevoked:r,onExtended:i}){let[o,s]=(0,J.useReducer)(O,He),{revokeOpen:u,revoking:d,linksOpen:m,urlCopied:g,copyFailed:_,extending:v}=o,y=!e.expired&&!e.revoked,b=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,x=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,S=(0,J.useCallback)(async()=>{s({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await ae(e.id),r()}catch{}finally{s({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),ee=(0,J.useCallback)(async()=>{if(s({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await h(e.shareUrl)){s({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>s({type:`patch`,patch:{copyFailed:!1}}),2500);return}s({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>s({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),C=(0,J.useCallback)(async()=>{s({type:`patch`,patch:{extending:!0}});try{await se(e.id,864e5),i()}catch{}finally{s({type:`patch`,patch:{extending:!1}})}},[e.id,i]),w=`share-links-${e.id}`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:f(`flex min-w-0 flex-1 items-start gap-3 rounded-md text-left`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),"aria-expanded":m,"aria-controls":w,onClick:()=>s({type:`patch`,patch:{linksOpen:!m}}),children:[(0,Q.jsx)(M,{className:f(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,m?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),(0,Q.jsx)(N,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,Q.jsx)(`span`,{className:f(`text-xs font-medium`,x),children:b})]}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.workspaceRelativePath}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:Oe(e.fileSize)}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(B,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:ke(e.expiresAt,n)]}),(0,Q.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,Q.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:y&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void ee(),children:g?(0,Q.jsx)(a,{className:`size-3.5 text-emerald-500`}):(0,Q.jsx)(c,{className:`size-3.5`})}),(0,Q.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void C(),disabled:v,title:t.extend,children:v?(0,Q.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(B,{className:`size-3.5`})}),(0,Q.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>s({type:`patch`,patch:{revokeOpen:!0}}),disabled:d,children:d?(0,Q.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(re,{className:`size-3.5`})})]})})]}),y&&m?(0,Q.jsxs)(`div`,{id:w,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,Q.jsx)(H,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),_?(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(I,{reachability:e.reachability})})]}):null]}),(0,Q.jsx)(z,{open:u,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void S(),onCancel:()=>s({type:`patch`,patch:{revokeOpen:!1}})})]})}function We({t:e,onCleaned:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!1),o=(0,J.useCallback)(async()=>{r(!1),a(!0);try{await L(),t()}catch{}finally{a(!1)}},[t]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Q.jsxs)(p,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>r(!0),className:`border-danger/40 px-2 py-1 text-xs text-danger hover:bg-danger/10`,children:[i?(0,Q.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(re,{className:`size-3.5`}),e.cleanExpired]})}),(0,Q.jsx)(z,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{je as SharesSettingsPanel};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{o as t,r as n}from"./locale-store-CbPVxonP.js";import{Kn as r}from"./index-BBw9QL0p.js";var i=e({reloadSkills:()=>a});async function a(){let e=await t(n(`/api/skills/reload`),{method:`POST`});if(!e.ok)throw Error(await r(e))}export{i as n,a as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,f as a,t as o}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as s,r as c}from"./popover-select-BzdnTy3h.js";import{t as l}from"./external-link-DjqjBmc3.js";import{f as u,u as ee}from"./markdown-view-Dl-0_9JR.js";import{t as te}from"./x-B_N4OPjy.js";import{t as d}from"./cn-JdwAhgNB.js";import{t as f}from"./button-CSEbl4zT.js";import{l as p,n as ne}from"./locale-store-CbPVxonP.js";import{i as m,n as re,o as ie,r as h,s as ae,t as g}from"./dist-BPoKqzeH.js";import{A as _,Aa as v,Bl as oe,Gt as se,H as y,K as ce,Kt as le,M as b,R as x,Va as S,Vc as C,Vs as w,W as T,Xc as E,Xr as D,Yi as O,ci as ue,dl as k,dr as A,fa as j,fr as de,gr as fe,ka as pe,mr as me,n as he,pr as ge,q as _e,qs as ve,qt as ye,rc as be,si as M,ul as N,vl as xe}from"./index-BBw9QL0p.js";import{t as Se}from"./date-picker-BNHd7HT7.js";import{t as Ce}from"./dependency-picker-D1kJBknt.js";var P=e(t(),1),F=n();function we(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function Te(e,t){let n={...e.task};t.title!==void 0&&(n.title=t.title),t.priority!==void 0&&(n.priority=t.priority);for(let e of[`body`,`projectId`,`milestoneId`,`parentTaskId`,`dueAt`,`ownerId`]){let r=t[e];r!==void 0&&(r===null?delete n[e]:Object.assign(n,{[e]:r}))}return n.version+=1,n.updatedAt=Date.now(),{...e,task:n}}var I=r();function Ee(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已完成`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Completed`})[e]}function De(){let e=(0,F.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,I.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,I.jsx)(v,{className:`h-32 rounded-2xl`}),(0,I.jsx)(v,{className:`h-52 rounded-2xl`}),(0,I.jsx)(v,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Oe(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function ke(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var Ae=`xopc.taskDetail.chatPanelPercent`,L=42;function je(e,t){let n=Math.max(30,352/Math.max(t,1)*100),r=Math.min(60,(t-480)/Math.max(t,1)*100);return r<n?L:Math.min(r,Math.max(n,e))}function Me(){try{let e=Number(window.localStorage.getItem(Ae));return Number.isFinite(e)&&e>=30&&e<=60?e:L}catch{return L}}function Ne(e){return e.task.phase===`closed`?e.task.resolution===`done`?`completed`:`ended`:e.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`)?`needsUser`:e.operationalState===`idle`?e.task.phase===`backlog`?`captured`:e.task.phase===`ready`?`ready`:e.task.phase===`review`?`review`:`paused`:e.operationalState}function R(e){let t=(0,F.c)(9),{items:n,empty:r,verificationByCriterion:i}=e;if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,I.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:r}),t[0]=r,t[1]=e),e}let a;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>{let t=i?.get(e)??`unverified`;return(0,I.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,I.jsx)(t===`passed`?xe:t===`failed`?k:N,{className:t===`passed`?`mt-1 size-4 shrink-0 text-success`:t===`failed`?`mt-1 size-4 shrink-0 text-danger`:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,I.jsx)(`span`,{children:e})]},e)},t[5]=i,t[6]=e),a=n.map(e),t[2]=n,t[3]=i,t[4]=a}else a=t[4];let o;return t[7]===a?o=t[8]:(o=(0,I.jsx)(`ul`,{className:`space-y-2`,children:a}),t[7]=a,t[8]=o),o}function Pe({taskId:e,presentation:t,backgroundPath:n}){let[r]=a(),i=ne(e=>e.language),te=p(e=>e.token),m=(0,P.useMemo)(()=>_e(i),[i]),re=S(e=>e.setPageHeader),ie=S(e=>e.clearPageHeader),{data:h,error:ae,mutate:g,lastChange:v,conversationLoading:ue,conversationError:k}=_(e),[ye,M]=(0,P.useState)(null),[N,F]=(0,P.useState)(!1),[Pe,z]=(0,P.useState)([]),[B,V]=(0,P.useState)(null),[Fe,Ie]=(0,P.useState)([]),[Le,H]=(0,P.useState)(!1),[U,W]=(0,P.useState)(``),[Re,G]=(0,P.useState)(!1),[ze,Be]=(0,P.useState)(``),[K,Ve]=(0,P.useState)(Me),[He,Ue]=(0,P.useState)(!1),We=(0,P.useRef)(null),Ge=(0,P.useRef)(!1),Ke=(0,P.useRef)(!1),qe=(0,P.useRef)(``),Je=(0,P.useRef)(null),Ye=(0,P.useRef)(null),Xe=(0,P.useRef)(null),[Ze,q]=(0,P.useState)(null),[Qe,$e]=(0,P.useState)(null),et=h?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,tt=(0,P.useMemo)(()=>ee(r.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[r]);(0,P.useEffect)(()=>{M(null),q(null),H(!1),G(!1),$e(null)},[e]),(0,P.useEffect)(()=>{let e=!0;return pe().then(t=>{e&&Ie(t.items)}).catch(()=>void 0),()=>{e=!1}},[te]),(0,P.useEffect)(()=>{if(!v||v.source===`user`)return;$e(v);let e=window.setTimeout(()=>$e(null),3500);return()=>window.clearTimeout(e)},[v]),(0,P.useEffect)(()=>{let t=h?.task.projectId,n=h?.dependencies??[];if(!t){Xe.current=null,V(null),z(n);return}Xe.current!==t&&(Xe.current=t,V(null));let r=!0;return j(t).then(t=>{if(!r)return;V(t.project.name);let i=new Map;for(let r of[...t.tasks,...n])r.id!==e&&i.set(r.id,{id:r.id,title:r.title});z([...i.values()])}).catch(()=>{r&&z(n)}),()=>{r=!1}},[et,h?.task.projectId,e]);let J=async t=>{if(h){F(!0),M(null);try{await g(await b(e,t,h.task.version),{revalidate:!1})}catch{M(m.actionFailed)}finally{F(!1)}}},Y=async t=>{if(!h)return!1;F(!0),M(null);try{return await g(T(e,t,h.task.version),{optimisticData:Te(h,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return M(m.actionFailed),!1}finally{F(!1)}},nt=async()=>{if(!h)return;if(Ge.current){Ge.current=!1;return}let e=U.trim(),t=Je.current;if(we(t,h.task.version,h.task.title,e)){q(`title`);return}if(!e||e===h.task.title){W(h.task.title),H(!1);return}await Y({title:e})&&(q(null),H(!1))},rt=async()=>{if(!h)return;if(Ke.current){Ke.current=!1;return}let e=ze.trim(),t=Ye.current;if(we(t,h.task.version,h.task.body??``,e)){q(`description`);return}if(ze===qe.current||e===(h.task.body??``).trim()){G(!1);return}await Y({body:e||null})&&(q(null),G(!1))},it=async e=>{if(!(!h||e===h.task.phase)){if(h.task.phase===`closed`){await J({type:`reopen`,phase:e===`closed`?`ready`:e});return}if(e===`closed`){await J({type:`close`,resolution:`done`});return}await J({type:`move`,phase:e})}},X=(0,P.useCallback)(e=>{Ve(e);try{window.localStorage.setItem(Ae,String(e))}catch{}},[]),at=(0,P.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=We.current?.clientWidth??0;X(je(e.key===`Home`?L:K+(e.key===`ArrowLeft`?2:-2),t))},[K,X]),ot=(0,P.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=We.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),Ue(!0);let i=K,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=je((n.right-e.clientX)/n.width*100,n.width),a===0&&(a=window.requestAnimationFrame(o))},c=()=>{a!==0&&(window.cancelAnimationFrame(a),o());try{n.releasePointerCapture(r)}catch{}Ue(!1),X(i),window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[K,X]),st=async t=>{if(h){F(!0),M(null);try{await g(await ce(e,t,h.task.version),{revalidate:!1})}catch{M(m.dependencyUpdateFailed)}finally{F(!1)}}},ct=async t=>{if(!(!h||!t||t===h.conversation.currentExecutorAgentId)){F(!0),M(null);try{await g(await x(e,t,h.task.version),{revalidate:!1})}catch{M(m.actionFailed)}finally{F(!1)}}};if((0,P.useLayoutEffect)(()=>{if(t!==`modal`)return re({startExtra:(0,I.jsx)(o,{to:tt,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":m.backToWork,children:(0,I.jsx)(oe,{className:`size-4`})}),main:h?(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:B?`${B} / ${m.taskLabel}`:m.taskLabel}),(0,I.jsx)(`p`,{className:`text-xs text-fg-muted`,children:m.detailStatuses[Ne(h)]})]}):null,end:null}),ie},[ie,m.backToWork,m.detailStatuses,m.taskLabel,h,t,B,tt,re]),ae&&!h)return(0,I.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:m.taskNotFound});if(!h)return(0,I.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,I.jsx)(De,{})});let lt=h.waits[0],ut=lt?.kind===`paused`?lt:void 0,Z=h.receipts[0],dt=m.detailStatuses[Ne(h)],ft=m.detailStatusDescriptions[Ne(h)],pt=h.task.body?.trim()||h.task.contract?.objective.trim(),mt=new Map(Z?.verification.checks.map(e=>[e.criterion,e.status])),ht=h.allowedCommands.includes(`mark_ready`),gt=h.allowedCommands.includes(`start`),_t=h.allowedCommands.includes(`add_wait`),vt=h.task.phase===`review`&&h.allowedCommands.includes(`close`),yt=h.allowedCommands.includes(`reopen`),bt=h.conversation.activeSessionKey,Q=h.conversation.currentExecutorAgentId??h.task.delegateAgentId??h.task.ownerId,xt=Fe.find(e=>e.id===Q),St=h.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),Ct=h.task.contract?.acceptanceCriteria??[],wt=Ct.filter(e=>mt.get(e)===`passed`).length,Tt=h.task.contract?.expectedOutputs??[],Et=h.task.contract?.constraints??[],Dt=h.task.contract?.approvalRequired??[],Ot=h.task.contract?.assumptions??[],kt=h.task.contract?.risks??[],$=(...e)=>!!Qe?.changedFields.some(t=>e.includes(t)),At=e=>t===`modal`&&n?le(n,e):u(`/tasks/${e}`,tt),jt=h.allowedCommands.includes(`move`),Mt=e=>e!==h.task.phase&&(e===`closed`?!vt:h.task.phase===`closed`?!yt:!jt),Nt=(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[ht?(0,I.jsxs)(f,{variant:`primary`,disabled:N,onClick:()=>void J({type:`mark_ready`}),children:[(0,I.jsx)(w,{className:`size-4`}),m.scheduleTask]}):null,ut?(0,I.jsxs)(f,{variant:`primary`,disabled:N,onClick:()=>void J({type:`resolve_wait`,waitId:ut.id}),children:[(0,I.jsx)(w,{className:`size-4`}),m.resumeTask]}):null,!lt&&gt&&Q?(0,I.jsxs)(f,{variant:`primary`,disabled:N,onClick:()=>void J({type:`start`,executor:{kind:`agent`,agentId:Q}}),children:[(0,I.jsx)(w,{className:`size-4`}),m.runTask]}):null,vt?(0,I.jsxs)(f,{variant:`primary`,disabled:N,onClick:()=>void J({type:`close`,resolution:`done`}),children:[(0,I.jsx)(xe,{className:`size-4`}),m.approveTask]}):null,yt?(0,I.jsxs)(f,{variant:`primary`,disabled:N,onClick:()=>void J({type:`reopen`,phase:`ready`}),children:[(0,I.jsx)(w,{className:`size-4`}),m.reopenTask]}):null,!lt&&_t?(0,I.jsxs)(f,{variant:`secondary`,className:`border-0 bg-surface-hover shadow-none`,disabled:N,onClick:()=>void J({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,I.jsx)(ve,{className:`size-4`}),m.pauseTask]}):null,h.task.phase===`closed`?null:(0,I.jsxs)(me,{children:[(0,I.jsx)(fe,{asChild:!0,children:(0,I.jsx)(f,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:N,"aria-label":m.moreActions,children:(0,I.jsx)(E,{className:`size-4`,"aria-hidden":!0})})}),(0,I.jsx)(ge,{children:(0,I.jsx)(A,{align:`end`,sideOffset:6,className:`z-[100] min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:(0,I.jsx)(de,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void J({type:`close`,resolution:`cancelled`}),children:m.cancelTask})})})]})]});return(0,I.jsxs)(`div`,{ref:We,className:`${t===`modal`?`flex h-full min-h-0 flex-col lg:flex-row`:`flex min-h-[calc(100dvh-8rem)] flex-col overflow-hidden lg:flex-row`} ${He?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${K}%`},children:[(0,I.jsxs)(`section`,{className:`task-detail-scroll min-w-0 flex-1 overflow-y-auto overscroll-contain p-5 sm:p-6`,children:[(0,I.jsxs)(`header`,{className:d(`px-4 pb-5`,$(`title`)&&`task-detail-live-update`),children:[(0,I.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[B?(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,I.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),B]}):null,(0,I.jsx)(`span`,{children:`/`}),(0,I.jsx)(`span`,{children:m.taskLabel}),Qe?(0,I.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:Qe.source===`agent`?i===`zh`?`Agent 刚刚更新`:`Updated by Agent`:i===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),Le?(0,I.jsx)(`input`,{autoFocus:!0,"data-task-inline-editor":!0,value:U,onChange:e=>W(e.target.value),onBlur:()=>void nt(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Ge.current=!0,W(h.task.title),H(!1),queueMicrotask(()=>{Ge.current=!1}))},className:`mt-3 w-full max-w-3xl rounded-lg bg-surface-hover px-3 py-2 text-2xl font-semibold leading-8 text-fg outline-none ring-2 ring-accent/30 focus:ring-accent/60`}):(0,I.jsx)(`button`,{type:`button`,className:`mt-3 block max-w-3xl rounded-lg text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{Je.current={value:h.task.title,version:h.task.version},q(null),W(h.task.title),H(!0)},children:(0,I.jsx)(`h1`,{className:`text-2xl font-semibold leading-8 text-fg`,children:h.task.title})}),Ze===`title`?(0,I.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,I.jsx)(`span`,{children:i===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,I.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{W(h.task.title),q(null),H(!1)},children:i===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,I.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Y({title:U.trim()}).then(e=>{e&&(q(null),H(!1))}),children:i===`zh`?`保留我的修改`:`Keep my changes`})]}):null]})}),ye?(0,I.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:ye}):null]}),(0,I.jsxs)(`div`,{className:`mt-5 flex flex-col gap-5`,children:[(0,I.jsxs)(`main`,{className:`order-2 min-w-0 space-y-5`,children:[(0,I.jsxs)(`section`,{className:d(`rounded-xl bg-surface-panel p-4`,$(`body`)&&`task-detail-live-update`),children:[(0,I.jsx)(`h2`,{className:`font-medium text-fg`,children:m.taskDescription}),Re?(0,I.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:ze,onChange:e=>Be(e.target.value),onBlur:()=>void rt(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Ke.current=!0,Be(h.task.body??h.task.contract?.objective??``),G(!1),queueMicrotask(()=>{Ke.current=!1}))},className:`mt-3 w-full resize-y rounded-lg bg-surface-hover px-3 py-2 text-sm leading-6 text-fg outline-none ring-2 ring-accent/20 focus:ring-accent/50`}):(0,I.jsx)(`button`,{type:`button`,className:`-mx-1 mt-2 block w-[calc(100%+0.5rem)] rounded-lg px-1 py-1 text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{let e=h.task.body??h.task.contract?.objective??``;qe.current=e,Ye.current={value:h.task.body??``,version:h.task.version},q(null),Be(e),G(!0)},children:(0,I.jsx)(`span`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg-muted`,children:pt&&pt!==h.task.title?pt:m.noTaskDescription})}),Ze===`description`?(0,I.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,I.jsx)(`span`,{children:i===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,I.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{Be(h.task.body??``),q(null),G(!1)},children:i===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,I.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Y({body:ze.trim()||null}).then(e=>{e&&(q(null),G(!1))}),children:i===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),h.attention.length>0?(0,I.jsxs)(`section`,{className:d(`rounded-xl bg-warning/10 p-4`,$(`attention`)&&`task-detail-live-update`),children:[(0,I.jsx)(`h3`,{className:`font-medium text-fg`,children:St?m.needsAttention:m.waitingStatus}),(0,I.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm text-fg-muted`,children:h.attention.map((e,t)=>(0,I.jsx)(`li`,{children:e.summary},`${e.kind}-${t}`))})]}):null,(0,I.jsxs)(`section`,{className:d(`rounded-xl bg-surface-panel p-4`,$(`contract`)&&`task-detail-live-update`),children:[(0,I.jsx)(`h2`,{className:`font-medium text-fg`,children:m.taskDefinition}),(0,I.jsxs)(`div`,{className:`mt-5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:m.successDefinition}),Ct.length>0?(0,I.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:m.criteriaProgress.replace(`{{verified}}`,String(wt)).replace(`{{total}}`,String(Ct.length))}):null]}),(0,I.jsx)(`div`,{className:`mt-3`,children:(0,I.jsx)(R,{items:Ct,empty:m.noDefinition,verificationByCriterion:mt})})]}),Tt.length>0?(0,I.jsxs)(`div`,{className:`mt-5 rounded-lg bg-surface-hover p-4`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:m.expectedOutputs}),(0,I.jsx)(`div`,{className:`mt-3`,children:(0,I.jsx)(R,{items:Tt,empty:m.noDefinition})})]}):null,Et.length>0?(0,I.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:m.constraints}),(0,I.jsx)(`div`,{className:`mt-3`,children:(0,I.jsx)(R,{items:Et,empty:m.noDefinition})})]}):null,Dt.length>0?(0,I.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:m.approvalRequired}),(0,I.jsx)(`div`,{className:`mt-3`,children:(0,I.jsx)(R,{items:Dt,empty:m.noDefinition})})]}):null,Ot.length>0?(0,I.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:m.contextAssumptions}),(0,I.jsx)(`div`,{className:`mt-3`,children:(0,I.jsx)(R,{items:Ot,empty:m.noDefinition})})]}):null,kt.length>0?(0,I.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:m.contextRisks}),(0,I.jsx)(`div`,{className:`mt-3`,children:(0,I.jsx)(R,{items:kt,empty:m.noDefinition})})]}):null]}),Z?(0,I.jsxs)(`section`,{className:d(`rounded-xl bg-surface-panel p-4`,$(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{className:`font-medium text-fg`,children:m.latestResult}),(0,I.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg`,children:Z.summary})]}),(0,I.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[m.receiptStatuses[Z.status],` · `,m.verificationStatuses[Z.verification.status]]})]}),Z.remainingWork.length>0?(0,I.jsxs)(`div`,{className:`mt-4`,children:[(0,I.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:m.remainingWork}),(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(R,{items:Z.remainingWork,empty:m.noRemainingWork})})]}):null,Z.nextAction?(0,I.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:m.nextAction}),(0,I.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:Z.nextAction})]}):null,(0,I.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(f,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void y(Z.runId,`helpful`),children:m.doneWell}),(0,I.jsx)(f,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void y(Z.runId,`not_helpful`),children:m.needsFix}),Z.evidence.filter(e=>e.uri).map(e=>(0,I.jsxs)(`a`,{className:`ml-auto inline-flex items-center gap-1 text-xs text-accent hover:underline`,href:e.uri,children:[(0,I.jsx)(l,{className:`size-3`}),e.title]},`${e.title}-${e.uri}`))]}),h.receipts.length>1?(0,I.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:m.executionHistory.replace(`{{count}}`,String(h.receipts.length-1))}),(0,I.jsx)(`div`,{className:`mt-3 space-y-3`,children:h.receipts.slice(1).map(e=>(0,I.jsx)(`article`,{className:`rounded-lg bg-surface-active p-3`,children:(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsx)(`p`,{className:`text-sm text-fg`,children:e.summary}),(0,I.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:m.receiptStatuses[e.status]})]})},e.runId))})]}):null]}):null,h.context.length>0?(0,I.jsxs)(`section`,{className:d(`rounded-xl bg-surface-panel p-4`,$(`context`)&&`task-detail-live-update`),children:[(0,I.jsx)(`h2`,{className:`font-medium text-fg`,children:m.contextUsed}),(0,I.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:h.context.map(e=>(0,I.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,I.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[m.contextRoleLabels[e.role],` · `,m.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,I.jsx)(`a`,{className:`mt-1 block break-all text-sm text-accent hover:underline`,href:e.targetId,target:`_blank`,rel:`noreferrer`,children:e.title??e.targetId}):(0,I.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,I.jsxs)(`aside`,{className:`order-1 min-w-0 space-y-4`,children:[(0,I.jsxs)(`section`,{className:d(`rounded-xl bg-surface-subtle p-4`,$(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,I.jsx)(`h2`,{className:`font-medium text-fg`,children:m.taskProperties}),(0,I.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,I.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[(0,I.jsx)(`span`,{children:m.taskPhase}),(0,I.jsx)(s,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:h.task.phase,disabled:N,onChange:e=>void it(e.target.value),children:[`backlog`,`ready`,`active`,`review`,`closed`].map(e=>(0,I.jsx)(c,{value:e,disabled:Mt(e),children:Ee(e,i)},e))})]}),(0,I.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[(0,I.jsx)(`span`,{children:m.priority}),(0,I.jsx)(s,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:h.task.priority,disabled:N,onChange:e=>void Y({priority:e.target.value}),children:[`low`,`normal`,`high`,`critical`].map(e=>(0,I.jsx)(c,{value:e,children:m.priorityLabels[e]},e))})]}),(0,I.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[(0,I.jsx)(`span`,{children:m.dueDate}),(0,I.jsx)(Se,{disabled:N,value:Oe(h.task.dueAt),onChange:e=>void Y({dueAt:ke(e)}),ariaLabel:m.dueDate})]}),(0,I.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[(0,I.jsx)(`span`,{children:m.executorLabel}),(0,I.jsxs)(s,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:h.conversation.currentExecutorAgentId??``,disabled:N,onChange:e=>void ct(e.target.value),children:[(0,I.jsx)(c,{value:``,disabled:!0,children:m.unassigned}),Fe.map(e=>(0,I.jsx)(c,{value:e.id,children:e.name||e.id},e.id))]})]}),B?(0,I.jsxs)(`div`,{className:`grid gap-1 text-xs text-fg-muted`,children:[(0,I.jsx)(`span`,{children:m.projectLabel}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-lg bg-surface-hover px-3 py-2 text-sm text-fg`,children:[(0,I.jsx)(C,{className:`size-3.5`}),B]})]}):null]}),(0,I.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3 text-xs leading-5 text-fg-subtle`,children:[(0,I.jsx)(`p`,{children:dt}),(0,I.jsx)(`p`,{children:ft}),(0,I.jsx)(`p`,{className:`mt-2`,children:m.updatedAt.replace(`{{date}}`,D(h.task.updatedAt,i))})]})]}),(0,I.jsxs)(`section`,{className:d(`rounded-xl bg-surface-panel p-4`,$(`dependencies`)&&`task-detail-live-update`),children:[(0,I.jsx)(`h2`,{className:`font-medium text-fg`,children:m.taskRelations}),(0,I.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:m.dependencies}),(0,I.jsx)(Ce,{borderless:!0,candidates:Pe,selectedIds:h.dependencies.map(e=>e.id),disabled:N,onChange:e=>void st(e),labels:{link:m.linkDependencies,linked:m.linkedDependencies,searchPlaceholder:m.dependencySearchPlaceholder,noMatches:m.noDependencyMatches,noCandidates:m.noDependencyCandidates,remove:m.removeDependency}})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:m.dependents}),h.dependents.length>0?(0,I.jsx)(`div`,{className:`space-y-1.5`,children:h.dependents.map(e=>(0,I.jsx)(o,{to:At(e.id),className:`block rounded-lg bg-surface-hover p-2.5 text-sm text-accent hover:underline`,children:e.title},e.id))}):(0,I.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:m.noDependents})]})]})]})]})]})]}),(0,I.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":i===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(K),tabIndex:0,onPointerDown:ot,onKeyDown:at,onDoubleClick:()=>X(L),className:`group hidden w-2 shrink-0 cursor-col-resize touch-none items-stretch justify-center bg-surface-panel outline-none transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover lg:flex ${He?`bg-surface-hover`:``}`,children:(0,I.jsx)(`div`,{className:`my-3 w-px rounded-full bg-edge-strong/70 transition-colors group-hover:bg-accent group-focus-visible:bg-accent`})}),(0,I.jsxs)(`aside`,{className:`flex min-h-[34rem] min-w-0 flex-col bg-surface-panel lg:min-h-0 lg:w-[var(--task-chat-panel-width)] lg:shrink-0`,children:[(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 bg-surface-subtle px-4 py-3.5`,children:[(0,I.jsx)(`div`,{className:`min-w-0`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[Q?(0,I.jsx)(O,{agentId:Q,avatar:xt?.avatar,size:28,className:`shrink-0`}):null,(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:i===`zh`?`Agent 执行与对话`:`Agent execution and chat`}),(0,I.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[xt?.name??Q??m.unassigned,` · `,dt]})]})]})}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[Nt,bt?(0,I.jsx)(f,{asChild:!0,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,children:(0,I.jsxs)(o,{to:se(e),children:[(0,I.jsx)(l,{className:`size-3.5`}),i===`zh`?`全屏`:`Full screen`]})}):null]})]}),bt?(0,I.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,I.jsx)(he,{embedded:!0,sessionKey:bt,taskId:e})}):ue?(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,I.jsxs)(`div`,{className:`max-w-xs`,children:[(0,I.jsx)(be,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,I.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:i===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):k?(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,I.jsxs)(`div`,{className:`max-w-xs`,children:[(0,I.jsx)(be,{className:`mx-auto size-8 text-danger`}),(0,I.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:i===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,I.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:k instanceof Error?k.message:String(k)})]})}):(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,I.jsxs)(`div`,{className:`max-w-xs`,children:[(0,I.jsx)(be,{className:`mx-auto size-8 text-fg-subtle`}),(0,I.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:i===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,I.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:i===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]})]})}function z(){let e=(0,F.c)(2),{taskId:t}=i(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,I.jsx)(Pe,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function B(e){let t=(0,F.c)(43),{taskId:n,backgroundPath:r,onClose:i}=e,a=ne(Re),o=ue(W),s=ue(U),c=ue(H),l=M(Le),u=M(Ie),ee=o?s:0,d;t[0]!==i||t[1]!==u?(d=e=>{e||(u(null),i())},t[0]=i,t[1]=u,t[2]=d):d=t[2];let f=a===`zh`?`关闭任务详情`:`Close task details`,p;t[3]!==i||t[4]!==u?(p=()=>{u(null),i()},t[3]=i,t[4]=u,t[5]=p):p=t[5];let _;t[6]!==f||t[7]!==p?(_=(0,I.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45 backdrop-blur-[1px]`,"aria-label":f,onClick:p}),t[6]=f,t[7]=p,t[8]=_):_=t[8];let v=o?`true`:`false`,oe=`${ee/2}px`,se=`${ee}px`,y;t[9]!==oe||t[10]!==se?(y={"--task-detail-workspace-offset":oe,"--task-detail-workspace-width":se},t[9]=oe,t[10]=se,t[11]=y):y=t[11];let ce=y,le=a===`zh`?`任务详情`:`Task details`,b;t[12]===le?b=t[13]:(b=(0,I.jsx)(ae,{className:`font-medium text-fg`,children:le}),t[12]=le,t[13]=b);let x=a===`zh`?`查看并操作任务详情`:`View and manage task details`,S;t[14]===x?S=t[15]:(S=(0,I.jsx)(m,{className:`sr-only`,children:x}),t[14]=x,t[15]=S);let C=a===`zh`?`关闭任务详情`:`Close task details`,w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,I.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[16]=w):w=t[16];let T;t[17]===C?T=t[18]:(T=(0,I.jsx)(re,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":C,children:w}),t[17]=C,t[18]=T);let E;t[19]!==b||t[20]!==S||t[21]!==T?(E=(0,I.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[b,S,T]}),t[19]=b,t[20]=S,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==r||t[24]!==n?(D=(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,I.jsx)(Pe,{taskId:n,presentation:`modal`,backgroundPath:r})}),t[23]=r,t[24]=n,t[25]=D):D=t[25];let O;t[26]!==E||t[27]!==D||t[28]!==v||t[29]!==ce?(O=(0,I.jsxs)(h,{className:`task-detail-modal-content fixed top-1/2 z-[90] flex h-[min(54rem,calc(100dvh-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl bg-surface-base shadow-float focus:outline-none`,"data-workspace-panel-open":v,style:ce,onEscapeKeyDown:Fe,onInteractOutside:V,children:[E,D]}),t[26]=E,t[27]=D,t[28]=v,t[29]=ce,t[30]=O):O=t[30];let k;t[31]!==l||t[32]!==o||t[33]!==s||t[34]!==c?(k=l?(0,I.jsx)(`div`,{className:`fixed inset-y-0 left-0 z-[100] flex min-h-0 min-w-0 overflow-hidden bg-surface-panel transition-[right] duration-200 ease-out motion-reduce:transition-none`,style:{right:o?s:0},children:(0,I.jsx)(ye,{allowOutsideChat:!0,sessionKey:c??void 0})}):null,t[31]=l,t[32]=o,t[33]=s,t[34]=c,t[35]=k):k=t[35];let A;t[36]!==O||t[37]!==k||t[38]!==_?(A=(0,I.jsxs)(ie,{children:[_,O,k]}),t[36]=O,t[37]=k,t[38]=_,t[39]=A):A=t[39];let j;return t[40]!==d||t[41]!==A?(j=(0,I.jsx)(g,{modal:!1,open:!0,onOpenChange:d,children:A}),t[40]=d,t[41]=A,t[42]=j):j=t[42],j}function V(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function Fe(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function Ie(e){return e.setPath}function Le(e){return e.path}function H(e){return e.sessionKeyOverride}function U(e){return e.widthPx}function W(e){return e.open}function Re(e){return e.language}export{B as TaskDetailModal,z as TaskDetailPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{f as r,l as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./check-DUBLcKHA.js";import{n as o,t as ee}from"./working-directory-picker-modal-CYWdZUJ5.js";import{t as s}from"./loader-circle-CifKLtgG.js";import{t as te}from"./x-B_N4OPjy.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./button-CSEbl4zT.js";import{t as u}from"./messages-9zCa8KkW.js";import{n as ne}from"./locale-store-CbPVxonP.js";import{$a as d,Aa as f,Bc as p,Cl as re,Cs as m,Ga as ie,Gc as ae,Ha as h,Ic as oe,Ja as g,Ka as se,Qa as ce,Ua as le,Wa as ue,Wo as de,Xa as fe,Ya as pe,Za as me,eo as he,qa as _,sl as ge,xl as _e}from"./index-BBw9QL0p.js";var v=e(t(),1),y=new Set([`completed`,`failed`,`canceled`]);function b(){return new Promise(e=>window.setTimeout(e,1200))}async function ve(e,t){let n=[],r=t.wait??b;for(let i=0;i<e.length&&!t.shouldStop?.();i+=1){let a=e[i];if(a)try{await t.grantDirectory(a.rootPath);let o=await t.startRun(a.rootPath);for(t.onRun(o,i,e.length);!y.has(o.status)&&!t.shouldStop?.();)await r(),o=await t.fetchRun(o.id),t.onRun(o,i,e.length);if(n.push(o),o.status===`canceled`||t.shouldStop?.())break}catch(e){if(t.onError?.(e,a,i),t.shouldStop?.())break}}return n}var x=new Set([`local-recent-files`,`chromium-bookmarks`,`apple-notes`,`apple-calendar`,`apple-reminders`]);function ye(e){return new Set(e.filter(e=>e.availability===`available`&&x.has(e.id)).map(e=>e.id))}var S=n(),be=[`folder_structure`,`recent_progress`,`next_steps`];function C(e){return e instanceof Error?e.message:String(e)}function xe({embedded:e=!1,onRequestClose:t}={}){let n=ne(e=>e.language),y=u(n).onboarding.workDiscovery,b=u(n).chat.workingDirectory,x=i(),[xe]=r(),Se=e||xe.get(`new`)===`1`,[w,T]=(0,v.useState)(`loading`),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)(null),[A,j]=(0,v.useState)(!1),[M,N]=(0,v.useState)(null),[Ce,P]=(0,v.useState)(!1),[F,we]=(0,v.useState)(``),[Te,Ee]=(0,v.useState)(!1),[De,I]=(0,v.useState)(()=>new Set),[L,Oe]=(0,v.useState)([]),[R,z]=(0,v.useState)(()=>new Set),[ke,B]=(0,v.useState)([]),[V,H]=(0,v.useState)(!1),[U,W]=(0,v.useState)({current:0,total:0}),[Ae,je]=(0,v.useState)([]),[G,Me]=(0,v.useState)(()=>new Set),K=(0,v.useRef)(!1),Ne=e=>{Me(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};(0,v.useEffect)(()=>{let e=!1;return window.electronAPI?.understandingSources?.catalog().then(t=>{e||(je(t),Me(ye(t)))}),()=>{e=!0}},[]);let q=(0,v.useCallback)(e=>{h.getState().updateDirectoryRun(e),k(e),e.status===`completed`?(I(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),T(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`)):e.status===`failed`||e.status===`canceled`?T(`error`):T(`running`)},[]),Pe=async()=>{j(!0),N(null);try{let e=await ue();if(!e.length){N(y.noCandidates);return}Oe(e),z(new Set([e[0].rootPath])),T(`candidates`)}catch(e){N(C(e))}finally{j(!1)}},Fe=e=>{z(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ie=(0,v.useCallback)((e,t,n)=>{h.getState().updateDirectoryRun(e),k(e),W({current:t+1,total:n}),B(n=>{let r=[...n];return r[t]=e,r}),T(`running`)},[]),Le=(0,v.useCallback)(e=>{B(t=>t.map(t=>t?.id===e.id?e:t))},[]),Re=async()=>{let e=L.filter(e=>R.has(e.rootPath));if(!e.length)return;j(!0),N(null),B([]),W({current:1,total:e.length}),H(!0),K.current=!1;let t=!1;try{let n=await ve(e,{grantDirectory:g,startRun:ce,fetchRun:_,shouldStop:()=>K.current,onRun:(e,n,r)=>{Ie(e,n,r),t||(t=!0,h.getState().collectSources(e.id,[...G]))},onError:(t,n,r)=>{W({current:r+1,total:e.length}),N(y.folderAnalysisFailed.replace(`{{folder}}`,n.displayName).replace(`{{error}}`,C(t)))}});if(K.current)return;let r=n.find(e=>e.status===`completed`)??n.at(-1);r?q(r):T(`candidates`)}catch(e){N(C(e)),T(`candidates`)}finally{H(!1),j(!1)}},J=o({onPicked:(0,v.useCallback)(async e=>{j(!0),N(null);try{D(await pe(e)),T(`consent`)}catch(e){N(C(e)),T(`intro`)}finally{j(!1)}},[])});(0,v.useEffect)(()=>{let e=!1;return se().then(async({enabled:n,state:r})=>{if(!e){if(!n){t?t():x(`/chat`,{replace:!0});return}if(!Se&&r.activeRunId)try{let t=await _(r.activeRunId);e||q(t);return}catch{}e||T(`intro`)}}).catch(t=>{e||(N(C(t)),T(`intro`))}),()=>{e=!0}},[q,x,t,Se]),(0,v.useEffect)(()=>{if(!O||w!==`running`||V)return;let e=!1,t=async()=>{try{let t=await _(O.id);e||q(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===O.id)&&t()};for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.addEventListener(e,r);return()=>{e=!0,window.clearInterval(n);for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.removeEventListener(e,r)}},[q,V,w,O]);let Y=async()=>{j(!0);try{await ie()}finally{t?t():x(`/chat`,{replace:!0})}},ze=async()=>{if(E){j(!0),N(null),B([]),W({current:0,total:0});try{await g(E.canonicalRootPath);let e=await ce(E.canonicalRootPath);q(e),h.getState().collectSources(e.id,[...G])}catch(e){N(C(e)),T(`consent`)}finally{j(!1)}}},X=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;x(`/chat/${encodeURIComponent(e)}${n}`)},Be=e=>{k(e),P(!1),Ee(!1),I(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),e.status===`completed`?T(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?T(`error`):T(`running`)},Ve=async()=>{O&&(K.current=!0,q(await le(O.id)))},Z=async(e,t)=>{if(!O)return;await me(O.id,e.id).catch(()=>{});let r=t?`${n===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${e.actionPrompt}`:e.actionPrompt;X(O.sessionKey,r)},He=async()=>{if(O){j(!0),N(null);try{let e=O.result?.profileCandidates??[],t=await d((e.length>0?await he(O.id,e.map(e=>({id:e.id,status:De.has(e.id)?`accepted`:`rejected`}))):O).id,`confirmed`);k(t),Le(t),T(`recommendation`)}catch(e){N(C(e))}finally{j(!1)}}},Q=async e=>{if(!(!O||!F.trim())){j(!0),N(null);try{let t=await d(O.id,e,F.trim());k(t),X(t.sessionKey,F.trim())}catch(e){N(C(e)),j(!1)}}},Ue=async()=>{if(O){j(!0);try{X((await d(O.id,`dismissed`)).sessionKey)}catch(e){N(C(e)),j(!1)}}},$=O?.result?.suggestions.find(e=>e.id===O.result?.primarySuggestionId)??O?.result?.suggestions[0],We=O?.result?.suggestions.filter(e=>e.id!==$?.id)??[],Ge=e=>e===`command`?y.riskCommand:e===`file_write`?y.riskFileWrite:y.riskAnalysis,Ke=ke.filter(e=>e?.status===`completed`),qe=e&&w===`candidates`,Je=Ke.length>1?(0,S.jsxs)(`div`,{className:`mt-6 rounded-xl border border-edge bg-surface-panel p-2`,children:[(0,S.jsx)(`p`,{className:`px-2 pb-2 text-xs font-medium text-fg-muted`,children:y.analysisResults}),(0,S.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Ke.map(e=>{let t=L.find(t=>t.rootPath===e.rootPath)?.displayName??e.rootPath.split(/[\\/]/).filter(Boolean).at(-1)??e.rootPath;return(0,S.jsx)(`button`,{type:`button`,className:`rounded-lg px-3 py-2 text-sm font-medium transition ${e.id===O?.id?`bg-accent text-white`:`bg-surface-muted text-fg hover:bg-surface-hover`}`,onClick:()=>Be(e),children:t},e.id)})})]}):null;return(0,S.jsxs)(`div`,{className:e?`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-surface-base`:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,S.jsxs)(`main`,{className:e?`mx-auto flex h-full min-h-0 w-full max-w-[40rem] flex-1 flex-col px-5 py-7 sm:px-8 sm:py-9 ${qe?`overflow-hidden`:`overflow-y-auto [scrollbar-gutter:stable]`}`:`mx-auto flex w-full max-w-[40rem] flex-1 flex-col px-5 py-10 sm:px-8 sm:py-16`,children:[e?null:(0,S.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,S.jsx)(de,{className:`size-11`})}),w===`loading`?(0,S.jsxs)(`div`,{className:`mx-auto flex min-h-[26rem] w-full max-w-md flex-col items-center`,"aria-busy":!0,children:[(0,S.jsx)(f,{className:`h-8 w-64 max-w-full`}),(0,S.jsx)(f,{className:`mt-4 h-4 w-full max-w-sm`}),(0,S.jsx)(f,{className:`mt-2 h-4 w-4/5 max-w-xs`}),(0,S.jsx)(f,{className:`mt-10 h-12 w-full rounded-xl`}),(0,S.jsx)(f,{className:`mt-3 h-11 w-full rounded-xl`}),(0,S.jsx)(f,{className:`mt-5 h-4 w-3/5 max-w-56`})]}):null,w===`intro`?(0,S.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,S.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,S.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:y.title}),(0,S.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:y.subtitle})]}),(0,S.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[Ae.length?(0,S.jsxs)(`div`,{className:`mb-5 rounded-xl border border-edge bg-surface-panel p-3 text-left`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:y.localSourcesTitle}),(0,S.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:y.localSourcesSubtitle}),(0,S.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 sm:grid-cols-3`,children:Ae.map(e=>{let t=G.has(e.id);return(0,S.jsxs)(`button`,{type:`button`,className:c(`flex min-h-16 flex-col items-center justify-center gap-1 rounded-lg border px-2 py-2 text-xs font-medium transition-colors`,t?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":t,onClick:()=>Ne(e.id),children:[(0,S.jsx)(`span`,{className:c(`flex size-4 items-center justify-center rounded-full border`,t?`border-accent bg-accent text-white`:`border-edge`),children:t?(0,S.jsx)(a,{className:`size-3`,"aria-hidden":!0}):null}),e.displayName]},e.id)})})]}):null,(0,S.jsxs)(l,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void Pe(),disabled:A||J.picking,children:[A?(0,S.jsx)(s,{className:`size-4 animate-spin`}):(0,S.jsx)(m,{className:`size-4`}),y.quickScan]}),(0,S.jsxs)(l,{type:`button`,variant:`secondary`,className:`mt-3 h-11 w-full gap-2`,onClick:J.pick,disabled:A||J.picking,children:[J.picking?(0,S.jsx)(s,{className:`size-4 animate-spin`}):(0,S.jsx)(p,{className:`size-4`}),y.chooseFolderManually]}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,S.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,S.jsx)(`span`,{children:y.quickScanNote})]}),(0,S.jsx)(`button`,{type:`button`,className:`mt-4 text-sm font-medium text-accent-fg hover:underline`,onClick:()=>x(`/connectors?understanding=1&returnTo=%2Fonboarding%2Fworkspace`),children:y.connectCloudSource}),M?(0,S.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:M}):null]}),(0,S.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void Y(),disabled:A,children:y.skip})]}):null,w===`candidates`?(0,S.jsxs)(`section`,{className:e?`flex h-full min-h-0 flex-col`:void 0,"aria-labelledby":`work-discovery-candidates-title`,children:[(0,S.jsxs)(`div`,{className:e?`shrink-0 text-center`:`text-center`,children:[(0,S.jsx)(`h1`,{id:`work-discovery-candidates-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:y.candidatesTitle}),(0,S.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:y.candidatesSubtitle})]}),(0,S.jsx)(`div`,{className:e?`mt-5 min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain pr-1 [scrollbar-gutter:stable]`:`mt-7 space-y-2`,children:L.map((e,t)=>{let n=R.has(e.rootPath);return(0,S.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:`flex w-full items-start gap-3 rounded-xl border p-4 text-left transition ${n?`border-accent bg-accent-soft/45`:`border-edge bg-surface-panel hover:border-edge-strong`}`,onClick:()=>Fe(e.rootPath),children:[(0,S.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-md border ${n?`border-accent bg-accent text-white`:`border-edge bg-surface-base text-transparent`}`,children:(0,S.jsx)(a,{className:`size-3.5`})}),(0,S.jsx)(p,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`}),(0,S.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,S.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),t===0?(0,S.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:y.recommendedCandidate}):null]}),(0,S.jsx)(`span`,{className:`mt-1 block truncate font-mono text-xs text-fg-muted`,children:e.rootPath}),(0,S.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,S.jsx)(`span`,{children:e.projectKind===`coding`?y.codingProject:e.projectKind===`general`?y.generalProject:y.unknownProject}),e.branch?(0,S.jsx)(`span`,{children:y.branchValue.replace(`{{branch}}`,e.branch)}):null,e.changedFileCount>0?(0,S.jsx)(`span`,{children:y.changedFiles.replace(`{{count}}`,String(e.changedFileCount))}):null]})]})]},e.id)})}),(0,S.jsxs)(`div`,{className:e?`shrink-0 border-t border-edge-subtle pt-4`:void 0,children:[(0,S.jsxs)(`div`,{className:`${e?``:`mt-5 `}flex items-start gap-2 rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3 text-xs leading-5 text-fg-muted`,children:[(0,S.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,S.jsx)(`span`,{children:y.multiFolderPrivacyNote})]}),M?(0,S.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:M}):null,(0,S.jsxs)(`div`,{className:`${e?`mt-4`:`mt-7`} flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,S.jsxs)(l,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:A||R.size===0,onClick:()=>void Re(),children:[A?(0,S.jsx)(s,{className:`mr-2 size-4 animate-spin`}):null,y.analyzeSelected.replace(`{{count}}`,String(R.size))]}),(0,S.jsx)(l,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:A,onClick:J.pick,children:y.chooseFolderManually})]}),(0,S.jsx)(`button`,{type:`button`,className:`${e?`mt-3`:`mt-6`} mx-auto block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>T(`intro`),children:y.back})]})]}):null,w===`consent`&&E?(0,S.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,S.jsxs)(`div`,{className:`text-center`,children:[(0,S.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:y.selectedTitle}),(0,S.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:y.selectedSubtitle})]}),(0,S.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,S.jsx)(p,{className:`size-5 shrink-0 text-accent-fg`}),(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:E.displayName}),(0,S.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:E.canonicalRootPath})]}),(0,S.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:E.projectKind===`coding`?y.codingProject:E.projectKind===`general`?y.generalProject:y.unknownProject})]}),(0,S.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle bg-surface-base/60 p-4 sm:grid-cols-2`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:y.localFingerprint}),(0,S.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:E.fingerprint.branch?y.branchValue.replace(`{{branch}}`,E.fingerprint.branch):y.noGitBranch})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:y.recentActivity}),(0,S.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:y.changedFiles.replace(`{{count}}`,String(E.fingerprint.changedFileCount))})]}),E.fingerprint.recentAreas.length>0?(0,S.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,S.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:y.recentAreas}),(0,S.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:E.fingerprint.recentAreas.map(e=>(0,S.jsx)(`code`,{className:`rounded-md bg-surface-muted px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,S.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,S.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,S.jsx)(ae,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:y.willRead}),(0,S.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:y.willReadValue})]})]}),(0,S.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,S.jsx)(te,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:y.willIgnore}),(0,S.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:y.willIgnoreValue})]})]}),(0,S.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,S.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,S.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:E.remoteModel?y.providerDisclosure.replace(`{{provider}}`,E.provider):y.localDisclosure})]})]})]}),M?(0,S.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:M}):null,(0,S.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,S.jsxs)(l,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:A,onClick:()=>void ze(),children:[A?(0,S.jsx)(s,{className:`mr-2 size-4 animate-spin`}):null,y.startAnalysis]}),(0,S.jsx)(l,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:A,onClick:J.pick,children:y.changeFolder})]}),(0,S.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void Y(),children:y.skip})]}):null,w===`running`&&O?(0,S.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,S.jsxs)(`div`,{className:`text-center`,children:[(0,S.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:y.analyzingTitle}),(0,S.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:y.analyzingSubtitle}),U.total>1?(0,S.jsx)(`p`,{className:`mt-2 text-sm font-medium text-accent-fg`,children:y.analyzingFolderProgress.replace(`{{current}}`,String(U.current)).replace(`{{total}}`,String(U.total))}):null]}),(0,S.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:be.map((e,t)=>{let n=Math.max(0,be.indexOf(O.stage??`folder_structure`)),r=t<n,i=t===n;return(0,S.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,S.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-full ${r?`bg-accent text-white`:i?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-subtle`}`,children:r?(0,S.jsx)(a,{className:`size-4`}):i?(0,S.jsx)(s,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,S.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,S.jsx)(`span`,{className:i||r?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:y.stages[e]})]},e)})}),(0,S.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:O.rootPath}),(0,S.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3`,children:[(0,S.jsx)(l,{type:`button`,variant:`secondary`,className:`h-11 w-full`,onClick:()=>x(`/chat`),children:y.continueInBackground}),(0,S.jsx)(`button`,{type:`button`,className:`mx-auto text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void Ve(),children:y.cancelAnalysis})]})]}):null,w===`recognition`&&O?.result?(0,S.jsxs)(`section`,{"aria-labelledby":`work-discovery-recognition-title`,children:[(0,S.jsxs)(`div`,{className:`text-center`,children:[(0,S.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:y.recognitionEyebrow}),(0,S.jsx)(`h1`,{id:`work-discovery-recognition-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:O.result.lowConfidence?y.lowConfidenceTitle:y.recognitionTitle})]}),Je,(0,S.jsxs)(`div`,{className:`mt-7 rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/45 via-surface-panel to-surface-panel p-5 sm:p-6`,children:[(0,S.jsx)(`p`,{className:`text-base font-medium leading-7 text-fg`,children:O.result.projectSummary}),(0,S.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:O.result.currentState}),!O.result.lowConfidence&&$?.evidence.length?(0,S.jsx)(`ul`,{className:`mt-5 space-y-2 border-t border-edge-subtle pt-4`,children:$.evidence.slice(0,3).map((e,t)=>(0,S.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,S.jsx)(oe,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,S.jsxs)(`span`,{children:[e.path?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${$.id}-recognition-${t}`))}):null]}),O.result.workThreads?.length?(0,S.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:y.workThreadsTitle}),(0,S.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:y.workThreadsSubtitle}),(0,S.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle`,children:O.result.workThreads.map(e=>(0,S.jsxs)(`div`,{className:`py-3 first:pt-0 last:pb-0`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:e.horizon===`current`?y.workThreadCurrent:e.horizon===`ongoing`?y.workThreadOngoing:y.workThreadLongTerm}),(0,S.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.title})]}),(0,S.jsx)(`p`,{className:`mt-1.5 text-xs leading-5 text-fg-muted`,children:e.summary})]},e.id))})]}):null,O.result.profileCandidates?.length?(0,S.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:y.profileCandidatesTitle}),(0,S.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:y.profileCandidatesSubtitle}),(0,S.jsx)(`div`,{className:`mt-3 space-y-2`,children:O.result.profileCandidates.map(e=>(0,S.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg px-2 py-2 hover:bg-surface-muted`,children:[(0,S.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 rounded border-edge accent-accent`,checked:De.has(e.id),onChange:()=>I(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n})}),(0,S.jsx)(`span`,{className:`text-sm leading-5 text-fg`,children:e.statement})]},e.id))})]}):null,O.result.lowConfidence?(0,S.jsxs)(`div`,{className:`mt-5`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:O.result.contextQuestion}),(0,S.jsx)(`textarea`,{value:F,onChange:e=>we(e.target.value),placeholder:y.correctionPlaceholder,className:`mt-3 min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,S.jsx)(l,{className:`mt-3 w-full bg-accent text-white hover:bg-accent-hover`,disabled:A||!F.trim(),onClick:()=>void Q(`different_goal`),children:y.continueWithCorrection})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,S.jsxs)(l,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:A,onClick:()=>void He(),children:[A?(0,S.jsx)(s,{className:`size-4 animate-spin`}):(0,S.jsx)(a,{className:`size-4`}),y.confirmUnderstanding]}),(0,S.jsx)(l,{variant:`secondary`,className:`h-11 flex-1`,disabled:A,onClick:()=>P(e=>!e),children:y.notQuiteRight})]}),Ce?(0,S.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,S.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`work-discovery-correction`,children:y.correctionLabel}),(0,S.jsx)(`textarea`,{id:`work-discovery-correction`,value:F,onChange:e=>we(e.target.value),placeholder:y.correctionPlaceholder,className:`mt-2 min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,S.jsx)(l,{variant:`ghost`,disabled:A||!F.trim(),onClick:()=>void Q(`different_goal`),children:y.differentGoal}),(0,S.jsx)(l,{variant:`primary`,disabled:A||!F.trim(),onClick:()=>void Q(`corrected`),children:y.useCorrection})]})]}):null]}),M?(0,S.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:M}):null,(0,S.jsx)(`button`,{type:`button`,disabled:A,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:()=>void Ue(),children:y.openConversation})]}):null,w===`recommendation`&&O?.result&&$?(0,S.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,S.jsxs)(`div`,{className:`text-center`,children:[(0,S.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:y.understandingConfirmed}),(0,S.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:y.primaryRecommendationTitle})]}),Je,(0,S.jsx)(`article`,{className:`mt-7 rounded-2xl border border-accent/30 bg-surface-panel p-5 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,S.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,S.jsx)(_e,{className:`size-5`})}),(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:$.title}),(0,S.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:$.rationale}),(0,S.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,S.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:[(0,S.jsx)(ge,{className:`size-3.5`}),y.estimatedMinutes.replace(`{{count}}`,String($.estimatedMinutes))]}),(0,S.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:Ge($.risk)})]}),(0,S.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,S.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:y.expectedTask}),(0,S.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:$.expectedTask})]}),(0,S.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,S.jsx)(l,{className:`h-10 bg-accent px-4 text-white hover:bg-accent-hover`,onClick:()=>void Z($,!1),children:y.startRecommendedAction}),(0,S.jsx)(l,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void Z($,!0),children:y.explainFirst})]})]})]})}),We.length>0?(0,S.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between py-2 text-sm font-medium text-fg-muted hover:text-fg`,onClick:()=>Ee(e=>!e),children:[y.otherDirections,(0,S.jsx)(re,{className:`size-4 transition-transform ${Te?`rotate-180`:``}`})]}),Te?(0,S.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-panel px-4`,children:We.map(e=>(0,S.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void Z(e,!0),children:[(0,S.jsx)(_e,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,S.jsxs)(`span`,{children:[(0,S.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,S.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedTask})]})]},e.id))}):null]}):null,(0,S.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,S.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>X(O.sessionKey),children:y.doSomethingElse}),(0,S.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{P(!0),T(`recognition`)},children:y.correctUnderstanding})]})]}):null,w===`error`&&O?(0,S.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,S.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,S.jsx)(te,{className:`size-5`})}),(0,S.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:y.errorTitle}),(0,S.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:O.errorMessage}),(0,S.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,S.jsx)(l,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void fe(O.id).then(q),children:y.retry}),(0,S.jsx)(l,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{k(null),D(null),T(`intro`)},children:y.chooseDifferent})]}),(0,S.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>X(O.sessionKey),children:y.openConversation})]}):null]}),J.hasNativePicker?null:(0,S.jsx)(ee,{open:J.modalOpen,onOpenChange:J.setModalOpen,initialAbsolutePath:E?.canonicalRootPath,onConfirm:J.confirmPick,wd:b})]})}export{xe as WorkDiscoveryPage};