pisper 0.6.21 → 0.6.22

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 (117) hide show
  1. package/package.json +6 -6
  2. package/web/.vite/manifest.json +575 -583
  3. package/web/assets/{AppDialog-CyOinq_c.js → AppDialog-BluIYP8v.js} +1 -1
  4. package/web/assets/{AppOverlays-tniCecGA.js → AppOverlays-vn_Ter3M.js} +1 -1
  5. package/web/assets/{AssetsPage-DYFCPNhU.js → AssetsPage-CLlSYXp8.js} +1 -1
  6. package/web/assets/{BoardPage-Dp-FZv-N.js → BoardPage-nSsZudtr.js} +3 -3
  7. package/web/assets/{ChannelsPage-vBRUJEhU.js → ChannelsPage-DqnfAoWC.js} +1 -1
  8. package/web/assets/{ChatAppearancePage-DH4LSb0w.js → ChatAppearancePage-2itvW4ex.js} +1 -1
  9. package/web/assets/{ChatHistoryPage-ChspTm6r.js → ChatHistoryPage-OPTj6spQ.js} +1 -1
  10. package/web/assets/{ChatPage-DvU-p808.js → ChatPage-C_3_rpJn.js} +5 -5
  11. package/web/assets/{ConfigPage-CFFaLkKD.js → ConfigPage-DnPb_QrV.js} +2 -2
  12. package/web/assets/{DesktopWindowControls-Cz0mpg2c.js → DesktopWindowControls-DQf3N-Pq.js} +1 -1
  13. package/web/assets/{FeaturePage-DT_WfUIg.js → FeaturePage-B8dFhtLs.js} +1 -1
  14. package/web/assets/{FileAttachmentPreview-yuCLHoKm.js → FileAttachmentPreview-CeQTyfpt.js} +1 -1
  15. package/web/assets/{FloatingWidgets-D-48zs1T.js → FloatingWidgets-CWpMJq1K.js} +1 -1
  16. package/web/assets/{FocusRuntimeControls-D61-BVTV.js → FocusRuntimeControls-J_hbXz7v.js} +1 -1
  17. package/web/assets/{GitDiffViewer-DWHHRnjQ.js → GitDiffViewer-DZm3DoP7.js} +1 -1
  18. package/web/assets/{ManageProjectsDialog-B_0l-_Th.js → ManageProjectsDialog-VaG1Uu6p.js} +1 -1
  19. package/web/assets/{MarkdownMessage-zaqhqJ44.js → MarkdownMessage-Dbypp4RC.js} +1 -1
  20. package/web/assets/{McpPage-CuOr94Lo.js → McpPage-D8NZyKoO.js} +1 -1
  21. package/web/assets/{MemoryPage-CI_OOJh3.js → MemoryPage-DZsAXror.js} +1 -1
  22. package/web/assets/{MobileNavigation-CpOrDVyY.js → MobileNavigation-DHWkx5h0.js} +1 -1
  23. package/web/assets/{MorePage-CP0ptgQR.js → MorePage-PK0vEEda.js} +1 -1
  24. package/web/assets/{NewFolderDialog-wwAp2HUt.js → NewFolderDialog-DjC2xSrj.js} +1 -1
  25. package/web/assets/{PageHeader-CbiN6zVm.js → PageHeader-CcgJJB4K.js} +1 -1
  26. package/web/assets/{PhoneDrawer-DN3UBXYe.js → PhoneDrawer-DMIlKCRW.js} +1 -1
  27. package/web/assets/{PhoneMenuButton-BMgvbvez.js → PhoneMenuButton-dzvj0NS0.js} +1 -1
  28. package/web/assets/{PhoneTopBar-DFtEfuO6.js → PhoneTopBar-UqSQG8KO.js} +1 -1
  29. package/web/assets/{PluginsPage-CPkH6yN9.js → PluginsPage-D_7E0Mcm.js} +1 -1
  30. package/web/assets/{SafeModePrompt-vZ-kg03s.js → SafeModePrompt-CYubRBr0.js} +1 -1
  31. package/web/assets/{SchedulesPage-BQBk-HJm.js → SchedulesPage-BsX821QZ.js} +1 -1
  32. package/web/assets/{SessionBrowserPane-CC0qsCP9.js → SessionBrowserPane-ZvjA5vop.js} +2 -2
  33. package/web/assets/{SessionContextPanel-CyPu1SIQ.js → SessionContextPanel-39eXpERL.js} +2 -2
  34. package/web/assets/{SessionHome-C2xp5_yM.js → SessionHome-Cm131bvz.js} +1 -1
  35. package/web/assets/{SessionInspector-D362Va6Y.js → SessionInspector-DiSWVd6R.js} +1 -1
  36. package/web/assets/{SessionShell-BmsJM64n.js → SessionShell-DiWPHdio.js} +1 -1
  37. package/web/assets/{SettingsSidebar-B7qnN1dq.js → SettingsSidebar-Br83KuNT.js} +1 -1
  38. package/web/assets/{ShortcutHelpDialog-BzWvhRT2.js → ShortcutHelpDialog-rmlTJwrg.js} +1 -1
  39. package/web/assets/{ShortcutKeys-Cg-wl3yb.js → ShortcutKeys-CE7wsdx4.js} +1 -1
  40. package/web/assets/{SidebarUpdateStatus-B-MIuH8f.js → SidebarUpdateStatus-BSxoGQFm.js} +1 -1
  41. package/web/assets/{SkillsPage-BowfELnZ.js → SkillsPage-zrZCbP5L.js} +1 -1
  42. package/web/assets/{TaskProcessesPane-DGikk1nH.js → TaskProcessesPane-B9a-bK8Q.js} +1 -1
  43. package/web/assets/{TaskTerminalView-BjR4vuZI.js → TaskTerminalView-Dnl9t0Yq.js} +1 -1
  44. package/web/assets/{TerminalPanel-ZXcyyLBu.js → TerminalPanel-EbsJNe9L.js} +1 -1
  45. package/web/assets/{WebDesktopPet-CrUcp9Ym.js → WebDesktopPet-CqR3puOx.js} +1 -1
  46. package/web/assets/{WorkflowsPage-CTKpPFrC.js → WorkflowsPage-ChXjB-wW.js} +1 -1
  47. package/web/assets/{WorkspacePicker-CROSQVzJ.js → WorkspacePicker-CojYPYIa.js} +1 -1
  48. package/web/assets/{api-CIB7ZPX3.js → api-3pnTJcsp.js} +1 -1
  49. package/web/assets/{app-update-B6njQMB7.js → app-update-C6PjqV-N.js} +1 -1
  50. package/web/assets/{approval-confirm-D2B0tMFE.js → approval-confirm-Ng3lhZR9.js} +1 -1
  51. package/web/assets/board-messages-DRw0EP3S.js +1 -0
  52. package/web/assets/{board-projects-Ca61ZKPH.js → board-projects-Cn83x27D.js} +1 -1
  53. package/web/assets/{bots-store-BG81qEJz.js → bots-store-B0uE78FQ.js} +1 -1
  54. package/web/assets/{chat-api-aEirz9it.js → chat-api-DE-00AQt.js} +1 -1
  55. package/web/assets/{client-store-BSqTT-c2.js → client-store-B0G8KCEA.js} +1 -1
  56. package/web/assets/{config-search-DdXAm7PX.js → config-search-Cnob89Wh.js} +1 -1
  57. package/web/assets/{dialog-D1TVm0d6.js → dialog-sq6TFrs2.js} +1 -1
  58. package/web/assets/{dropdown-menu-CFIFNaKO.js → dropdown-menu-Ds0gD8S8.js} +1 -1
  59. package/web/assets/{events-CrT7ie40.js → events-BYm_7rfH.js} +1 -1
  60. package/web/assets/{folder-paths-BuiyvlAk.js → folder-paths-BeZN9wq7.js} +1 -1
  61. package/web/assets/{hosts-CpFGDuNR.js → hosts-BWu_xvML.js} +1 -1
  62. package/web/assets/i18n-Cewq43aI.js +1 -0
  63. package/web/assets/{index-DcTDwezs.js → index-DT21IKeB.js} +2 -2
  64. package/web/assets/index-dYNkGdsI.css +2 -0
  65. package/web/assets/{mount-app-DhHe93-u.js → mount-app-YAzhl88_.js} +3 -3
  66. package/web/assets/{permission-rules-api-Ch3fRXTD.js → permission-rules-api-DdYftUQE.js} +1 -1
  67. package/web/assets/{pick-system-directory-B8aZR2BS.js → pick-system-directory-LOpQirAM.js} +1 -1
  68. package/web/assets/{placements-5hgUqGzE.js → placements-BzbpQDQ7.js} +2 -2
  69. package/web/assets/{popover-BMTgTASl.js → popover-CEwCyvso.js} +1 -1
  70. package/web/assets/{public-DTq_JyXj.js → public-CgfPT7gK.js} +2 -2
  71. package/web/assets/public-Ck1i4t8o.js +1 -0
  72. package/web/assets/{public-BTvrDX6E.js → public-CoivUKr6.js} +1 -1
  73. package/web/assets/{public-components-DUa3En6P.js → public-components-CQf0np0Z.js} +1 -1
  74. package/web/assets/public-diff-wY-tpFFs.js +1 -0
  75. package/web/assets/public-events-B-fuAF9_.js +1 -0
  76. package/web/assets/{public-flags-DEs9Uj_y.js → public-flags-DZvYvsWH.js} +1 -1
  77. package/web/assets/{public-session-CXzhUUNr.js → public-session-Bx2TqcKh.js} +1 -1
  78. package/web/assets/{public-sidebar-CJVnP7HU.js → public-sidebar-3z7xPwe3.js} +1 -1
  79. package/web/assets/{runtime-capabilities-store-DpEKnn1b.js → runtime-capabilities-store-CDhzPVU-.js} +1 -1
  80. package/web/assets/{safe-mode-instance-CVh0Lclx.js → safe-mode-instance-D_H4Z8Xv.js} +1 -1
  81. package/web/assets/safe-mode-sentinel-BG7I9wh1.js +1 -0
  82. package/web/assets/segmented-control-xkrEOP_d.js +1 -0
  83. package/web/assets/{session-change-summary-api-sn-ejt4H.js → session-change-summary-api-CxOV5OrA.js} +1 -1
  84. package/web/assets/{session-home-DBefA-JE.js → session-home-chPk0XEV.js} +1 -1
  85. package/web/assets/{session-organization-api-BFW_7Myv.js → session-organization-api-A3EudhgK.js} +1 -1
  86. package/web/assets/{session-scope-P-D-Ssd4.js → session-scope-CF4OLtKw.js} +1 -1
  87. package/web/assets/{session-tree-actions-DZ5-Z8_F.js → session-tree-actions-DNefaiZO.js} +1 -1
  88. package/web/assets/{session-tree-summary-Dljblf8P.js → session-tree-summary-DPqtCWEP.js} +1 -1
  89. package/web/assets/{shortcuts-DXHroTTi.js → shortcuts-zcQP1D4E.js} +1 -1
  90. package/web/assets/{side-chat-context-6tf1Gx5C.js → side-chat-context-BpjCorLu.js} +4 -4
  91. package/web/assets/{sidebar-PuiNlAmD.js → sidebar-Bb6NlEeR.js} +1 -1
  92. package/web/assets/{sidebar-store-CbyxBthc.js → sidebar-store-CQWNlMxT.js} +1 -1
  93. package/web/assets/{speech-session-B3-i8f64.js → speech-session-2WJk-z3P.js} +1 -1
  94. package/web/assets/{startup-queries-CceboYee.js → startup-queries-C9AHlyOp.js} +1 -1
  95. package/web/assets/{use-i18n-B2p84ZNR.js → use-i18n-BPJI6-Ue.js} +1 -1
  96. package/web/assets/{use-open-bot-CgFlDm0x.js → use-open-bot-5wf_No4c.js} +1 -1
  97. package/web/assets/{use-studio-actions-DM2CAaXR.js → use-studio-actions-C5heO0nL.js} +3 -3
  98. package/web/assets/{useCatalogProjects-laY-U3Br.js → useCatalogProjects-BWKT2GrE.js} +1 -1
  99. package/web/assets/{useNewProjectPicker-rhLvXi27.js → useNewProjectPicker-BCkEpwht.js} +2 -2
  100. package/web/assets/{useNow-DYvbFah-.js → useNow-e0HHzVad.js} +1 -1
  101. package/web/assets/{usePhoneShell-BSkh5GND.js → usePhoneShell-C90daPSI.js} +1 -1
  102. package/web/assets/{useSessionListQuery-CHbg2lM2.js → useSessionListQuery-Ezaq4rI5.js} +1 -1
  103. package/web/assets/{useSessionRowActions-CO4u1xCd.js → useSessionRowActions-BIJ-eKcN.js} +1 -1
  104. package/web/assets/{useSidebarModel-V_SZjKZH.js → useSidebarModel-DDqX8onb.js} +1 -1
  105. package/web/assets/{web-preview-CR8GMArR.js → web-preview-C5NXKRu-.js} +1 -1
  106. package/web/assets/{web-preview-events-DUqovP-L.js → web-preview-events-CIJw4Wx-.js} +1 -1
  107. package/web/assets/{workspace-order-store-CK1RETHt.js → workspace-order-store-0jm2oVHS.js} +1 -1
  108. package/web/index.html +2 -2
  109. package/web/assets/board-messages-DVz8SE1C.js +0 -1
  110. package/web/assets/i18n-CXRjs9ow.js +0 -1
  111. package/web/assets/index-BY7X-ZtU.css +0 -2
  112. package/web/assets/public-BZlIDP6h.js +0 -1
  113. package/web/assets/public-diff-DEL93aov.js +0 -1
  114. package/web/assets/public-events-BiaqrDkZ.js +0 -1
  115. package/web/assets/safe-mode-sentinel-Bm4e075H.js +0 -1
  116. package/web/assets/segmented-control-BlM_GKV6.js +0 -1
  117. package/web/assets/touch-target-BsyCgjR5.js +0 -1
@@ -1,5 +1,5 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{l as t,m as n}from"./vendor-router-CSN_DGvx.js";import{t as r}from"./index-DcTDwezs.js";import{i,r as a}from"./vendor-react-DwNgTV1j.js";import{c as o,d as s,n as c}from"./i18n-CXRjs9ow.js";import{t as l}from"./use-i18n-B2p84ZNR.js";import{a as u,l as d,t as f}from"./api-CIB7ZPX3.js";import{n as p}from"./runtime-capabilities-CHYOF_hE.js";import{t as m}from"./runtime-capabilities-store-DpEKnn1b.js";import{n as h}from"./client-store-BSqTT-c2.js";import{t as g}from"./createLucideIcon-Cd-3GVxJ.js";import{a as _,i as v,t as y}from"./permission-rules-api-Ch3fRXTD.js";import{t as b}from"./arrow-left-B8oVrQ2S.js";import{t as x}from"./arrow-right-DqLOhpA2.js";import{t as S}from"./arrow-up-right-B6l8qFZz.js";import{t as C}from"./bell-BjONAtgH.js";import{t as w}from"./bot-B3TaBp_T.js";import{t as T}from"./brain-qxhnKqYP.js";import{t as E}from"./check-2vYc6QaP.js";import{t as D}from"./chevron-down-CxtxIjiP.js";import{t as O}from"./chevron-left-BAtyp3_6.js";import{t as k}from"./circle-alert-DCChabnT.js";import{t as A}from"./circle-check-iEdCm3Pw.js";import{t as j}from"./code-xml-BrUXrBax.js";import{t as M}from"./copy-DHmIFc52.js";import{t as ee}from"./download-BCfIiuaL.js";import{t as N}from"./ellipsis-CfGKfbq6.js";import{t as P}from"./external-link-CEQqPcqc.js";import{i as te,o as ne,s as re}from"./settings-navigation-DiP_AM1C.js";import{t as ie}from"./image-BY_c3FYU.js";import{t as ae}from"./info-DATxy0fb.js";import{t as F}from"./loader-circle-BOwQzHB-.js";import{t as oe}from"./message-square-SKjZyY3v.js";import{t as se}from"./monitor-smartphone-B1gIjItA.js";import{n as I,r as ce,t as le}from"./zap-DZHw5afO.js";import{t as ue}from"./play-DNDjDNGn.js";import{t as de}from"./plus-fQbSqB1n.js";import{t as fe}from"./refresh-cw-TbWxTY4K.js";import{t as pe}from"./rocket-BgLSjoHY.js";import{t as me}from"./rotate-ccw-C0v8V77_.js";import{t as he}from"./search-D0mqDaf_.js";import{t as ge}from"./server-BgNvmqwJ.js";import{t as _e}from"./shield-check-Gvek4RJ7.js";import{t as ve}from"./sparkles-S_eeuqn9.js";import{t as ye}from"./square-terminal-BVG6cUT1.js";import{t as be}from"./trash-2-CNrPOoPR.js";import{t as xe}from"./triangle-alert-CE1q54ci.js";import{t as Se}from"./wrench-6pg6_bqI.js";import{t as Ce}from"./x-07u4-129.js";import{t as we}from"./brand-DIEc3fK8.js";import{a as Te}from"./dist-41X0pdUs.js";import{c as Ee,i as De,o as Oe,s as ke}from"./dist-BsRXXcSL.js";import{t as Ae}from"./dist-DzGQ7sLi.js";import{i as je,n as Me,r as Ne,t as Pe}from"./accordion-CiJMkjqX.js";import{t as Fe}from"./dist-OB2r6Xsr.js";import{n as Ie,r as Le,t as Re}from"./dist-BaBySQmo.js";import{c as ze,i as Be,n as Ve,p as He,r as Ue,t as We}from"./dropdown-menu-CFIFNaKO.js";import{i as Ge,n as Ke,t as qe}from"./popover-BMTgTASl.js";import{a as Je,i as Ye,n as Xe,r as Ze,t as Qe}from"./select-DD_WO-gs.js";import{t as $e}from"./separator-BPh_qxvc.js";import{t as et}from"./slider-DTmAZl-R.js";import{t as tt}from"./switch-D_G8wFhs.js";import{t as L}from"./utils-C8uzG5AZ.js";import{n as R,r as nt,t as z}from"./button-CCcCN8tE.js";import{n as rt,t as it}from"./kbd-CAufZTkl.js";import{i as at,t as ot}from"./config-search-DdXAm7PX.js";import{_ as st,c as ct,d as lt,f as ut,h as dt,l as ft,m as pt,o as mt,p as ht,t as gt,u as _t}from"./shortcuts-DXHroTTi.js";import{a as vt}from"./format-DMJQzoZ7.js";import{t as yt}from"./StatusGlyph-1KgitlUg.js";import{a as bt,i as xt,l as St,o as Ct,s as wt,t as Tt}from"./dialog-D1TVm0d6.js";import{t as B}from"./input-CPw-zkYh.js";import{t as Et}from"./textarea-DmATpOqT.js";import{t as Dt}from"./model-display-kDwvtxrW.js";import{n as Ot,r as kt,t as At}from"./PageState-Cz6vFMXv.js";import{t as jt}from"./useOverlayFocusReturn-NkxBSSjb.js";import{i as V,n as H,o as U,r as Mt,s as Nt,t as W}from"./FeaturePage-DT_WfUIg.js";import{n as G}from"./field-DoLEb0np.js";import{t as Pt}from"./MarkdownMessage-zaqhqJ44.js";import{t as K}from"./AppSelect-BD6RAaJ5.js";import{n as Ft}from"./public-flags-DEs9Uj_y.js";import{t as It}from"./badge-CWB3lj2H.js";import{a as Lt,i as Rt,l as zt,n as Bt,o as Vt,r as Ht,s as Ut,t as Wt}from"./app-primitives-Drz_SjnR.js";import{t as Gt}from"./BrandLogo-k3CvJjd4.js";import{n as Kt,r as qt,t as Jt}from"./collapsible-Dcoy-qnz.js";import{C as Yt,_ as Xt,a as Zt,c as Qt,d as $t,g as en,i as tn,l as nn,o as rn,p as an,r as on,s as sn,v as cn,x as ln,y as un}from"./app-update-B6njQMB7.js";import{a as dn,n as fn,r as pn,t as mn}from"./ShortcutKeys-Cg-wl3yb.js";import{i as hn,n as gn,r as _n,t as vn}from"./browser-notifications-DBS0oXqN.js";var yn=g(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),bn=g(`blend`,[[`circle`,{cx:`9`,cy:`9`,r:`7`,key:`p2h5vp`}],[`circle`,{cx:`15`,cy:`15`,r:`7`,key:`19ennj`}]]),xn=g(`cat`,[[`path`,{d:`M12 5c.67 0 1.35.09 2 .26 1.78-2 5.03-2.84 6.42-2.26 1.4.58-.42 7-.42 7 .57 1.07 1 2.24 1 3.44C21 17.9 16.97 21 12 21s-9-3-9-7.56c0-1.25.5-2.4 1-3.44 0 0-1.89-6.42-.5-7 1.39-.58 4.72.23 6.5 2.23A9.04 9.04 0 0 1 12 5Z`,key:`x6xyqk`}],[`path`,{d:`M8 14v.5`,key:`1nzgdb`}],[`path`,{d:`M16 14v.5`,key:`1lajdz`}],[`path`,{d:`M11.25 16.25h1.5L12 17l-.75-.75Z`,key:`12kq1m`}]]),Sn=g(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),Cn=g(`fold-vertical`,[[`path`,{d:`M12 22v-6`,key:`6o8u61`}],[`path`,{d:`M12 8V2`,key:`1wkif3`}],[`path`,{d:`M4 12H2`,key:`rhcxmi`}],[`path`,{d:`M10 12H8`,key:`s88cx1`}],[`path`,{d:`M16 12h-2`,key:`10asgb`}],[`path`,{d:`M22 12h-2`,key:`14jgyd`}],[`path`,{d:`m15 19-3-3-3 3`,key:`e37ymu`}],[`path`,{d:`m15 5-3 3-3-3`,key:`19d6lf`}]]),wn=g(`laptop`,[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]),Tn=g(`monitor-cog`,[[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`m14.305 7.53.923-.382`,key:`1mlnsw`}],[`path`,{d:`m15.228 4.852-.923-.383`,key:`82mpwg`}],[`path`,{d:`m16.852 3.228-.383-.924`,key:`ln4sir`}],[`path`,{d:`m16.852 8.772-.383.923`,key:`1dejw0`}],[`path`,{d:`m19.148 3.228.383-.924`,key:`192kgf`}],[`path`,{d:`m19.53 9.696-.382-.924`,key:`fiavlr`}],[`path`,{d:`m20.772 4.852.924-.383`,key:`1j8mgp`}],[`path`,{d:`m20.772 7.148.924.383`,key:`zix9be`}],[`path`,{d:`M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7`,key:`1tnzv8`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}]]),En=g(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),Dn=g(`qr-code`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),On=g(`radar`,[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`,key:`qzzz0`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`,key:`1yjesh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`,key:`1u2y91`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]),kn=g(`scale`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]),An=g(`scan-line`,[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}]]),jn=g(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),Mn=g(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Nn=g(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),Pn=g(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Fn=g(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),In=g(`unfold-vertical`,[[`path`,{d:`M12 22v-6`,key:`6o8u61`}],[`path`,{d:`M12 8V2`,key:`1wkif3`}],[`path`,{d:`M4 12H2`,key:`rhcxmi`}],[`path`,{d:`M10 12H8`,key:`s88cx1`}],[`path`,{d:`M16 12h-2`,key:`10asgb`}],[`path`,{d:`M22 12h-2`,key:`14jgyd`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m15 5-3-3-3 3`,key:`itvq4r`}]]),Ln=g(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),q=e(i(),1),J=a(),Rn=Object.defineProperty,Y=(e,t)=>Rn(e,`name`,{value:t,configurable:!0}),zn=`Radio`,[Bn,Vn]=ke(zn),[Hn,Un]=Bn(zn);function Wn(e){let{__scopeRadio:t,checked:n=!1,children:r,disabled:i,form:a,name:o,onCheck:s,required:c,value:l=`on`,internal_do_not_use_render:u}=e,[d,f]=q.useState(null),[p,m]=q.useState(null),h=q.useRef(!1),[g,_]=q.useReducer(e=>e+1,0),v={checked:n,disabled:i,required:c,name:o,form:a,value:l,control:d,setControl:f,hasConsumerStoppedPropagationRef:h,userInteractionCount:g,onUserInteraction:_,isFormControl:!d||!!a||!!d.closest(`form`),bubbleInput:p,setBubbleInput:m,onCheck:Y(()=>s?.(),`onCheck`)};return(0,J.jsx)(Hn,{scope:t,...v,children:Yn(u)?u(v):r})}Y(Wn,`RadioProvider`);var Gn=`RadioTrigger`,Kn=q.forwardRef(Y(function({__scopeRadio:e,onClick:t,...n},r){let{checked:i,disabled:a,value:o,setControl:s,onCheck:c,hasConsumerStoppedPropagationRef:l,onUserInteraction:u,isFormControl:d,bubbleInput:f}=Un(Gn,e),p=Te(r,s);return(0,J.jsx)(Ee.button,{type:`button`,role:`radio`,"aria-checked":i,"data-state":Xn(i),"data-disabled":a?``:void 0,disabled:a,value:o,...n,ref:p,onClick:Oe(t,e=>{i||(u(),c()),f&&d&&(l.current=e.isPropagationStopped(),l.current||e.stopPropagation())})})},`RadioTrigger`)),qn=`RadioBubbleInput`,Jn=q.forwardRef(Y(function({__scopeRadio:e,onClick:t,...n},r){let{control:i,checked:a,required:o,disabled:s,name:c,value:l,form:u,bubbleInput:d,setBubbleInput:f,hasConsumerStoppedPropagationRef:p,userInteractionCount:m}=Un(qn,e),h=Te(r,f),g=Fe(i),_=q.useRef(!1),v=q.useRef(a),y=q.useRef(m);q.useEffect(()=>{let e=d;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=m!==y.current;y.current=m;let i=v.current!==a;v.current=a;let o=!(r&&p.current);if(i&&n){_.current=!r;let t=new Event(`click`,{bubbles:o});n.call(e,a),e.dispatchEvent(t),_.current=!1}},[d,a,p,m]);let b=q.useRef(a);return(0,J.jsx)(Ee.input,{type:`radio`,"aria-hidden":!0,defaultChecked:b.current,required:o,disabled:s,name:c,value:l,form:u,...n,tabIndex:-1,ref:h,onClick:Oe(t,e=>{_.current&&e.stopPropagation()}),style:{...n.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`RadioBubbleInput`));function Yn(e){return typeof e==`function`}Y(Yn,`isFunction`);function Xn(e){return e?`checked`:`unchecked`}Y(Xn,`getState`);var Zn=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`],Qn=`RadioGroup`,[$n,er]=ke(Qn,[Le,Vn]),tr=Le(),nr=Vn(),[rr,ir]=$n(Qn),ar=q.forwardRef(Y(function(e,t){let{__scopeRadioGroup:n,name:r,form:i,defaultValue:a,value:o,required:s=!1,disabled:c=!1,orientation:l,dir:u,loop:d=!0,onValueChange:f,...p}=e,m=tr(n),h=Ae(u),[g,_]=De({prop:o,defaultProp:a??null,onChange:f,caller:Qn}),[v,y]=q.useState(null),b=Te(t,y),x=q.useRef(g);return q.useEffect(()=>{let e=i?v?.ownerDocument.getElementById(i):v?.closest(`form`);if(e instanceof HTMLFormElement){let t=Y(()=>_(x.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[v,i,_]),(0,J.jsx)(rr,{scope:n,name:r,form:i,required:s,disabled:c,value:g,onValueChange:_,children:(0,J.jsx)(Ie,{asChild:!0,...m,orientation:l,dir:h,loop:d,children:(0,J.jsx)(Ee.div,{role:`radiogroup`,"aria-required":s,"aria-orientation":l,"data-disabled":c?``:void 0,dir:h,...p,ref:b})})})},`RadioGroup`)),or=`RadioGroupItemProvider`,sr=`RadioGroupItemTrigger`;function cr(e){let{__scopeRadioGroup:t,value:n,disabled:r,children:i,internal_do_not_use_render:a}=e,o=ir(or,t),s=nr(t),c=o.disabled||r;return(0,J.jsx)(Wn,{...s,checked:o.value===n,disabled:c,required:o.required,name:o.name,form:o.form,value:n,onCheck:()=>o.onValueChange(n),internal_do_not_use_render:a,children:i})}Y(cr,`RadioGroupItemProvider`);var lr=q.forwardRef(Y(function(e,t){let{__scopeRadioGroup:n,...r}=e,i=tr(n),a=nr(n),{checked:o,disabled:s}=Un(sr,a.__scopeRadio),c=q.useRef(null),l=Te(t,c),u=q.useRef(!1);return q.useEffect(()=>{let e=Y(e=>{Zn.includes(e.key)&&(u.current=!0)},`handleKeyDown`),t=Y(()=>u.current=!1,`handleKeyUp`);return document.addEventListener(`keydown`,e),document.addEventListener(`keyup`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`keyup`,t)}},[]),(0,J.jsx)(Re,{asChild:!0,...i,focusable:!s,active:o,children:(0,J.jsx)(Kn,{...a,...r,ref:l,onKeyDown:Oe(r.onKeyDown,e=>{e.key===`Enter`&&e.preventDefault()}),onFocus:Oe(r.onFocus,()=>{u.current&&c.current?.click()})})})},`RadioGroupItemTrigger`)),ur=q.forwardRef(Y(function(e,t){let{__scopeRadioGroup:n,value:r,disabled:i,...a}=e;return(0,J.jsx)(cr,{__scopeRadioGroup:n,value:r,disabled:i,internal_do_not_use_render:({isFormControl:e})=>(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(lr,{...a,ref:t,__scopeRadioGroup:n}),e&&(0,J.jsx)(dr,{__scopeRadioGroup:n})]})})},`RadioGroupItem`)),dr=q.forwardRef(Y(function(e,t){let{__scopeRadioGroup:n,...r}=e,i=nr(n);return(0,J.jsx)(Jn,{...i,...r,ref:t})},`RadioGroupItemBubbleInput`));o.addResourceBundle(`zh-CN`,`labs`,{notice:`实验功能还在开发中,可能不稳定,也可能在之后的版本里调整或移除。每项单独开关,随时可以关掉;遇到问题请点「反馈」告诉我们。`,listTitle:`可试用的功能`,loading:`正在读取实验功能…`,loadFailed:`没能读取实验功能:{error}`,retry:`重试`,emptyTitle:`目前没有实验功能`,emptyDescription:`有新功能进入测试时,会出现在这里。`,"stage.experimental":`实验中`,"stage.preview":`即将毕业`,whenOffPrefix:`关掉后:`,feedback:`反馈`,toggleLabel:`开启或关闭“{name}”`,"saving.on":`正在开启…`,"saving.off":`正在关闭…`,enabledNow:`已开启,立即生效`,saveFailed:`没能保存:{error}。开关已恢复。`,"unavailable.runtime":`当前连接的 Runtime 不支持这个功能。升级那台机器上的 Pisper 后即可开启。`,openLinkFailed:`没能打开链接。`,"feature.bots.title":`Bots`,"feature.bots.description":`新建多个常驻的 Bot,在对话里交代事情;它们在自己的电脑上干活,改代码时用独立分支,改完交给你确认。`,"feature.bots.whenOff":`Bots 和它们的会话都不再显示;记录都保留,重新打开就回来。正在运行的任务会跑完。`}),o.addResourceBundle(`en-US`,`labs`,{notice:`Labs features are still in development. They may be unstable and may change or be removed in later versions. Each one has its own switch and can be turned off at any time; use Feedback to tell us about problems.`,listTitle:`Available to try`,loading:`Loading Labs features…`,loadFailed:`Couldn't load Labs features: {error}`,retry:`Retry`,emptyTitle:`No Labs features right now`,emptyDescription:`New features appear here when they enter testing.`,"stage.experimental":`Experimental`,"stage.preview":`Graduating soon`,whenOffPrefix:`When turned off: `,feedback:`Feedback`,toggleLabel:`Turn “{name}” on or off`,"saving.on":`Turning on…`,"saving.off":`Turning off…`,enabledNow:`On, effective immediately`,saveFailed:`Couldn't save: {error}. The switch was restored.`,"unavailable.runtime":`The connected Runtime doesn't support this feature. Update Pisper on that machine to turn it on.`,openLinkFailed:`Couldn't open the link.`,"feature.bots.title":`Bots`,"feature.bots.description":`Create several always-on Bots and tell them what to do in a chat. They work on their own computer, use a separate branch for code changes and hand the result to you to confirm.`,"feature.bots.whenOff":`Bots and their sessions are hidden everywhere; nothing is deleted, and turning it back on brings them back. Running tasks finish.`});function fr(e,t){if(typeof window>`u`||!window.__PISPER_MOBILE_APP__)return null;e.preventDefault();let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(`mobile_open_external_url`,{url:t}):Promise.reject(Error(`移动端原生桥不可用。`))}var pr={bots:e=>({title:e(`labs:feature.bots.title`),description:e(`labs:feature.bots.description`),whenOff:e(`labs:feature.bots.whenOff`)})};function mr(e,t){return pr[t]?.(e)??{title:t,description:``,whenOff:``}}function hr(e,t){return e(t===`preview`?`labs:stage.preview`:`labs:stage.experimental`)}function gr({notify:e}){let{t}=l(),n=Ft(e=>e.features),r=Ft(e=>e.status),i=Ft(e=>e.error),a=Ft(e=>e.pending),o=Ft(e=>e.rowErrors),s=Ft(e=>e.load),c=Ft(e=>e.setEnabled),[u,d]=(0,q.useState)(()=>new Set);(0,q.useEffect)(()=>{s()},[s]);let f=async(e,t)=>{await c(e,t);let n=Ft.getState(),r=!n.rowErrors[e]&&n.features.some(n=>n.id===e&&n.enabled===t);d(n=>{let i=new Set(n);return r&&t?i.add(e):i.delete(e),i})},p=n=>{fr(n,n.currentTarget.href)?.catch(()=>e(t(`labs:openLinkFailed`),`error`))},m;return m=r===`loading`&&n.length===0?(0,J.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 py-6 text-sm text-content-muted`,children:[(0,J.jsx)(nt,{"aria-hidden":`true`}),t(`labs:loading`)]}):n.length===0?r===`error`?null:(0,J.jsx)(At,{compact:!0,icon:re,title:t(`labs:emptyTitle`),description:t(`labs:emptyDescription`)}):(0,J.jsx)(H,{children:n.map(e=>{let n=mr(t,e.id),r=a[e.id]===!0,i=o[e.id];return(0,J.jsx)(V,{"data-beta-feature":e.id,"data-enabled":e.enabled,icon:(0,J.jsx)(re,{}),name:n.title,status:(0,J.jsx)(It,{variant:`outline`,children:hr(t,e.stage)}),description:n.description||void 0,actions:(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[r&&(0,J.jsxs)(`span`,{role:`status`,className:`flex items-center gap-1.5 text-xs text-content-muted`,children:[(0,J.jsx)(nt,{"aria-hidden":`true`}),e.enabled?t(`labs:saving.on`):t(`labs:saving.off`)]}),(0,J.jsx)(tt,{checked:e.enabled,disabled:r||!e.available,"aria-busy":r,"aria-label":t(`labs:toggleLabel`,{name:n.title}),onCheckedChange:t=>void f(e.id,t)})]}),detail:(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5 pb-3 text-xs leading-relaxed text-content-muted`,children:[n.whenOff&&(0,J.jsxs)(`p`,{children:[t(`labs:whenOffPrefix`),n.whenOff]}),e.feedbackUrl&&(0,J.jsxs)(`a`,{className:`inline-flex w-fit items-center gap-1 text-content-secondary underline decoration-stroke-strong underline-offset-3 hover:text-content`,href:e.feedbackUrl,target:`_blank`,rel:`noopener noreferrer`,"data-web-preview":`external`,onClick:p,children:[t(`labs:feedback`),(0,J.jsx)(P,{className:`size-3.5`,"aria-hidden":`true`})]}),!e.available&&(0,J.jsxs)(`p`,{className:`flex items-start gap-1.5 text-content-secondary`,children:[(0,J.jsx)(ae,{className:`mt-[3px] size-3.5 flex-none`,"aria-hidden":`true`}),t(`labs:unavailable.runtime`)]}),e.enabled&&u.has(e.id)&&!r&&(0,J.jsxs)(`p`,{role:`status`,className:`flex items-center gap-1.5 text-content-secondary`,children:[(0,J.jsx)(E,{className:`size-3.5 flex-none`,"aria-hidden":`true`}),t(`labs:enabledNow`)]}),i&&(0,J.jsx)(W,{className:`mt-1`,children:(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[t(`labs:saveFailed`,{error:i.message}),(0,J.jsx)(z,{size:`sm`,variant:`outline`,onClick:()=>void f(e.id,i.desired),children:t(`labs:retry`)})]})})]})},e.id)})}),(0,J.jsxs)(`div`,{"data-labs-settings":!0,className:`flex min-w-0 flex-col`,children:[(0,J.jsxs)(`p`,{role:`note`,className:`flex items-start gap-2 rounded-[var(--r-md)] bg-surface-subtle px-3 py-2.5 text-[13px] leading-relaxed text-content-secondary`,children:[(0,J.jsx)(re,{className:`mt-[3px] size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),t(`labs:notice`)]}),r===`error`&&(0,J.jsx)(W,{children:(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[t(`labs:loadFailed`,{error:i}),(0,J.jsx)(z,{size:`sm`,variant:`outline`,onClick:()=>void s(),children:t(`labs:retry`)})]})}),(0,J.jsx)(U,{title:t(`labs:listTitle`),count:n.length||void 0,children:m})]})}function _r({className:e,...t}){return(0,J.jsx)(Wt,{"data-settings-card":!0,className:L(`rounded-none border-x-0 border-t border-b-0 border-stroke-soft bg-transparent px-0`,e),...t})}var vr=Vt,yr=zt;function br(e){return(0,J.jsx)(Ut,{density:`compact`,...e})}function xr({className:e,...t}){return(0,J.jsx)(`div`,{"data-settings-group":!0,className:L(`@container/card min-w-0 divide-y divide-stroke-soft border-y border-stroke-soft`,e),...t})}function Sr({label:e,help:t,htmlFor:n,labelId:r,helpId:i,children:a,className:o}){return(0,J.jsxs)(`div`,{className:L(`grid min-w-0 gap-1.5 py-2.5 @min-[480px]/card:grid-cols-[168px_minmax(0,1fr)] @min-[480px]/card:items-center @min-[480px]/card:gap-4`,o),children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`label`,{id:r,htmlFor:n,className:`text-sm font-medium text-content`,children:e}),t&&(0,J.jsx)(`p`,{id:i,className:`mt-0.5 text-xs text-content-muted`,children:t})]}),(0,J.jsx)(`div`,{className:`min-w-0 @min-[480px]/card:max-w-[460px]`,children:a})]})}var Cr=`0.6.18`,wr=`https://github.com/ling-kong-ran/pisper`,Tr=`${wr}/blob/release/LICENSE`;function Er({href:e,icon:t,label:n,value:r,onClick:i}){return(0,J.jsxs)(`a`,{className:`group grid min-h-14 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-3 py-2.5 text-left no-underline`,href:e,target:`_blank`,rel:`noopener noreferrer`,"data-web-preview":`external`,onClick:i,children:[(0,J.jsx)(`span`,{className:`grid size-7.5 place-items-center rounded-md border border-key-border bg-key text-content-muted shadow-key transition-colors group-hover:text-content`,children:(0,J.jsx)(t,{size:16,"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block text-sm font-medium text-content`,children:n}),(0,J.jsx)(`span`,{className:`mt-0.5 block truncate font-mono text-xs text-content-muted`,children:r})]}),(0,J.jsx)(P,{"aria-hidden":`true`,className:`text-content-muted transition-colors group-hover:text-content`,size:14})]})}function Dr({update:e,notify:t}){let{t:n}=l(),r=e.info?.version||Cr,i=e=>{fr(e,e.currentTarget.href)?.catch(()=>t(n(`config:aboutSettings.openLinkFailed`),`error`))};return(0,J.jsxs)(`div`,{className:`mx-auto flex w-full flex-col gap-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 rounded-[15px] shadow-raise`,children:(0,J.jsx)(Gt,{size:56})}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`h2`,{className:`text-[length:calc(var(--ui-font-size)*10/7)] leading-[1.3] font-semibold tracking-[-.015em] text-content`,children:`Pisper`}),(0,J.jsxs)(yr,{tone:`gray`,className:`font-mono`,children:[`v`,r]})]}),(0,J.jsx)(`p`,{className:`mt-1 text-sm text-content-muted`,children:n(`config:aboutSettings.description`)})]})]}),(0,J.jsxs)(`section`,{"data-config-card":`about-project`,children:[(0,J.jsx)(vr,{title:n(`config:aboutSettings.projectInformation`),className:`mb-3 text-[15px] leading-6 font-medium text-content`}),(0,J.jsxs)(xr,{children:[(0,J.jsx)(Er,{href:wr,icon:j,label:n(`config:aboutSettings.sourceCode`),value:`github.com/ling-kong-ran/pisper`,onClick:i}),(0,J.jsx)(Er,{href:Tr,icon:kn,label:n(`config:aboutSettings.license`),value:`MIT License`,onClick:i})]})]}),(0,J.jsx)(_r,{className:`py-4`,"data-config-card":`about-support`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 max-[540px]:flex-col max-[540px]:items-stretch`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(vr,{title:n(`config:aboutSettings.supportPisper`)}),(0,J.jsx)(`p`,{className:`mt-0.5 max-w-[520px] text-xs leading-5 text-content-muted`,children:n(`config:aboutSettings.supportDescription`)})]}),(0,J.jsx)(z,{asChild:!0,className:`max-[650px]:h-11 max-[540px]:w-full`,children:(0,J.jsxs)(`a`,{href:wr,target:`_blank`,rel:`noopener noreferrer`,"data-web-preview":`external`,onClick:i,children:[(0,J.jsx)(Nn,{size:15}),n(`config:aboutSettings.starOnGitHub`)]})})]})}),(0,J.jsx)(`p`,{className:`text-center text-xs text-content-muted`,children:n(`config:aboutSettings.copyright`)})]})}function Or(e){window.dispatchEvent(new CustomEvent(`pisper:desktop-pet-changed`,{detail:e}))}function kr({notify:e,requestConfirm:t}){let{t:n}=l(),r=window.pisperDesktop,i=(0,q.useMemo)(()=>r?.getPetStatus?{getStatus:()=>r.getPetStatus(),setEnabled:e=>r.setPetEnabled(e),setOpacity:e=>r.setPetOpacity(e),search:e=>r.searchPets(e),install:e=>r.installPet(e),select:e=>r.selectPet(e),remove:e=>r.removePet(e),openCatalog:()=>void r.openPetdex?.()}:{getStatus:()=>f(`/api/desktop-pet`),setEnabled:e=>f(`/api/desktop-pet/enabled`,{method:`POST`,body:{enabled:e}}),setOpacity:e=>f(`/api/desktop-pet/opacity`,{method:`POST`,body:{opacity:e}}),search:e=>f(`/api/desktop-pet/catalog?query=${encodeURIComponent(e)}`),install:e=>f(`/api/desktop-pet/install`,{method:`POST`,body:{slug:e}}),select:e=>f(`/api/desktop-pet/select`,{method:`POST`,body:{slug:e}}),remove:e=>f(`/api/desktop-pet/${encodeURIComponent(e)}`,{method:`DELETE`}),openCatalog:()=>window.open(`https://petdex.dev`,`_blank`,`noopener,noreferrer`)},[r]),[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(``),[u,d]=(0,q.useState)([]),[p,m]=(0,q.useState)(100),[h,g]=(0,q.useState)(``),[_,v]=(0,q.useState)(``),y=(0,q.useCallback)(e=>{o(e),m(Math.round((e.opacity??1)*100))},[]),b=(0,q.useCallback)(async()=>{try{v(``),y(await i.getStatus())}catch(e){v(e instanceof Error?e.message:String(e))}},[y,i]),x=(0,q.useCallback)(async()=>{g(`search`);try{v(``),d(await i.search(s))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(``)}},[i,s]);(0,q.useEffect)(()=>{b(),i.search(``).then(d).catch(()=>{})},[i,b]);let S=async t=>{let r=a;o(e=>e&&{...e,enabled:t,running:!!(t&&e.installed.length)}),g(`toggle`);try{v(``);let r=await i.setEnabled(t);y(r),Or(r),e(n(t?`config:desktopPetSettings.petEnabled`:`config:desktopPetSettings.petDisabled`))}catch(e){o(r),v(e instanceof Error?e.message:String(e))}finally{g(``)}},C=async e=>{g(`opacity`);try{v(``);let t=await i.setOpacity(e);y(t),Or(t)}catch(e){m(Math.round((a?.opacity??1)*100)),v(e instanceof Error?e.message:String(e))}finally{g(``)}},w=async(t=s)=>{if(t.trim()){g(`install`);try{v(``);let r=await i.install(t);y(r),Or(r),e(n(`config:desktopPetSettings.petInstalled`,{name:r.selectedName||t}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(``)}}},T=async t=>{if(t!==a?.selectedSlug){g(`select:${t}`);try{v(``);let r=await i.select(t);y(r),Or(r),e(n(`config:desktopPetSettings.petSelected`,{name:r.selectedName||t}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(``)}}},D=async r=>{if(await t({title:n(`config:desktopPetSettings.deleteTitle`),message:n(`config:desktopPetSettings.deleteConfirm`,{name:r.name}),confirmLabel:n(`config:desktopPetSettings.delete`),tone:`danger`})){g(`remove:${r.slug}`);try{v(``);let t=await i.remove(r.slug);y(t),Or(t),e(n(`config:desktopPetSettings.petRemoved`,{name:r.name}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(``)}}};return(0,J.jsxs)(J.Fragment,{children:[_&&(0,J.jsx)(W,{children:_}),(0,J.jsx)(U,{title:n(`config:desktopPetSettings.displayTitle`),"data-config-card":`desktop-pet-settings`,children:a?(0,J.jsxs)(H,{children:[(0,J.jsx)(V,{icon:(0,J.jsx)(xn,{}),name:n(`config:desktopPetSettings.showOnDesktop`),description:a.selectedName?n(`config:desktopPetSettings.currentPet`,{name:a.selectedName}):n(`config:desktopPetSettings.installBeforeEnabling`),status:(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[a.running&&(0,J.jsx)(yt,{status:`done`,className:`size-3.5`}),a.running?n(`config:desktopPetSettings.running`):n(`config:desktopPetSettings.stopped`)]}),actions:(0,J.jsx)(tt,{checked:a.enabled,disabled:!!h||!a.installed.length,onCheckedChange:e=>void S(e),"aria-label":n(`config:desktopPetSettings.showOnDesktop`)})}),(0,J.jsx)(V,{icon:(0,J.jsx)(bn,{}),name:n(`config:desktopPetSettings.opacity`),nameMeta:`${p}%`,actions:(0,J.jsx)(et,{value:[p],min:20,max:100,step:5,disabled:h===`opacity`,onValueChange:([e])=>m(e),onValueCommit:([e])=>void C(e/100),"aria-label":n(`config:desktopPetSettings.opacity`),className:`w-44 max-w-full max-[650px]:w-32`})})]}):(0,J.jsx)(Ot,{kind:`loading`,title:n(`config:desktopPetSettings.loading`)})}),(0,J.jsxs)(U,{title:n(`config:desktopPetSettings.installTitle`),"data-config-card":`desktop-pet-install`,description:n(`config:desktopPetSettings.installDescription`),actions:(0,J.jsxs)(z,{variant:`ghost`,size:`sm`,onClick:i.openCatalog,children:[(0,J.jsx)(P,{}),n(`config:desktopPetSettings.browsePetdex`)]}),children:[(0,J.jsxs)(`div`,{className:`mb-3 flex gap-2`,children:[(0,J.jsx)(B,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&x()},placeholder:n(`config:desktopPetSettings.searchPlaceholder`),"aria-label":n(`config:desktopPetSettings.petSlug`),className:`h-9 min-w-0 flex-1 font-mono pointer-coarse:min-h-11 max-[650px]:min-h-11`}),(0,J.jsxs)(z,{variant:`secondary`,className:`h-9 shrink-0 pointer-coarse:h-11 max-[650px]:h-11`,disabled:h===`search`,onClick:x,children:[h===`search`?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(he,{}),n(`config:desktopPetSettings.search`)]})]}),u.length>0&&(0,J.jsx)(H,{children:u.map(e=>{let t=a?.installed.some(t=>t.slug===e.slug);return(0,J.jsx)(V,{"data-pet-catalog":e.slug,icon:(0,J.jsx)(xn,{}),name:e.displayName,nameMeta:e.slug,status:t?n(`config:desktopPetSettings.installed`):void 0,actions:(0,J.jsxs)(z,{size:`sm`,variant:t?`ghost`:`secondary`,disabled:!!h||t&&e.slug===a?.selectedSlug,"aria-label":`${n(t?`config:desktopPetSettings.use`:`config:desktopPetSettings.install`)}: ${e.displayName}`,onClick:()=>void(t?T(e.slug):w(e.slug)),children:[t?(0,J.jsx)(E,{}):(0,J.jsx)(ee,{}),n(t?`config:desktopPetSettings.use`:`config:desktopPetSettings.install`)]})},e.slug)})})]}),a&&a.installed.length>0&&(0,J.jsx)(U,{title:n(`config:desktopPetSettings.installedTitle`),count:a.installed.length,"data-config-card":`desktop-pet-installed`,description:n(`config:desktopPetSettings.installedDescription`),children:(0,J.jsx)(H,{children:a.installed.map(e=>{let t=e.slug===a.selectedSlug;return(0,J.jsx)(V,{"data-pet-installed":e.slug,"data-selected":t||void 0,className:L(`relative`,t&&`after:absolute after:inset-y-3 after:-left-3 after:w-[3px] after:rounded-full after:bg-star`),icon:(0,J.jsx)(xn,{}),name:e.name,nameMeta:`${e.slug} · ${e.source===`pisper`?`Pisper`:`Petdex`}`,status:t?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,J.jsx)(yt,{status:`done`,className:`size-3.5`}),n(`config:desktopPetSettings.inUse`)]}):void 0,actions:(0,J.jsxs)(J.Fragment,{children:[!t&&(0,J.jsx)(z,{size:`sm`,variant:`ghost`,disabled:!!h,"aria-label":`${n(`config:desktopPetSettings.use`)}: ${e.name}`,onClick:()=>void T(e.slug),children:n(`config:desktopPetSettings.use`)}),e.source===`pisper`&&(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`hover:bg-danger-soft hover:text-danger max-[650px]:size-11 pointer-coarse:size-11`,disabled:!!h,onClick:()=>void D(e),"aria-label":`${n(`config:desktopPetSettings.delete`)}: ${e.name}`,title:n(`config:desktopPetSettings.delete`),children:h===`remove:${e.slug}`?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(be,{})})]})},`${e.source}:${e.slug}`)})})})]})}function X(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function Ar(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}var jr,Z,Mr,Nr,Pr=`__TAURI_TO_IPC_KEY__`;function Fr(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}var Ir=class{constructor(e){jr.set(this,void 0),Z.set(this,0),Mr.set(this,[]),Nr.set(this,void 0),Ar(this,jr,e||(()=>{}),`f`),this.id=Fr(e=>{let t=e.index;if(`end`in e){t==X(this,Z,`f`)?this.cleanupCallback():Ar(this,Nr,t,`f`);return}let n=e.message;if(t==X(this,Z,`f`)){for(X(this,jr,`f`).call(this,n),Ar(this,Z,X(this,Z,`f`)+1,`f`);X(this,Z,`f`)in X(this,Mr,`f`);){let e=X(this,Mr,`f`)[X(this,Z,`f`)];X(this,jr,`f`).call(this,e),delete X(this,Mr,`f`)[X(this,Z,`f`)],Ar(this,Z,X(this,Z,`f`)+1,`f`)}X(this,Z,`f`)===X(this,Nr,`f`)&&this.cleanupCallback()}else X(this,Mr,`f`)[t]=n})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){Ar(this,jr,e,`f`)}get onmessage(){return X(this,jr,`f`)}[(jr=new WeakMap,Z=new WeakMap,Mr=new WeakMap,Nr=new WeakMap,Pr)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[Pr]()}};function Lr(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function Rr(e,t){return Lr(`plugin:barcode-scanner|${e}`,t)}function zr(e){return e instanceof Error?e.message:String(e)}function Br(e){return/cancel(?:led|ed)/i.test(zr(e))}function Vr(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function Hr(e){return Array.isArray(e)?new TextDecoder().decode(Uint8Array.from(e)):``}function Ur(e){if(!e.isActive||!e.port)return null;let t=Hr(e.txt.fp);if(!/^SHA256:[0-9A-F]{64}$/i.test(t))return null;let n=e.addresses.find(e=>/^\d{1,3}(?:\.\d{1,3}){3}$/.test(e))||e.addresses.find(e=>e.includes(`:`));if(!n)return null;let r=n.includes(`:`)?`[${n}]`:n,i=Hr(e.txt.name)||e.name||`Pisper Desktop`,a=`https://${r}:${e.port}`;return{id:`${e.fullName}:${a}`,name:i,url:a,fingerprint:t}}function Wr(e){return new Promise(t=>window.setTimeout(t,e))}function Gr({open:e,onOpenChange:t}){let{t:n}=l(),r=jt(e),[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(!1),[c,u]=(0,q.useState)([]),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(``),[h,g]=(0,q.useState)(``),[_,v]=(0,q.useState)(``),y=(0,q.useRef)(!1),x=(0,q.useRef)(!1),S=(0,q.useRef)(!1),C=(0,q.useRef)(0),w=(0,q.useRef)(``),T=(0,q.useCallback)(e=>{y.current=e,s(e)},[]),E=(0,q.useCallback)(async()=>{x.current=!0,y.current&&await Rr(`cancel`).catch(()=>void 0),T(!1),a(null)},[T]);(0,q.useEffect)(()=>{if(!o)return;let e=document.getElementById(`root`),t=[],n=(e,n,r)=>{e&&(t.push({element:e,property:n,value:e.style.getPropertyValue(n),priority:e.style.getPropertyPriority(n)}),e.style.setProperty(n,r,`important`))};return n(document.documentElement,`background`,`transparent`),n(document.body,`background`,`transparent`),n(e,`background`,`transparent`),n(e,`visibility`,`hidden`),()=>{for(let{element:e,property:n,value:r,priority:i}of t.reverse())r?e.style.setProperty(n,r,i):e.style.removeProperty(n)}},[o]),(0,q.useEffect)(()=>{if(!o)return;let e=`pisper-scanner-${Date.now()}`;window.history.pushState({...window.history.state,pisperScanner:e},``);let t=()=>void E();return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),!S.current&&window.history.state?.pisperScanner===e&&window.history.back()}},[E,o]);let D=e=>{if(!e.proxyUrl)throw Error(n(`config:mobileServer.pairFailed`));window.location.replace(e.proxyUrl)},O=(0,q.useCallback)(async()=>{let e=++C.current;f(!0),m(``),u([]);let t=new Ir;t.onmessage=t=>{if(C.current!==e)return;if(t.reason===`permission-denied`){m(n(`config:mobileServer.localNetworkDenied`));return}if(t.reason?.startsWith(`error:`)){m(n(`config:mobileServer.discoveryFailed`));return}if(!t.service)return;if(!t.service.isActive){u(e=>e.filter(e=>!e.id.startsWith(`${t.service?.fullName}:`)));return}let r=Ur(t.service);r&&u(e=>[...e.filter(e=>e.fingerprint!==r.fingerprint),r])};let r=null;try{await Lr(`mobile_ensure_local_network_permission`),r=(await Lr(`plugin:dns-sd|browse_start`,{options:{service:{type:`pisper`,protocol:`tcp`,domain:`local`},timeoutMs:4e3},channel:t})).browseId,await Wr(4300)}catch(t){C.current===e&&m(zr(t).includes(`local_network_permission_denied`)?n(`config:mobileServer.localNetworkDenied`):n(`config:mobileServer.discoveryFailed`))}finally{r!==null&&await Lr(`plugin:dns-sd|browse_stop`,{browseId:r}).catch(()=>void 0),C.current===e&&f(!1)}},[n]);(0,q.useEffect)(()=>{if(!(!e||o))return O(),()=>{C.current+=1}},[O,e,o]);let k=(0,q.useCallback)(async()=>{let e=w.current;w.current=``,e&&await Lr(`mobile_cancel_lan_pairing`,{operationId:e}).catch(()=>void 0),a(null),g(``)},[]),A=async e=>{let t=globalThis.crypto?.randomUUID?.()||`lan-${Date.now()}-${Math.random().toString(16).slice(2)}`;w.current=t,a(`lan:${e.id}`),v(``),g(n(`config:mobileServer.awaitingApproval`,{name:e.name}));try{let n=await Lr(`mobile_pair_lan`,{operationId:t,name:e.name,url:e.url,fingerprint:e.fingerprint,deviceName:null});if(w.current!==t)return;D(n)}catch(e){w.current===t&&v(zr(e))}finally{w.current===t&&(w.current=``,a(null),g(``))}},j=async()=>{x.current=!1,S.current=!1,a(`scan`),v(``);try{let e=await Rr(`check_permissions`);if(e.camera!==`granted`&&(e=await Rr(`request_permissions`)),e.camera!==`granted`)throw Error(n(`config:mobileServer.cameraDenied`));if(x.current||(T(!0),await Vr(),x.current))return;let t=await Rr(`scan`,{windowed:!0,formats:[]});if(!t.content)throw Error(n(`config:mobileServer.scanFailed`));S.current=!0,D(await Lr(`mobile_pair`,{payloadJson:t.content,deviceName:null}))}catch(e){!x.current&&!Br(e)&&v(zr(e))}finally{T(!1),a(null),x.current=!1}};return(0,J.jsx)(Tt,{open:e,onOpenChange:e=>{if(!e&&o){E();return}if(!e&&i?.startsWith(`lan:`)){k(),t(!1);return}i||(e||v(``),t(e))},children:(0,J.jsx)(xt,{showCloseButton:!o,overlayClassName:o?`bg-transparent supports-backdrop-filter:backdrop-blur-none`:void 0,className:o?`inset-0 top-0 left-0 h-dvh max-h-none w-screen max-w-none translate-x-0 translate-y-0 gap-0 overflow-hidden rounded-none bg-transparent p-0 text-white ring-0 sm:max-w-none`:`sm:max-w-md`,onPointerDownOutside:o?e=>e.preventDefault():void 0,onCloseAutoFocus:r,children:o?(0,J.jsxs)(`div`,{className:`flex h-dvh w-screen flex-col overflow-hidden`,children:[(0,J.jsxs)(wt,{className:`sr-only`,children:[(0,J.jsx)(St,{children:n(`config:mobileServer.scanTitle`)}),(0,J.jsx)(bt,{children:n(`config:mobileServer.scanHint`)})]}),(0,J.jsxs)(`header`,{className:`flex min-h-16 items-center justify-between gap-3 bg-black/60 px-4 pb-3`,style:{paddingTop:`max(env(safe-area-inset-top), 0.75rem)`},children:[(0,J.jsxs)(z,{variant:`ghost`,className:`h-10 bg-black/40 px-3 text-white hover:bg-black/70 hover:text-white`,onClick:()=>void E(),children:[(0,J.jsx)(b,{}),n(`config:mobileServer.cancelScan`)]}),(0,J.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium`,children:n(`config:mobileServer.scanTitle`)}),(0,J.jsx)(`div`,{className:`w-[88px]`,"aria-hidden":`true`})]}),(0,J.jsx)(`main`,{className:`grid min-h-0 flex-1 place-items-center p-6`,children:(0,J.jsx)(`div`,{className:`relative aspect-square w-[min(72vw,20rem)] rounded-md border-2 border-white/90 shadow-[0_0_0_9999px_rgba(0,0,0,0.18)]`,children:(0,J.jsx)(An,{className:`absolute top-1/2 left-1/2 size-10 -translate-x-1/2 -translate-y-1/2 text-white/75`})})}),(0,J.jsxs)(`footer`,{className:`flex flex-col items-center gap-3 bg-black/60 px-5 pt-4 text-center`,style:{paddingBottom:`max(env(safe-area-inset-bottom), 1rem)`},children:[(0,J.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-white/90`,children:n(`config:mobileServer.scanHint`)}),(0,J.jsx)(z,{variant:`outline`,className:`w-full max-w-sm border-white/50 bg-black/30 text-white hover:bg-black/60 hover:text-white`,onClick:()=>void E(),children:n(`config:mobileServer.cancelScan`)})]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(wt,{children:[(0,J.jsx)(St,{children:n(`config:mobileServer.addServer`)}),(0,J.jsx)(bt,{children:n(`config:mobileServer.discoverDescription`)})]}),(0,J.jsxs)(`section`,{className:`grid gap-2`,"aria-live":`polite`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,J.jsx)(On,{className:`size-4`}),n(`config:mobileServer.nearby`)]}),(0,J.jsx)(z,{size:`icon-sm`,variant:`ghost`,disabled:d||i!==null,className:`pointer-coarse:size-11`,"aria-label":n(`config:mobileServer.rediscover`),onClick:()=>void O(),children:(0,J.jsx)(fe,{className:d?`animate-spin`:void 0})})]}),c.length?(0,J.jsx)(`ul`,{className:`m-0 grid max-h-44 list-none divide-y divide-stroke-soft overflow-y-auto border-y border-stroke-soft p-0`,children:c.map(e=>{let t=i===`lan:${e.id}`;return(0,J.jsxs)(`li`,{className:`flex min-h-12 items-center justify-between gap-3 py-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(ge,{className:`size-4 flex-none text-muted-foreground`}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`truncate text-sm`,children:e.name}),(0,J.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.url})]})]}),(0,J.jsxs)(z,{size:`sm`,className:`pointer-coarse:min-h-11`,disabled:i!==null,onClick:()=>void A(e),children:[t?(0,J.jsx)(F,{className:`animate-spin`}):null,n(`config:mobileServer.requestConnect`)]})]},e.id)})}):(0,J.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:n(d?`config:mobileServer.discovering`:`config:mobileServer.noNearby`)}),p?(0,J.jsx)(`p`,{role:`alert`,className:`text-xs leading-relaxed text-content-secondary`,children:p}):null,h?(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-[var(--r-md)] bg-surface-subtle px-3 py-2`,children:[(0,J.jsx)(`p`,{role:`status`,className:`text-xs leading-relaxed`,children:h}),(0,J.jsx)(z,{size:`sm`,variant:`outline`,className:`pointer-coarse:min-h-11`,onClick:()=>void k(),children:n(`config:mobileServer.cancelRequest`)})]}):null]}),(0,J.jsxs)(`div`,{className:`relative py-1`,children:[(0,J.jsx)($e,{}),(0,J.jsx)(`span`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-popover px-2 text-xs text-muted-foreground`,children:n(`config:mobileServer.otherMethods`)})]}),(0,J.jsxs)(z,{className:`w-full pointer-coarse:min-h-11`,disabled:i!==null,onClick:()=>void j(),children:[i===`scan`?(0,J.jsx)(F,{className:`animate-spin`}):(0,J.jsx)(Dn,{}),n(`config:mobileServer.scan`)]}),_?(0,J.jsx)(`p`,{role:`alert`,className:`text-xs leading-relaxed text-content-secondary`,children:_}):null]})})})}function Kr(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function qr({requestConfirm:e}){let{t}=l(),[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(``),[c,u]=(0,q.useState)(!1),d=(0,q.useCallback)(async()=>{try{r(await Kr(`mobile_state`)),a(``)}catch{a(t(`config:mobileServer.loadFailed`))}},[t]);(0,q.useEffect)(()=>{d()},[d]);let f=async(e,t,n=``)=>{s(n||e);try{r(await Kr(e,t)),a(``)}catch(e){a(String(e))}finally{s(``)}},p=async n=>{o||await e({title:t(`config:mobileServer.forget`),message:t(`config:mobileServer.forgetConfirm`),confirmLabel:t(`config:mobileServer.forget`),tone:`danger`})&&await f(`mobile_forget_server`,{id:n.id},n.id)},m=async e=>{s(e);try{let t=await Kr(`mobile_select_server`,{id:e});r(t),a(``),t.proxyUrl&&window.location.replace(t.proxyUrl)}catch(e){a(String(e))}finally{s(``)}},h=n?.mode===`local`,g=n?.mode===`remote`&&!!n.activeId,_=h||g,v=t(h?`config:mobileServer.currentLocal`:g?`config:mobileServer.current`:`config:mobileServer.empty`),y=e=>t(e===`iroh`?`config:mobileServer.transportP2p`:`config:mobileServer.transportLan`);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mt-5 flex min-h-11 items-center gap-2 rounded-[var(--r-md)] border border-stroke bg-surface-subtle px-3 py-2 text-xs text-content-secondary`,role:`status`,"aria-live":`polite`,children:[_?(0,J.jsx)(yt,{status:`done`,className:`size-3.5`}):(0,J.jsx)(k,{className:`size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:v}),n?.activeTransport?(0,J.jsx)(`span`,{className:`flex-none font-mono text-xs text-content-muted`,children:y(n.activeTransport)}):null]}),(0,J.jsx)(Gr,{open:c,onOpenChange:u}),i?(0,J.jsx)(W,{className:`mt-3`,children:i}):null,(0,J.jsx)(U,{title:t(`config:mobileServer.localTitle`),"data-config-card":`mobile-server-local`,children:(0,J.jsx)(H,{children:(0,J.jsx)(V,{icon:(0,J.jsx)(Mn,{}),name:t(`config:mobileServer.localTitle`),description:t(`config:mobileServer.localDescription`),status:h?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,J.jsx)(yt,{status:`done`,className:`size-3.5`}),t(`config:mobileServer.currentLocal`)]}):void 0,actions:h?void 0:(0,J.jsx)(z,{size:`sm`,variant:`secondary`,className:`flex-none max-[650px]:h-11 max-[650px]:px-3 pointer-coarse:h-11`,disabled:!!o,onClick:()=>void(async()=>{s(`mobile_enter_local`);try{let e=await Kr(`mobile_enter_local`);e.onDevice.url&&window.location.replace(e.onDevice.url)}catch(e){a(String(e))}finally{s(``)}})(),children:t(`config:mobileServer.enterLocal`)})})})}),(0,J.jsx)(U,{title:t(`config:mobileServer.title`),count:n?.servers?.length??0,"data-config-card":`mobile-server-main`,description:t(`config:mobileServer.description`),actions:(0,J.jsxs)(z,{size:`sm`,onClick:()=>u(!0),children:[(0,J.jsx)(de,{}),t(`config:mobileServer.addServer`)]}),children:n?.servers?.length?(0,J.jsx)(H,{children:n.servers.map(e=>{let r=n.mode===`remote`&&e.id===n.activeId,i=e.endpoints.find(e=>e.url),a=e.endpoints.find(e=>e.t===`iroh`),s=i?.url||(a?.nodeId?`Iroh ${a.nodeId.slice(0,12)}`:`Iroh`);return(0,J.jsx)(V,{"data-mobile-server":e.id,icon:(0,J.jsx)(ge,{}),name:e.name,nameMeta:t(i&&a?`config:mobileServer.transportLanP2p`:a?`config:mobileServer.transportP2p`:`config:mobileServer.transportLan`),description:(0,J.jsx)(`span`,{className:`font-mono`,children:s}),status:r?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,J.jsx)(yt,{status:`done`,className:`size-3.5`}),n.activeTransport?t(`config:mobileServer.activeTransport`,{transport:y(n.activeTransport)}):t(`config:mobileServer.current`)]}):void 0,actions:(0,J.jsxs)(J.Fragment,{children:[r?null:(0,J.jsx)(z,{size:`sm`,variant:`ghost`,disabled:o===e.id,onClick:()=>void m(e.id),children:t(`config:mobileServer.connect`)}),(0,J.jsx)(z,{size:`icon-sm`,variant:`ghost`,className:`hover:bg-danger-soft hover:text-danger max-[650px]:size-11 pointer-coarse:size-11`,"aria-label":t(`config:mobileServer.forget`),title:t(`config:mobileServer.forget`),disabled:!!o,onClick:()=>void p(e),children:(0,J.jsx)(be,{})})]})},e.id)})}):(0,J.jsx)(At,{compact:!0,title:t(`config:mobileServer.empty`)})})]})}o.addResourceBundle(`zh-CN`,`remote-workspace`,{description:`使用本机的 Pisper 界面,在另一台 Linux 上运行会话、读写文件和执行任务。`,instructions:`先在 Linux 上运行 Pisper,在「设置 → 远程访问」启用连接,然后复制 HTTPS 地址、证书指纹和配对码。请通过可信渠道核对指纹。`,isolation:`每个工作区在独立窗口中打开。会话、文件、模型配置与任务属于远程机器,不会复制本机密钥;关闭窗口不会停止远程正在执行的任务。本机终端与桌面控制不会在远程窗口中启用。`,refresh:`刷新远程工作区`,name:`工作区名称(可选)`,address:`Linux HTTPS 地址`,fingerprint:`证书指纹`,code:`配对码`,pair:`配对并打开`,open:`连接`,show:`显示窗口`,forget:`移除 {name}`,forgetDescription:`这会关闭该工作区的本机窗口并移除保存的连接,不删除远程文件或会话,也不会停止远程任务。如需吊销设备授权,请在 Linux 的远程访问页操作。`,activeTitle:`当前为远程工作区`,activeDescription:`这里的会话、文件和模型设置属于远程 Linux。连接管理请回到本机主窗口;如需修改远程访问服务,请在 Linux 本机操作。`,manualConnection:`手动连接所需信息`,serverAddress:`HTTPS 服务器地址`}),o.addResourceBundle(`en-US`,`remote-workspace`,{description:`Use the local Pisper interface to run conversations, work with files, and execute tasks on another Linux machine.`,instructions:`Run Pisper on Linux and enable Settings → Remote access. Copy its HTTPS address, certificate fingerprint, and pairing code. Verify the fingerprint through a trusted channel.`,isolation:`Each workspace opens in a separate window. Sessions, files, model settings, and tasks belong to the remote machine; local credentials are not copied. Closing the window does not stop remote tasks. Local terminals and desktop controls are not enabled in remote windows.`,refresh:`Refresh remote workspaces`,name:`Workspace name (optional)`,address:`Linux HTTPS address`,fingerprint:`Certificate fingerprint`,code:`Pairing code`,pair:`Pair and open`,open:`Connect`,show:`Show window`,forget:`Remove {name}`,forgetDescription:`Close this workspace’s local windows and forget the saved connection. Remote files, sessions, and running tasks are not deleted or stopped. To revoke the device authorization, use Remote access on Linux.`,activeTitle:`Remote workspace`,activeDescription:`Sessions, files and model settings in this window belong to the remote Linux machine. Manage connections in your local main window; change remote access service settings directly on Linux.`,manualConnection:`Manual connection details`,serverAddress:`HTTPS server address`});function Jr({notify:e}){let{t,language:n}=l(),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)([]),[u,d]=(0,q.useState)([]),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(``),[y,b]=(0,q.useState)(``),[x,S]=(0,q.useState)(!1),[C,w]=(0,q.useState)(``),T=(0,q.useCallback)(async()=>{try{let[e,t,n,r]=await Promise.all([f(`/api/remote/status`),f(`/api/remote/devices`),f(`/api/remote/pairing-requests`).catch(()=>({requests:[]})),f(`/api/remote/firewall`).catch(e=>{if(e&&typeof e==`object`&&`status`in e&&e.status===403)return null;throw e})]);i(e),o(r),c(t.devices.filter(e=>!e.revokedAt)),d(n.requests),w(``)}catch{w(t(`config:remoteAccess.loadFailed`))}},[t]);(0,q.useEffect)(()=>{T()},[T]),(0,q.useEffect)(()=>{if(!r?.listening)return;let e=window.setInterval(()=>void T(),2e3);return()=>window.clearInterval(e)},[T,r?.listening]);let D=async n=>{S(!0);try{await f(`/api/remote/enabled`,{method:`PUT`,body:{enabled:n,configureFirewall:a!==null},timeout:15e4});let e=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;e&&await e(`desktop_iroh_set_enabled`,{enabled:n}).catch(()=>void 0),n||(m(null),g(!1),v(``)),await T()}catch(n){e(t(`config:remoteAccess.toggleFailed`,{message:String(n)}),`error`)}finally{S(!1)}},O=async()=>{S(!0);try{await f(`/api/remote/firewall/retry`,{method:`POST`,body:{},timeout:15e4}),await T()}catch(n){e(t(`config:remoteAccess.firewallRetryFailed`,{message:String(n)}),`error`)}finally{S(!1)}},k={disabled:t(`config:remoteAccess.firewallDisabled`),configured:t(`config:remoteAccess.firewallConfigured`),not_needed:t(`config:remoteAccess.firewallNotNeeded`),needs_authorization:t(`config:remoteAccess.firewallNeedsAuthorization`),unsupported:t(`config:remoteAccess.firewallUnsupported`),cancelled:t(`config:remoteAccess.firewallCancelled`),error:t(`config:remoteAccess.firewallError`),cleanup_pending:t(`config:remoteAccess.firewallCleanupPending`)},A={packaged_app_required:t(`config:remoteAccess.firewallPackagedApp`),unsupported_firewall:t(`config:remoteAccess.firewallUnsupportedBackend`),unsupported_platform:t(`config:remoteAccess.firewallUnsupportedBackend`),permission_denied:t(`config:remoteAccess.firewallPermissionDenied`),cancelled:t(`config:remoteAccess.firewallCancelled`),timeout:t(`config:remoteAccess.firewallTimeout`),block_all:t(`config:remoteAccess.firewallBlockAll`),rule_changed:t(`config:remoteAccess.firewallRuleChanged`),inspection_failed:t(`config:remoteAccess.firewallVerificationFailed`),verification_failed:t(`config:remoteAccess.firewallVerificationFailed`),operation_failed:t(`config:remoteAccess.firewallVerificationFailed`),unsupported:t(`config:remoteAccess.firewallUnsupportedBackend`)},j=async()=>{S(!0),v(``);try{let e=await f(`/api/remote/pairing-code`,{method:`POST`});if(!e?.code||!e?.expiresAt)throw Error(t(`config:remoteAccess.qrUnavailable`));e.connectionInfo=await f(`/api/remote/connection-info`).catch(()=>void 0),m(e),g(!0),e.qrDataUrl||v(t(`config:remoteAccess.qrUnavailable`))}catch(n){let r=t(`config:remoteAccess.pairingFailed`,{message:String(n)});v(r),e(r,`error`)}finally{S(!1)}},M=async(n,r)=>{b(n.id);try{await f(`/api/remote/pairing-requests/${encodeURIComponent(n.id)}/decision`,{method:`POST`,body:{approved:r}}),await T()}catch(n){e(t(`config:remoteAccess.approvalFailed`,{message:String(n)}),`error`)}finally{b(``)}},ee=async n=>{if(window.confirm(t(`config:remoteAccess.revokeConfirm`,{name:n.name})))try{await f(`/api/remote/devices/${encodeURIComponent(n.id)}/revoke`,{method:`POST`}),await T()}catch(n){e(t(`config:remoteAccess.revokeFailed`,{message:String(n)}),`error`)}};if(C&&!r)return(0,J.jsx)(Ot,{kind:`error`,title:t(`config:remoteAccess.loadFailed`),action:(0,J.jsxs)(z,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void T(),children:[(0,J.jsx)(fe,{}),t(`config:remoteAccess.refresh`)]})});if(!r)return(0,J.jsx)(Ot,{kind:`loading`,title:t(`config:remoteAccess.loading`)});let N=r.error?`failed`:r.listening?`on`:r.enabled?`starting`:`off`,P=a!==null&&!a.busy&&[`needs_authorization`,`cancelled`,`error`,`cleanup_pending`].includes(a.state);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Tt,{open:h&&p!==null,onOpenChange:g,children:(0,J.jsxs)(xt,{className:`sm:max-w-md`,children:[(0,J.jsxs)(wt,{children:[(0,J.jsx)(St,{children:t(`config:remoteAccess.pairingQrTitle`)}),(0,J.jsx)(bt,{children:t(`config:remoteAccess.scanQrDescription`)})]}),(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-2`,"aria-live":`polite`,children:[p?.qrDataUrl?(0,J.jsx)(`img`,{src:p.qrDataUrl,alt:t(`config:remoteAccess.qrAlt`),className:`size-64 max-w-full rounded-sm border border-stroke bg-white p-2`}):null,_?(0,J.jsx)(`p`,{role:`alert`,className:`text-center text-xs leading-relaxed text-content-secondary`,children:_}):null,p?(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsx)(`div`,{className:`font-mono text-[20px] font-medium tracking-[0.2em] text-content`,children:p.code}),(0,J.jsx)(`div`,{className:`mt-1 text-xs text-content-muted tabular-nums`,children:t(`config:remoteAccess.codeExpiresAt`,{time:vt(p.expiresAt,n)})})]}):null]}),p?.connectionInfo&&(0,J.jsxs)(`details`,{className:`min-w-0 rounded-md border border-stroke px-3 py-2 text-sm`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer text-content-secondary`,children:t(`remote-workspace:manualConnection`)}),(0,J.jsxs)(`div`,{className:`mt-2 space-y-2 text-xs text-content-muted`,children:[(0,J.jsx)(`div`,{children:t(`remote-workspace:serverAddress`)}),p.connectionInfo.endpoints.map(e=>(0,J.jsx)(`code`,{className:`block font-mono break-all text-content select-all`,children:e.url},e.url)),(0,J.jsx)(`div`,{children:t(`remote-workspace:fingerprint`)}),(0,J.jsx)(`code`,{className:`block font-mono break-all text-content select-all`,children:p.connectionInfo.fingerprint})]})]}),(0,J.jsx)(Ct,{children:(0,J.jsxs)(z,{disabled:x,onClick:()=>void j(),children:[x?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(fe,{}),t(x?`config:remoteAccess.generatingQr`:`config:remoteAccess.regenerate`)]})})]})}),C&&(0,J.jsx)(W,{children:C}),(0,J.jsx)(U,{title:t(`config:remoteAccess.thisComputer`),"data-config-card":`remote-access-main`,children:(0,J.jsxs)(H,{children:[(0,J.jsx)(V,{icon:(0,J.jsx)(se,{}),name:t(`config:remoteAccess.allowConnections`),description:t(`config:remoteAccess.description`),status:(0,J.jsx)(Yr,{attention:N===`failed`,glyph:N===`on`?`done`:N===`starting`?`run`:null,children:t(N===`failed`?`config:remoteAccess.stateFailed`:N===`on`?`config:remoteAccess.stateListening`:N===`starting`?`config:remoteAccess.stateStarting`:`config:remoteAccess.stateOff`)}),actions:(0,J.jsx)(tt,{checked:r.enabled,disabled:x,onCheckedChange:e=>void D(e),"aria-label":t(`config:remoteAccess.title`)}),detail:r.error?(0,J.jsx)(`p`,{className:`text-xs leading-relaxed [overflow-wrap:anywhere] text-st-attn`,children:t(`config:remoteAccess.listenFailed`,{message:r.error})}):void 0}),a?(0,J.jsx)(V,{"aria-live":`polite`,icon:(0,J.jsx)(_e,{}),name:t(`config:remoteAccess.firewallTitle`),description:a.busy?t(`config:remoteAccess.firewallWorking`):k[a.state],status:a.busy?(0,J.jsx)(Yr,{glyph:`run`,children:t(`config:remoteAccess.firewallChecking`)}):P?(0,J.jsx)(Yr,{attention:!0,children:t(`config:remoteAccess.firewallNeedsYou`)}):void 0,actions:r.enabled||a.state===`cleanup_pending`?(0,J.jsxs)(z,{size:`sm`,variant:`secondary`,disabled:x||a.busy,onClick:()=>void O(),children:[x||a.busy?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(fe,{}),r.enabled?t(`config:remoteAccess.firewallRetry`):t(`config:remoteAccess.firewallRetryCleanup`)]}):void 0,detail:(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-xs leading-relaxed text-content-muted`,children:[a.reason&&A[a.reason]?(0,J.jsx)(`p`,{className:`text-content-secondary`,children:A[a.reason]}):null,r.enabled?(0,J.jsx)(`p`,{children:a.scope===`application`?t(`config:remoteAccess.firewallApplicationScope`):a.scope===`program_port`?t(`config:remoteAccess.firewallProgramPortScope`,{port:a.port??`—`}):t(`config:remoteAccess.firewallPortScope`,{port:a.port??`—`})}):null,(0,J.jsx)(`p`,{children:t(`config:remoteAccess.firewallReachability`)}),a.checkedAt?(0,J.jsx)(`p`,{className:`tabular-nums`,children:t(`config:remoteAccess.firewallCheckedAt`,{time:vt(a.checkedAt,n)})}):null]})}):null]})}),r.listening&&u.length?(0,J.jsx)(U,{"aria-live":`polite`,title:t(`config:remoteAccess.pendingApprovals`),count:u.length,meta:(0,J.jsx)(`span`,{className:`font-medium text-st-attn`,children:t(`config:remoteAccess.waitingForYou`)}),description:t(`config:remoteAccess.pendingApprovalsDescription`),children:(0,J.jsx)(H,{children:u.map(e=>(0,J.jsx)(V,{"data-pairing-request":e.id,icon:(0,J.jsx)(Mn,{}),name:e.deviceName,description:(0,J.jsx)(`span`,{className:`font-mono`,children:t(`config:remoteAccess.requestSource`,{ip:e.ip})}),meta:t(`config:remoteAccess.requestedAt`,{time:vt(e.requestedAt,n)}),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(z,{size:`sm`,variant:`ghost`,disabled:y===e.id,onClick:()=>void M(e,!1),children:[(0,J.jsx)(Ce,{}),t(`config:remoteAccess.reject`)]}),(0,J.jsxs)(z,{size:`sm`,disabled:y===e.id,onClick:()=>void M(e,!0),children:[y===e.id?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(E,{}),t(`config:remoteAccess.approve`)]})]})},e.id))})}):null,r.listening?(0,J.jsx)(U,{title:t(`config:remoteAccess.pairing`),"data-config-card":`remote-access-pairing`,children:(0,J.jsx)(H,{children:(0,J.jsx)(V,{icon:(0,J.jsx)(Dn,{}),name:t(`config:remoteAccess.pairWithPhone`),description:t(`config:remoteAccess.pairingDescription`),actions:(0,J.jsxs)(z,{size:`sm`,disabled:x,onClick:()=>void j(),children:[x?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(Dn,{}),t(x?`config:remoteAccess.generatingQr`:`config:remoteAccess.generateQr`)]}),detail:_&&!h?(0,J.jsx)(`p`,{className:`text-xs leading-relaxed text-content-secondary`,"aria-live":`polite`,children:_}):void 0})})}):null,(0,J.jsx)(U,{title:t(`config:remoteAccess.devices`),count:s.length,"data-config-card":`remote-access-devices`,actions:(0,J.jsx)(z,{size:`icon-sm`,variant:`ghost`,className:`pointer-coarse:size-11 max-[650px]:size-11`,onClick:()=>void T(),"aria-label":t(`config:remoteAccess.refresh`),title:t(`config:remoteAccess.refresh`),children:(0,J.jsx)(fe,{})}),children:s.length===0?(0,J.jsx)(At,{compact:!0,title:t(`config:remoteAccess.noDevices`)}):(0,J.jsx)(H,{children:s.map(e=>(0,J.jsx)(V,{icon:(0,J.jsx)(Mn,{}),name:e.name,nameMeta:e.current?t(`config:remoteAccess.currentDevice`):void 0,description:t(`config:remoteAccess.lastSeen`,{time:vt(e.lastSeenAt,n)}),actions:(0,J.jsx)(z,{size:`sm`,variant:`ghost`,className:`hover:bg-danger-soft hover:text-danger`,"aria-label":`${t(`config:remoteAccess.revoke`)}: ${e.name}`,onClick:()=>void ee(e),children:t(`config:remoteAccess.revoke`)})},e.id))})})]})}function Yr({attention:e=!1,glyph:t=null,children:n}){let r=e?`attention`:t;return(0,J.jsxs)(`span`,{className:L(`inline-flex min-w-0 items-center gap-1.5 whitespace-nowrap`,e?`font-medium text-st-attn`:`text-content-secondary`),children:[r&&(0,J.jsx)(yt,{status:r,className:`size-3.5`}),n]})}function Xr({requestConfirm:e}){let{t}=l(),n=window.pisperDesktop?.remoteWorkspaces,[r,i]=(0,q.useState)([]),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(``),[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(``),v=(0,q.useCallback)(async()=>{n&&i(await n.list())},[n]);(0,q.useEffect)(()=>{v().catch(e=>_(String(e)))},[v]);let y=async e=>{if(!m){h(!0),_(``);try{await e()}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}}};return window.__PISPER_REMOTE_WORKSPACE__?(0,J.jsx)(U,{title:t(`config:remoteWorkspace.title`),"data-config-card":`remote-workspaces`,children:(0,J.jsx)(H,{children:(0,J.jsx)(V,{icon:(0,J.jsx)(ge,{}),name:t(`remote-workspace:activeTitle`),description:t(`remote-workspace:activeDescription`),detail:(0,J.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:t(`remote-workspace:isolation`)})})})}):n?(0,J.jsxs)(U,{title:t(`config:remoteWorkspace.title`),count:r.length,"data-config-card":`remote-workspaces`,description:t(`remote-workspace:description`),actions:(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`pointer-coarse:size-11`,disabled:m,"aria-label":t(`remote-workspace:refresh`),title:t(`remote-workspace:refresh`),onClick:()=>void y(v),children:(0,J.jsx)(fe,{className:`size-3.5`})}),children:[r.length>0&&(0,J.jsx)(H,{children:r.map(r=>(0,J.jsx)(V,{icon:(0,J.jsx)(ge,{}),name:r.name,description:(0,J.jsx)(`span`,{className:`font-mono`,children:r.address}),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(z,{type:`button`,size:`sm`,variant:`secondary`,disabled:m,onClick:()=>void y(async()=>{await n.open(r.id),await v()}),children:[r.connected?t(`remote-workspace:show`):t(`remote-workspace:open`),(0,J.jsx)(S,{className:`size-3.5`})]}),(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`hover:bg-danger-soft hover:text-danger max-[650px]:size-11 pointer-coarse:size-11`,disabled:m,"aria-label":t(`remote-workspace:forget`,{name:r.name}),onClick:()=>void y(async()=>{await e({title:t(`remote-workspace:forget`,{name:r.name}),message:t(`remote-workspace:forgetDescription`)})&&(await n.forget(r.id),await v())}),children:(0,J.jsx)(be,{className:`size-3.5`})})]})},r.id))}),(0,J.jsxs)(`div`,{className:`@container/card mt-3 rounded-[var(--r-md)] border border-stroke px-3 pt-2 pb-1`,children:[(0,J.jsx)(`p`,{className:`py-1.5 text-xs leading-relaxed text-content-secondary`,children:t(`remote-workspace:instructions`)}),(0,J.jsxs)(`form`,{className:`divide-y divide-stroke-soft border-t border-stroke-soft`,onSubmit:e=>{e.preventDefault(),y(async()=>{let e=await n.pair({name:a,address:s,fingerprint:u,code:f});p(``),await v(),await n.open(e),await v()})},children:[(0,J.jsx)(Sr,{label:t(`remote-workspace:name`),htmlFor:`remote-workspace-name`,children:(0,J.jsx)(B,{id:`remote-workspace-name`,value:a,maxLength:160,disabled:m,placeholder:`Linux`,onChange:e=>o(e.target.value)})}),(0,J.jsx)(Sr,{label:t(`remote-workspace:address`),htmlFor:`remote-workspace-address`,children:(0,J.jsx)(B,{id:`remote-workspace-address`,type:`url`,value:s,required:!0,disabled:m,placeholder:`https://192.168.1.10:5174`,autoComplete:`off`,spellCheck:!1,className:`font-mono`,onChange:e=>c(e.target.value)})}),(0,J.jsx)(Sr,{label:t(`remote-workspace:fingerprint`),htmlFor:`remote-workspace-fingerprint`,children:(0,J.jsx)(B,{id:`remote-workspace-fingerprint`,value:u,required:!0,disabled:m,placeholder:`SHA256:…`,autoComplete:`off`,spellCheck:!1,className:`font-mono text-xs`,onChange:e=>d(e.target.value)})}),(0,J.jsx)(Sr,{label:t(`remote-workspace:code`),htmlFor:`remote-workspace-code`,children:(0,J.jsx)(B,{id:`remote-workspace-code`,value:f,required:!0,maxLength:64,disabled:m,placeholder:`ABCD-EFGH`,autoComplete:`off`,spellCheck:!1,className:`font-mono`,onChange:e=>p(e.target.value)})}),(0,J.jsx)(`div`,{className:`flex justify-end py-3`,children:(0,J.jsxs)(z,{type:`submit`,className:`max-[650px]:h-11`,disabled:m,children:[m?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(S,{className:`size-3.5`}),t(`remote-workspace:pair`)]})})]})]}),g&&(0,J.jsx)(W,{className:`mt-3`,children:g}),(0,J.jsx)(`p`,{className:`mt-3 text-xs leading-relaxed text-content-muted`,children:t(`remote-workspace:isolation`)})]}):null}function Zr({section:e,notify:t,requestConfirm:n,onBack:r}){let{t:i}=l(),a=m(e=>e.capabilities),o=h(),s=p(a,e,{mobileApp:o}),c=i(e===`remote-access`?`config:configPage.remoteAccess`:e===`mobile-server`?`config:configPage.mobileServer`:`config:configPage.desktopPet`),u=i(e===`remote-access`?`config:deviceFeature.remoteAccessLede`:e===`mobile-server`?`config:deviceFeature.mobileServerLede`:`config:desktopPetSettings.description`),d;return d=s.supported?e===`desktop-pet`?(0,J.jsx)(kr,{notify:t,requestConfirm:n}):e===`mobile-server`?(0,J.jsx)(qr,{requestConfirm:n}):(0,J.jsxs)(J.Fragment,{children:[!window.__PISPER_REMOTE_WORKSPACE__&&(0,J.jsx)(Jr,{notify:t}),(0,J.jsx)(Xr,{requestConfirm:n})]}):(0,J.jsx)(Qr,{section:e,support:s}),(0,J.jsx)(Mt,{"data-device-feature":e,title:c,description:u,back:r&&{label:i(`navigation:sidebar.features`),ariaLabel:i(`navigation:shell.backToFeaturesLabel`),onBack:r},children:(0,J.jsx)(`div`,{"data-config-card":ot,className:`min-w-0`,children:d})})}function Qr({section:e,support:t}){let{t:n}=l(),r=n(e===`desktop-pet`?`config:desktopPetSettings.showOnDesktop`:e===`mobile-server`?`config:mobileServer.title`:`config:remoteAccess.allowConnections`),i=t.reason===`runtime`?n(`config:deviceFeature.runtimeUnavailable`):t.reason===`mobile-only`?n(`config:deviceFeature.mobileOnly`):n(e===`desktop-pet`?`config:desktopPetSettings.desktopOnlyDescription`:`config:deviceFeature.remoteAccessDesktopOnly`);return(0,J.jsx)(U,{title:n(`config:deviceFeature.unavailableTitle`),"data-device-unsupported":!0,children:(0,J.jsx)(H,{children:(0,J.jsx)(V,{icon:e===`desktop-pet`?(0,J.jsx)(w,{}):(0,J.jsx)(se,{}),name:r,description:i,status:n(`config:deviceFeature.unavailable`),actions:(0,J.jsx)(tt,{checked:!1,disabled:!0,"aria-label":r})})})})}function $r({title:e,description:t,action:n,children:r,className:i,...a}){let o=(0,q.useId)();return(0,J.jsxs)(`section`,{"aria-labelledby":o,className:L(`min-w-0`,i),...a,children:[(0,J.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h2`,{id:o,className:`text-[15px] leading-6 font-medium text-content`,children:e}),t&&(0,J.jsx)(`p`,{className:`mt-0.5 text-[13px] text-content-muted`,children:t})]}),n]}),(0,J.jsx)(`div`,{className:`divide-y divide-stroke-soft`,children:r})]})}function Q({title:e,description:t,control:n,nested:r,children:i,className:a,...o}){return(0,J.jsxs)(`div`,{className:L(`min-w-0 py-3`,r&&`pl-4`,a),...o,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-6 gap-y-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 basis-40`,children:[(0,J.jsx)(`div`,{className:`text-[13px] font-medium text-content`,children:e}),t&&(0,J.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-content-muted`,children:t})]}),n&&(0,J.jsx)(`div`,{className:`max-w-full shrink-0`,children:n})]}),i]})}function ei({className:e,...t}){return(0,J.jsx)(ar,{"data-slot":`radio-group`,className:L(`grid w-full gap-2`,e),...t})}function ti({className:e,...t}){return(0,J.jsx)(ur,{"data-slot":`radio-group-option`,className:L(`disabled:pointer-events-none disabled:opacity-50`,e),...t})}function ni(e,t){return t(e===`en-US`?`config:languageSettings.english`:`config:languageSettings.simplifiedChinese`)}function ri({notify:e}){let{language:t,setLanguage:n,t:r}=l(),i=(0,q.useId)(),a=(0,q.useId)(),o=r=>{r!==t&&(n(r),e(s(r===`en-US`?`config:languageSettings.displayLanguageChangedToEnglish`:`config:languageSettings.displayLanguageChangedToSimplifiedChinese`,r)))};return(0,J.jsxs)(`div`,{className:`flex flex-row flex-wrap items-center justify-between gap-x-6 gap-y-3 border-y border-stroke-soft py-3`,"data-config-card":`interface-language`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 basis-40`,children:[(0,J.jsx)(`h2`,{id:i,className:`text-sm font-medium text-content`,children:r(`config:languageSettings.displayLanguage`)}),(0,J.jsx)(`p`,{id:a,className:`mt-0.5 text-xs leading-relaxed text-content-muted`,children:r(`config:languageSettings.interfaceOnlyHint`)})]}),(0,J.jsxs)(Qe,{value:t,onValueChange:e=>{let t=c.find(t=>t.value===e);t&&o(t.value)},children:[(0,J.jsx)(Ye,{"aria-labelledby":i,"aria-describedby":a,className:`min-w-36 shrink-0`,children:(0,J.jsx)(Je,{})}),(0,J.jsx)(Xe,{align:`end`,children:c.map(e=>(0,J.jsx)(Ze,{value:e.value,children:ni(e.value,r)},e.value))})]})]})}function ii({role:e,label:t,value:n,onCommit:r}){let{t:i}=l(),a=(0,q.useId)(),[o,s]=(0,q.useState)(String(n)),c=(0,q.useRef)(o),u=(0,q.useRef)(n),d=e===`ui`?un:cn;(0,q.useEffect)(()=>{u.current=n,c.current=String(n),s(String(n))},[n]);let f=o!==String(n)&&ln(o,e)===null,p=()=>{let t=ln(c.current,e);t!==null&&t!==u.current&&(r(t),u.current=t)};return(0,J.jsxs)(`div`,{className:`flex max-w-full flex-col items-end gap-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(B,{type:`number`,min:d.min,max:d.max,step:1,value:o,"aria-label":t,"aria-invalid":f,"aria-describedby":f?a:void 0,className:`h-8 w-16 text-sm tabular-nums pointer-coarse:min-h-11 max-[650px]:min-h-11`,onChange:e=>{c.current=e.target.value,s(e.target.value)},onPointerUp:p,onBlur:p,onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Enter`?(e.preventDefault(),p()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),c.current=String(n),s(String(n))))}}),(0,J.jsx)(`span`,{className:`text-sm text-content-muted`,children:`px`})]}),f&&(0,J.jsx)(`p`,{id:a,role:`alert`,className:`max-w-56 text-xs text-destructive`,children:i(`config:interfaceSettings.invalidFontSize`,{min:d.min,max:d.max})})]})}function ai({label:e,options:t,value:n,onChange:r}){return(0,J.jsx)(ei,{value:n,onValueChange:e=>{let n=t.find(t=>t.value===e);n&&r(n.value)},className:`grid auto-cols-fr grid-flow-col gap-0.5 rounded-md border border-stroke bg-chrome p-[3px]`,"aria-label":e,children:t.map(e=>(0,J.jsx)(ti,{type:`button`,className:L(`min-h-7 rounded-sm border border-transparent px-2.5 text-sm transition-colors pointer-coarse:min-h-11 max-[650px]:min-h-11`,e.value===n?`border-key-border bg-key font-medium text-content shadow-key`:`text-content-secondary hover:text-content`),value:e.value,children:e.label},e.value))})}var oi={neutral:`var(--primary)`,blue:`#3d4bef`,teal:`#0f766e`,violet:`#6d4ad6`,coral:`#c93a48`,custom:`#3d4bef`};function si(e){let[t,n,r]=[1,3,5].map(t=>parseInt(e.slice(t,t+2),16)/255),i=Math.max(t,n,r),a=i-Math.min(t,n,r),o=0;return a&&(o=i===t?(n-r)/a%6:i===n?(r-t)/a+2:(t-n)/a+4),{hue:(o*60+360)%360,saturation:i?a/i:0,brightness:i}}function ci({hue:e,saturation:t,brightness:n}){let r=n*t,i=r*(1-Math.abs(e/60%2-1));return`#`+[[r,i,0],[i,r,0],[0,r,i],[0,i,r],[i,0,r],[r,0,i]][Math.floor(e/60)%6].map(e=>Math.round((e+n-r)*255).toString(16).padStart(2,`0`)).join(``)}function li({value:e,onCommit:t}){let{t:n}=l(),[r,i]=(0,q.useState)(e),a=(0,q.useRef)(e),[o,s]=(0,q.useState)(()=>si(e)),c=(0,q.useId)(),u=e=>{a.current=e,i(e)};(0,q.useEffect)(()=>{a.current=e,i(e),s(si(e))},[e]);let d=e=>{s(e),u(ci(e))},f=()=>{let n=Yt(a.current);n&&n!==Yt(e)&&t(n)},p=e=>{let t=e.currentTarget.getBoundingClientRect();d({...o,saturation:Math.min(1,Math.max(0,(e.clientX-t.left)/t.width)),brightness:1-Math.min(1,Math.max(0,(e.clientY-t.top)/t.height))})},m=!!r.trim()&&!Yt(r);return(0,J.jsxs)(qe,{onOpenChange:t=>{t||(f(),Yt(a.current)||(u(e),s(si(e))))},children:[(0,J.jsx)(Ge,{asChild:!0,children:(0,J.jsxs)(z,{variant:`outline`,className:`h-8 min-h-0 w-26 gap-1.5 px-2 text-xs tabular-nums pointer-coarse:h-11 max-[650px]:h-11`,"aria-label":n(`config:interfaceSettings.customAccentColor`),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 shrink-0 rounded-full border border-stroke-strong`,style:{backgroundColor:e}}),(0,J.jsx)(`span`,{className:`font-mono`,children:e})]})}),(0,J.jsxs)(Ke,{align:`end`,sideOffset:8,className:`w-auto rounded-xl p-3`,children:[(0,J.jsx)(`div`,{role:`slider`,tabIndex:0,"aria-label":n(`config:interfaceSettings.colorSpectrum`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(o.saturation*100),"aria-valuetext":r,"aria-describedby":c,className:`relative h-34 w-34 touch-none rounded-lg outline-none focus-visible:ring-2 focus-visible:ring-ring`,style:{background:`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), hsl(${o.hue} 100% 50%)`},onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),p(e)},onPointerMove:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&p(e)},onPointerUp:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&(p(e),e.currentTarget.releasePointerCapture(e.pointerId),f())},onPointerCancel:()=>{u(e),s(si(e))},onKeyDown:e=>{[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(e.key)&&(e.preventDefault(),d({...o,saturation:Math.min(1,Math.max(0,o.saturation+(e.key===`ArrowRight`?.01:e.key===`ArrowLeft`?-.01:0))),brightness:Math.min(1,Math.max(0,o.brightness+(e.key===`ArrowUp`?.01:e.key===`ArrowDown`?-.01:0)))}))},onKeyUp:e=>{e.key.startsWith(`Arrow`)&&f()},onBlur:f,children:(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-sm`,style:{left:`${o.saturation*100}%`,top:`${(1-o.brightness)*100}%`}})}),(0,J.jsx)(et,{min:0,max:359,step:1,value:[Math.round(o.hue)],"aria-label":n(`config:interfaceSettings.colorHue`),valueText:`${Math.round(o.hue)}°`,className:`h-7 w-34`,onValueChange:([e])=>d({...o,hue:e}),onValueCommit:()=>f()}),(0,J.jsx)(B,{type:`text`,value:r,spellCheck:!1,"aria-label":n(`config:interfaceSettings.customAccentHex`),"aria-invalid":m,"aria-describedby":c,className:`w-34 font-mono text-xs`,onChange:e=>{u(e.target.value);let t=Yt(e.target.value);t&&s(si(t))},onBlur:f,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f())}}),(0,J.jsx)(`p`,{id:c,className:`max-w-34 text-xs text-muted-foreground`,children:n(m?`config:interfaceSettings.invalidAccentColor`:`config:interfaceSettings.colorSpectrumHint`)})]})]})}function ui({notify:e,defaultAdvancedExpanded:t=!1,navigationKey:n}){let{t:r}=l(),{theme:i,density:a,accent:o,customAccent:s,uiFontSize:c,codeFontSize:u,radius:d,motion:f,setTheme:p,setDensity:m,setAccent:h,setCustomAccent:g,setUiFontSize:y,setCodeFontSize:b,setRadius:x,setMotion:S,resetAppearance:C}=Xt(),w=v(e=>e.pinned),T=v(e=>e.setPinned),[E,O]=(0,q.useState)(t),k=(0,q.useId)(),A=(0,q.useId)();(0,q.useEffect)(()=>{t&&O(!0)},[t,n]);let j=i!==en.theme||a!==en.density||o!==en.accent||s!==en.customAccent||c!==en.uiFontSize||u!==en.codeFontSize||d!==en.radius||f!==en.motion,M=t=>n=>{t(n),e(r(`config:interfaceSettings.preferencesUpdated`))},ee=[{value:`system`,label:r(`config:interfaceSettings.followSystem`),description:r(`config:interfaceSettings.followSystemDescription`),icon:Tn},{value:`light`,label:r(`config:interfaceSettings.light`),description:r(`config:interfaceSettings.lightDescription`),icon:Pn},{value:`dark`,label:r(`config:interfaceSettings.dark`),description:r(`config:interfaceSettings.darkDescription`),icon:En}],N=[{value:`comfortable`,label:r(`config:interfaceSettings.comfortable`),description:r(`config:interfaceSettings.comfortableDescription`),icon:In},{value:`compact`,label:r(`config:interfaceSettings.compact`),description:r(`config:interfaceSettings.compactDescription`),icon:Cn}],P=[{value:`system`,label:r(`config:interfaceSettings.motionSystem`),description:r(`config:interfaceSettings.motionSystemDescription`),icon:Tn},{value:`full`,label:r(`config:interfaceSettings.motionFull`),description:r(`config:interfaceSettings.motionFullDescription`),icon:ve},{value:`reduced`,label:r(`config:interfaceSettings.motionReduced`),description:r(`config:interfaceSettings.motionReducedDescription`),icon:_}],te=[{value:`neutral`,label:r(`config:interfaceSettings.accentNeutral`)},{value:`blue`,label:r(`config:interfaceSettings.accentBlue`)},{value:`teal`,label:r(`config:interfaceSettings.accentTeal`)},{value:`violet`,label:r(`config:interfaceSettings.accentViolet`)},{value:`coral`,label:r(`config:interfaceSettings.accentCoral`)},{value:`custom`,label:r(`config:interfaceSettings.accentCustom`)}],ne=[{value:`sharp`,label:r(`config:interfaceSettings.sharp`)},{value:`default`,label:r(`config:interfaceSettings.standard`)},{value:`soft`,label:r(`config:interfaceSettings.soft`)}];return(0,J.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,J.jsx)($r,{title:r(`config:interfaceSettings.visualStyle`),description:r(`config:interfaceSettings.appearanceDescription`),"data-config-card":`interface-appearance`,action:(0,J.jsxs)(z,{type:`button`,variant:`ghost`,size:`sm`,className:`pointer-coarse:h-11`,disabled:!j,onClick:()=>{C(),e(r(`config:interfaceSettings.defaultsRestored`))},children:[(0,J.jsx)(me,{size:14}),r(`config:interfaceSettings.restoreDefaults`)]}),children:(0,J.jsxs)(xr,{children:[(0,J.jsx)(Q,{title:r(`config:interfaceSettings.colorMode`),control:(0,J.jsx)(`div`,{role:`radiogroup`,"aria-label":r(`config:interfaceSettings.colorMode`),className:`grid w-68 max-w-full grid-cols-3 gap-4`,children:ee.map(e=>(0,J.jsxs)(`label`,{className:`group flex min-w-0 cursor-pointer flex-col items-center gap-2 text-xs text-content-muted`,children:[(0,J.jsx)(`input`,{className:`peer sr-only`,type:`radio`,name:A,value:e.value,checked:i===e.value,onChange:()=>M(p)(e.value)}),(0,J.jsxs)(`span`,{"aria-hidden":`true`,className:L(`relative block aspect-4/3 w-full overflow-hidden rounded-md border border-stroke bg-surface-sunken peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-focus`,i===e.value&&`border-star ring-2 ring-star`),children:[(0,J.jsxs)(`span`,{className:`absolute inset-2 rounded border border-(--preview-light-line) bg-(--preview-light-bg)`,children:[(0,J.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-1/4 border-r border-(--preview-light-line) bg-(--preview-light-side)`}),(0,J.jsx)(`span`,{className:`absolute top-3 right-1 h-0.5 w-1/2 rounded bg-(--preview-light-line)`}),(0,J.jsx)(`span`,{className:`absolute top-5 right-2 h-0.5 w-1/3 rounded bg-(--preview-light-line)`})]}),e.value!==`light`&&(0,J.jsxs)(`span`,{className:L(`absolute inset-2 rounded border border-(--preview-dark-line) bg-(--preview-dark-bg)`,e.value===`system`&&`left-1/2 rounded-l-none border-l-0`),children:[e.value===`dark`&&(0,J.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-1/4 border-r border-(--preview-dark-line) bg-(--preview-dark-side)`}),(0,J.jsx)(`span`,{className:`absolute top-3 right-1 h-0.5 w-1/2 rounded bg-(--preview-dark-line)`}),(0,J.jsx)(`span`,{className:`absolute top-5 right-2 h-0.5 w-1/3 rounded bg-(--preview-dark-line)`})]})]}),(0,J.jsx)(`span`,{className:L(i===e.value&&`font-medium text-content`),children:e.label})]},e.value))})}),(0,J.jsx)(Q,{title:r(`config:interfaceSettings.accentColor`),description:r(`config:interfaceSettings.accentDescription`),control:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,J.jsxs)(Qe,{value:o,onValueChange:e=>{let t=te.find(t=>t.value===e);t&&M(h)(t.value)},children:[(0,J.jsx)(Ye,{"aria-label":r(`config:interfaceSettings.accentColor`),className:`min-w-36`,children:(0,J.jsx)(Je,{})}),(0,J.jsx)(Xe,{align:`end`,children:te.map(e=>(0,J.jsxs)(Ze,{value:e.value,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 rounded-full border border-stroke-strong`,style:{backgroundColor:e.value===`custom`?s:oi[e.value]}}),e.label]},e.value))})]}),o===`custom`&&(0,J.jsx)(li,{value:Yt(s)||en.customAccent,onCommit:M(g)})]})})]})}),(0,J.jsxs)(Jt,{open:E,onOpenChange:O,children:[(0,J.jsx)(qt,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,"aria-controls":k,"aria-expanded":E,className:`flex min-h-9 w-full items-center gap-2 rounded-sm text-left text-[15px] leading-6 font-medium text-content max-[650px]:min-h-11`,children:[(0,J.jsx)(D,{size:16,"aria-hidden":`true`,className:L(`text-content-muted transition-transform`,!E&&`-rotate-90`)}),r(`config:interfaceSettings.advanced`)]})}),(0,J.jsx)(Kt,{id:k,children:(0,J.jsxs)(xr,{className:`mt-3`,children:[(0,J.jsxs)(`div`,{className:`divide-y divide-stroke-soft`,"data-config-card":`interface-style`,children:[(0,J.jsx)(Q,{title:r(`config:interfaceSettings.uiFontSize`),description:r(`config:interfaceSettings.numericFontHint`),control:(0,J.jsx)(ii,{role:`ui`,label:r(`config:interfaceSettings.uiFontSize`),value:c,onCommit:M(y)})}),(0,J.jsx)(Q,{title:r(`config:interfaceSettings.codeFontSize`),control:(0,J.jsx)(ii,{role:`code`,label:r(`config:interfaceSettings.codeFontSize`),value:u,onCommit:M(b)})}),(0,J.jsx)(Q,{title:r(`config:interfaceSettings.cornerStyle`),control:(0,J.jsx)(ai,{label:r(`config:interfaceSettings.cornerStyle`),options:ne,value:d,onChange:M(x)})})]}),(0,J.jsxs)(`div`,{className:`divide-y divide-stroke-soft`,"data-config-card":`interface-motion`,children:[(0,J.jsx)(Q,{title:r(`config:interfaceSettings.interfaceDensity`),control:(0,J.jsx)(ai,{label:r(`config:interfaceSettings.interfaceDensity`),options:N,value:a,onChange:M(m)})}),(0,J.jsx)(Q,{title:r(`config:interfaceSettings.pinInspector`),description:r(`config:interfaceSettings.pinInspectorDescription`),control:(0,J.jsx)(tt,{checked:w,onCheckedChange:M(T),"aria-label":r(`config:interfaceSettings.pinInspector`),"data-setting":`pin-inspector`})}),(0,J.jsx)(Q,{title:r(`config:interfaceSettings.motion`),control:(0,J.jsx)(ai,{label:r(`config:interfaceSettings.motion`),options:P,value:f,onChange:M(S)})}),(0,J.jsx)(Q,{title:r(`config:interfaceSettings.automaticByTime`),description:r(`config:interfaceSettings.automaticByTimeDescription`),control:(0,J.jsx)(tt,{checked:i===`scheduled`,onCheckedChange:e=>M(p)(e?`scheduled`:`system`),"aria-label":r(`config:interfaceSettings.automaticByTime`)})})]})]})})]}),(0,J.jsx)(ri,{notify:e})]})}function di({requestConfirm:e}){let{t}=l(),n=ct(e=>e.bindings),r=ct(e=>e.boardBindings),i=ct(e=>e.setBinding),a=ct(e=>e.setBoardBinding),o=ct(e=>e.resetBindings),[s,c]=(0,q.useState)(null),[u,d]=(0,q.useState)(null),[f,p]=(0,q.useState)(!1),m=dn(),h=m.actions,g=m.boardActions,_=(e,n)=>{p(!1);let i=pt(r,e,n);if(i){d({action:e,message:t(`config:shortcuts.conflict`,{action:g[i]})});return}try{a(e,n),c(null),d(null),p(!0)}catch{d({action:e,message:t(`config:shortcuts.saveFailed`)})}},v=(e,r)=>{p(!1);let a=dt(n,e,r);if(a){d({action:e,message:t(`config:shortcuts.conflict`,{action:h[a]})});return}try{st({...n,[e]:r})}catch{d({action:e,message:t(`config:shortcuts.invalid`)});return}try{i(e,r),c(null),d(null),p(!0)}catch{d({action:e,message:t(`config:shortcuts.saveFailed`)})}},y=(e,n)=>{if(s!==n)return;if(e.key===`Tab`){c(null);return}let r=ft.includes(n),i=r?ht(e.nativeEvent):mt(e.nativeEvent);if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){c(null),d(null);return}i&&r?_(n,i):i?v(n,i):!e.nativeEvent.isComposing&&e.keyCode!==229&&!e.repeat&&![`Control`,`Meta`,`Alt`,`Shift`,`AltGraph`,`Dead`,`Process`].includes(e.key)&&d({action:n,message:t(`config:shortcuts.invalid`)})},b=async()=>{if(c(null),await e({title:t(`config:shortcuts.resetAll`),message:t(`config:shortcuts.resetConfirm`),confirmLabel:t(`config:shortcuts.resetAll`)}))try{o(),d(null),p(!0)}catch{d({action:null,message:t(`config:shortcuts.saveFailed`)})}},x=ut.some(e=>n[e]!==lt[e])||ft.some(e=>r[e]!==_t[e]),S=e=>{let i=ft.includes(e),a=i?g[e]:h[e],o=i?r[e]:n[e],l=i?_t[e]:lt[e],f=t=>i?_(e,t):v(e,t);return(0,J.jsxs)(`div`,{className:`py-2.5`,"data-shortcut-action":e,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-5 gap-y-2`,children:[(0,J.jsx)(`label`,{htmlFor:`shortcut-${e}`,className:`min-w-0 text-sm font-medium text-content`,children:a}),(0,J.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1 max-[650px]:w-full`,children:[(0,J.jsx)(z,{id:`shortcut-${e}`,"data-shortcut-recorder":!0,variant:`outline`,className:L(`h-8 w-44 min-w-0 justify-center gap-2 border-input bg-panel px-2.5 text-xs font-normal shadow-none hover:bg-surface-subtle pointer-coarse:h-11 max-[650px]:h-11 max-[650px]:flex-1`,s===e&&`border-focus text-accent-fg ring-3 ring-focus-ring hover:bg-panel`),"aria-label":t(`config:shortcuts.edit`,{action:a}),"aria-pressed":s===e,"aria-describedby":u?.action===e?`shortcut-error-${e}`:void 0,onClick:()=>{c(e),d(null),p(!1)},onBlur:()=>c(t=>t===e?null:t),onKeyDown:t=>y(t,e),children:s===e?(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:t(`config:shortcuts.recording`)}):gt(o)?(0,J.jsx)(rt,{className:`min-w-0 flex-wrap justify-center`,children:gt(o).split(` + `).map((e,t)=>(0,J.jsx)(it,{className:`text-content-secondary`,children:e},t))}):(0,J.jsx)(`span`,{className:`text-content-muted`,children:t(`config:shortcuts.disabled`)})}),(0,J.jsxs)(We,{children:[(0,J.jsx)(He,{asChild:!0,children:(0,J.jsx)(z,{variant:`ghost`,size:`icon`,className:`pointer-coarse:size-11 max-[650px]:size-11`,title:t(`config:shortcuts.options`,{action:a}),"aria-label":t(`config:shortcuts.options`,{action:a}),children:(0,J.jsx)(N,{className:`size-4`})})}),(0,J.jsxs)(Ue,{align:`end`,className:`w-40`,onCloseAutoFocus:e=>{document.activeElement?.hasAttribute(`data-shortcut-recorder`)&&e.preventDefault()},children:[(0,J.jsxs)(Be,{disabled:o===null,onSelect:()=>f(null),children:[(0,J.jsx)(Ce,{className:`size-4`}),t(`config:shortcuts.disableKey`)]}),(0,J.jsxs)(Be,{disabled:o===l,onSelect:()=>f(l),children:[(0,J.jsx)(me,{className:`size-4`}),t(`config:shortcuts.resetAll`)]})]})]})]})]}),u?.action===e&&(0,J.jsx)(`p`,{id:`shortcut-error-${e}`,role:`alert`,className:`mt-2 text-xs text-danger`,children:u.message})]},e)},C=e=>e.kind===`fixed`?(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-5 gap-y-2 py-2.5`,"data-shortcut-fixed":e.id,children:[(0,J.jsxs)(`span`,{className:`min-w-0 text-sm text-content-secondary`,children:[m.label(e),(0,J.jsx)(`span`,{className:`ml-1.5 text-xs text-content-muted`,children:t(`board:shortcuts.fixed`)})]}),(0,J.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1 max-[650px]:w-full`,children:[(0,J.jsx)(mn,{keys:e.keys,className:`h-8 w-44 justify-center px-2.5 max-[650px]:flex-1`}),(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-7 flex-none pointer-coarse:size-11 max-[650px]:size-11`})]})]},pn(e)):S(e.action);return(0,J.jsxs)(`section`,{className:`w-full min-w-0`,"data-config-card":`shortcuts-bindings`,children:[(0,J.jsx)(`div`,{className:`flex flex-col gap-5`,children:fn.map((e,n)=>(0,J.jsxs)(`section`,{"aria-labelledby":`shortcut-group-${e.id}`,"data-shortcut-group":e.id,children:[(0,J.jsxs)(`div`,{className:`flex min-h-7 items-center justify-between gap-3`,children:[(0,J.jsx)(`h3`,{id:`shortcut-group-${e.id}`,className:`text-[13px] leading-6 font-semibold text-content`,children:m.groups[e.id].title}),n===0&&(0,J.jsxs)(z,{variant:`ghost`,size:`sm`,"data-shortcuts-reset-all":!0,className:`-mr-2 text-content-secondary max-[650px]:h-11 pointer-coarse:h-11`,disabled:!x,onClick:()=>void b(),children:[(0,J.jsx)(me,{className:`size-3.5`,"aria-hidden":`true`}),t(`config:shortcuts.resetAll`)]})]}),(0,J.jsx)(`p`,{className:`mb-2 text-xs text-content-muted`,children:m.groups[e.id].hint}),(0,J.jsx)(xr,{children:e.entries.map(C)})]},e.id))}),(0,J.jsx)(`div`,{className:`mt-3 min-h-5 text-xs text-content-muted`,role:`status`,"aria-live":`polite`,children:u?.action===null?(0,J.jsx)(`span`,{className:`text-destructive`,children:u.message}):t(f?`config:shortcuts.saved`:`config:shortcuts.deviceScope`)})]})}function fi(e,t){let n=(0,q.useRef)(t);n.current=t,(0,q.useEffect)(()=>{if(e)return e(()=>n.current?.())},[e])}o.addResourceBundle(`zh-CN`,`providers`,{"modelEditor.edit":`编辑模型`,"modelEditor.add":`添加模型`,"modelEditor.description":`能力与思考强度`,"modelEditor.id":`模型 ID`,"modelEditor.capabilities":`模型能力`,"modelEditor.chat":`对话`,"modelEditor.image":`图像生成`,"modelEditor.video":`视频生成`,"modelEditor.capabilitiesHint":`可单选或多选。仅选图像生成时,复用此连接的密钥,不会出现在对话模型中。`,"modelEditor.chatCapabilities":`对话能力`,"modelEditor.vision":`图片理解`,"modelEditor.reasoning":`深度思考`,"modelEditor.contextWindow":`上下文窗口(Token)`,"modelEditor.maxTokens":`最大输出(Token)`,"modelEditor.editNamed":`编辑模型 {name}`,"modelEditor.optionsNamed":`模型能力:{name}`,"modelEditor.delete":`删除模型`,"modelEditor.deleteNamed":`删除模型 {name}`,"modelEditor.deleteConfirmation":`删除“{name}”?供应商连接和密钥会保留。若它是默认模型,将选用其他可用模型,没有可用模型时清空默认值;已有会话的模型不会自动替换。之后可以重新添加此模型。`,"modelEditor.deleted":`模型已删除`}),o.addResourceBundle(`en-US`,`providers`,{"modelEditor.edit":`Edit model`,"modelEditor.add":`Add model`,"modelEditor.description":`Capabilities and reasoning levels`,"modelEditor.id":`Model ID`,"modelEditor.capabilities":`Model capabilities`,"modelEditor.chat":`Chat`,"modelEditor.image":`Image generation`,"modelEditor.video":`Video generation`,"modelEditor.capabilitiesHint":`Choose one or more. Image-only models reuse this connection’s key and stay out of the chat model picker.`,"modelEditor.chatCapabilities":`Chat capabilities`,"modelEditor.vision":`Image understanding`,"modelEditor.reasoning":`Reasoning`,"modelEditor.contextWindow":`Context window (tokens)`,"modelEditor.maxTokens":`Maximum output (tokens)`,"modelEditor.editNamed":`Edit model {name}`,"modelEditor.optionsNamed":`Model capabilities: {name}`,"modelEditor.delete":`Delete model`,"modelEditor.deleteNamed":`Delete model {name}`,"modelEditor.deleteConfirmation":`Delete “{name}”? The provider connection and credentials will remain. If this is the default model, another available model will be selected, or the default will be cleared if none is available. Existing conversations will keep their model bindings. You can add this model again later.`,"modelEditor.deleted":`Model deleted`});function pi(e){let t=(0,q.useContext)(an);return(0,q.useLayoutEffect)(()=>{t?.update(e)}),(0,q.useLayoutEffect)(()=>()=>t?.remove(e.id),[t,e.id]),{requestClose:(0,q.useCallback)(n=>{t?t.requestClose(e.id,n):n()},[t,e.id])}}var mi=[[`openai-responses`,`OpenAI Responses`],[`openai-completions`,`OpenAI Chat Completions`],[`anthropic-messages`,`Anthropic Messages`],[`google-generative-ai`,`Google Generative AI`]],hi={"openai-codex-responses":`OpenAI Codex Responses`,"azure-openai-responses":`Azure OpenAI Responses`,"mistral-conversations":`Mistral Conversations`,"bedrock-converse-stream":`Amazon Bedrock Converse`,"google-vertex":`Google Vertex AI`,"pi-messages":`Pi Messages`};function gi(e){return!e||mi.some(([t])=>t===e)?mi:[...mi,[e,hi[e]||e]]}var _i={openai:w,"openai-codex":w,anthropic:T,google:ve,deepseek:j,xai:le,openrouter:ce,"kimi-coding":ve,"zai-coding-cn":T},vi={saveFallbackModels(e){return f(`/api/config/fallback-models`,{method:`PUT`,body:JSON.stringify({models:e})})},saveAuxiliaryModel(e){return f(`/api/config/auxiliary-model`,{method:`PUT`,body:JSON.stringify({model:e})})},deleteModel(e,t){return f(`/api/providers/`+encodeURIComponent(e)+`/models`,{method:`DELETE`,body:JSON.stringify({modelId:t})})},saveModel(e,t,n=!1){return f(`/api/providers/`+encodeURIComponent(e)+`/models`+(n?``:`/options`),{method:n?`POST`:`PUT`,body:JSON.stringify(n?{...t,id:t.modelId,kind:t.capabilities[0]}:t)})},saveConnection(e,t){return f(`/api/providers/`+encodeURIComponent(e)+`/connection`,{method:`PUT`,body:JSON.stringify(t)})},importLocal(){return f(`/api/providers/import-local`,{method:`POST`,body:`{}`})}};function yi(e,t){return t.name!==e.name||t.api!==e.api||t.baseUrl!==(e.baseUrl||``)||!!t.apiKey}function bi({provider:e,onSave:t,draft:n,onDraftChange:r,onSavingChange:i,children:a}){let{t:o}=l(),[s,c]=(0,q.useState)(!1),[u,d]=(0,q.useState)(``),f=(0,q.useId)(),p=yi(e,n),m=async a=>{if(a.preventDefault(),!s){c(!0),i(!0),d(``);try{t(await vi.saveConnection(e.id,{...n,apiKey:n.apiKey.trim()||void 0})),r(void 0)}catch(e){d(e instanceof Error?e.message:String(e))}finally{c(!1),i(!1)}}};return(0,J.jsxs)(`form`,{onSubmit:e=>void m(e),"data-provider-connection-editor":!0,children:[(0,J.jsxs)(`fieldset`,{disabled:s,className:`min-w-0 divide-y divide-stroke-soft`,children:[(0,J.jsx)(Sr,{label:o(`config:configPage.displayName`),htmlFor:`${f}-name`,children:(0,J.jsx)(B,{id:`${f}-name`,required:!0,value:n.name,onChange:e=>r({...n,name:e.target.value})})}),(0,J.jsx)(Sr,{label:o(`config:configPage.apiKey`),htmlFor:`${f}-key`,children:(0,J.jsx)(B,{id:`${f}-key`,type:`password`,autoComplete:`new-password`,className:`font-mono placeholder:font-sans`,value:n.apiKey,placeholder:e.configured?o(`config:configPage.leaveBlankToKeepExistingKey`):o(`config:configPage.enterTheProviderAPIKey`),onChange:e=>r({...n,apiKey:e.target.value})})}),(0,J.jsx)(Sr,{label:o(`config:configPage.apiProtocol`),labelId:`${f}-api-label`,help:(0,J.jsx)(`span`,{className:`font-mono`,children:n.api}),children:(0,J.jsx)(K,{"aria-labelledby":`${f}-api-label`,value:n.api,onChange:e=>r({...n,api:e.target.value}),children:gi(n.api).map(([e,t])=>(0,J.jsx)(`option`,{value:e,children:t},e))})}),(0,J.jsx)(Sr,{label:`Base URL`,htmlFor:`${f}-url`,children:(0,J.jsx)(B,{id:`${f}-url`,required:!0,type:`url`,className:`font-mono`,value:n.baseUrl,onChange:e=>r({...n,baseUrl:e.target.value})})})]}),u&&(0,J.jsx)(W,{className:`mt-2 mb-3`,children:u}),a,(0,J.jsxs)(`div`,{className:L(`flex flex-wrap items-center justify-end gap-2 border-t border-stroke-soft py-3`,p&&`sticky bottom-0 z-[1] bg-background`),children:[p&&(0,J.jsx)(`span`,{role:`status`,className:`mr-auto text-xs text-content-muted`,children:o(`config:configPage.unsavedChanges`)}),(0,J.jsx)(z,{type:`submit`,className:`max-[650px]:h-11`,disabled:!p,loading:s,children:o(s?`config:configPage.saving`:`config:configPage.saveChanges`)})]})]})}var xi=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function Si({label:e,checked:t,disabled:n,onChange:r}){return(0,J.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t,disabled:n,onClick:r,className:L(`inline-flex h-8 items-center gap-2 rounded-sm border px-2.5 text-sm transition-colors disabled:opacity-50 pointer-coarse:h-11`,t?`border-star-border bg-star-soft text-star-strong`:`border-stroke text-content-secondary hover:bg-surface-hover hover:text-content`),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:L(`grid size-3.5 place-items-center rounded-[3px] border border-control`,t&&`border-star bg-star text-on-accent`),children:t&&(0,J.jsx)(E,{size:11})}),e]})}function Ci({provider:e,model:t,onSave:n,onClose:r}){let{t:i}=l(),[a]=(0,q.useState)(()=>t?.contextWindow||2e5),[o,s]=(0,q.useState)(()=>({modelId:t?.id||``,name:t?.name||``,capabilities:t?.capabilities||[t?.kind===`image`?`image`:t?.kind===`video`?`video`:`chat`],input:t?.input||[`text`],reasoning:t?.reasoning??!0})),[c,u]=(0,q.useState)(()=>({contextWindow:String(a),maxTokens:String(t?.maxTokens||8192)})),[d,f]=(0,q.useState)(t?.thinkingLevels||[`off`,`low`,`medium`,`high`]),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(``),y=o.capabilities.includes(`chat`),b=async i=>{if(i.preventDefault(),!h){g(!0),v(``);try{n(await vi.saveModel(e.id,{...o,modelId:o.modelId.trim(),thinkingLevels:p||!t?d:void 0,contextWindow:Number(c.contextWindow)===a?void 0:Number(c.contextWindow),maxTokens:Number(c.maxTokens)},!t)),r()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}};return(0,J.jsx)(Tt,{open:!0,onOpenChange:e=>{!e&&!h&&r()},children:(0,J.jsxs)(xt,{className:`sm:max-w-[540px] p-5`,showCloseButton:!h,onEscapeKeyDown:e=>{h&&e.preventDefault()},onInteractOutside:e=>e.preventDefault(),children:[(0,J.jsxs)(wt,{children:[(0,J.jsx)(St,{children:i(t?`providers:modelEditor.edit`:`providers:modelEditor.add`)}),(0,J.jsxs)(bt,{children:[e.name,` · `,i(`providers:modelEditor.description`)]})]}),(0,J.jsxs)(`form`,{onSubmit:e=>void b(e),className:`space-y-5`,children:[(0,J.jsxs)(`fieldset`,{disabled:h,className:`space-y-5`,children:[(0,J.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(`providers:modelEditor.id`),(0,J.jsx)(B,{required:!0,disabled:!!t,value:o.modelId,onChange:e=>s({...o,modelId:e.target.value})})]}),(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(`config:configPage.modelName`),(0,J.jsx)(B,{value:o.name,onChange:e=>s({...o,name:e.target.value})})]})]}),(0,J.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,J.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`providers:modelEditor.capabilities`)}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`chat`,`image`,`video`].map(e=>(0,J.jsx)(Si,{label:i(e===`chat`?`providers:modelEditor.chat`:e===`image`?`providers:modelEditor.image`:`providers:modelEditor.video`),checked:o.capabilities.includes(e),onChange:()=>s({...o,capabilities:o.capabilities.includes(e)?o.capabilities.filter(t=>t!==e):[...o.capabilities,e]})},e))}),(0,J.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:i(`providers:modelEditor.capabilitiesHint`)})]}),y&&(0,J.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,J.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`providers:modelEditor.chatCapabilities`)}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(Si,{label:i(`providers:modelEditor.vision`),checked:o.input.includes(`image`),onChange:()=>s({...o,input:o.input.includes(`image`)?[`text`]:[`text`,`image`]})}),(0,J.jsx)(Si,{label:i(`providers:modelEditor.reasoning`),checked:o.reasoning,onChange:()=>s({...o,reasoning:!o.reasoning})})]})]}),y&&o.reasoning&&(0,J.jsxs)(`fieldset`,{children:[(0,J.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`config:configPage.modelThinkingLevels`)}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:xi.map(e=>(0,J.jsx)(Si,{label:e,checked:e===`off`||d.includes(e),disabled:e===`off`,onChange:()=>{m(!0),f(d.includes(e)?d.filter(t=>t!==e):[...d,e])}},e))})]}),y&&(0,J.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[`contextWindow`,`maxTokens`].map(e=>(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(e===`contextWindow`?`providers:modelEditor.contextWindow`:`providers:modelEditor.maxTokens`),(0,J.jsx)(B,{required:!0,type:`number`,min:1,max:1e8,step:1,value:c[e],onChange:t=>u({...c,[e]:t.target.value})})]},e))})]}),_&&(0,J.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:_}),(0,J.jsxs)(Ct,{children:[(0,J.jsx)(z,{type:`button`,variant:`ghost`,disabled:h,onClick:r,children:i(`config:configPage.cancel`)}),(0,J.jsxs)(z,{type:`submit`,disabled:h||!o.capabilities.length||!o.modelId.trim(),children:[h&&(0,J.jsx)(F,{className:`animate-spin`,size:14}),` `,i(h?`config:configPage.saving`:`config:configPage.saveChanges`)]})]})]})]})})}function wi(e,t){let n=e.providers.filter(e=>e.configured||e.custom),r=e.defaultProvider||e.provider;return{providers:n,selected:n.find(e=>e.id===t)??n.find(e=>e.id===r)??n[0],defaultId:r}}function Ti(e){let t=e.trim().split(/[\s_\-/.]+/).filter(Boolean);if(t.length>1)return(Array.from(t[0])[0]+Array.from(t[1])[0]).toUpperCase();let n=Array.from(t[0]||`?`);return n[0].toUpperCase()+(n[1]||``)}function Ei(e){return e?e>=1e6?`${Number((e/1e6).toFixed(2))}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e):`—`}function Di(e){return gi(e).find(([t])=>t===e)?.[1]||e}var Oi=`grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 @min-[560px]/card:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)_64px_76px_minmax(88px,auto)]`;function ki(e){let{t}=l(),n=(0,q.useId)(),{providers:r,defaultId:i}=wi(e.config,e.selectedProviderId),a=r.find(t=>t.id===e.selectedProviderId),[o,s]=(0,q.useState)({}),[c,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(null),p=!!(c||e.settingDefault||e.settingModel||e.toggling||e.deletingModel);pi({id:`provider-drafts-${n}`,dirty:r.some(e=>!!(o[e.id]&&yi(e,o[e.id]))),saving:p,discard:()=>s({})});let m={chat:t(`providers:modelEditor.chat`),image:t(`providers:modelEditor.image`),video:t(`providers:modelEditor.video`),reasoning:t(`providers:modelEditor.reasoning`)},h=e=>{let t=e.capabilities||[e.kind];return[[`chat`,oe,t.includes(`chat`)],[`image`,ie,t.includes(`image`)],[`video`,I,t.includes(`video`)],[`reasoning`,T,!!e.reasoning&&t.includes(`chat`)]].filter(([,,e])=>e).map(([e,t])=>(0,J.jsxs)(`span`,{title:m[e],className:`inline-flex`,children:[(0,J.jsx)(t,{size:13,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`sr-only`,children:m[e]})]},e))},g=e=>e.configured?t(`config:providerWorkbench.keyConfigured`):e.id===`openai-codex`?t(`config:configPage.codexCLILoginRequired`):t(`config:configPage.apiKeyRequired`),_=e=>e.configured?e.enabled?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,J.jsx)(E,{className:`size-3.5`,"aria-hidden":`true`}),t(`config:providerWorkbench.connected`)]}):t(`config:configPage.disabled2`):t(`config:providerWorkbench.notConnected`),v=n=>(0,J.jsxs)(`div`,{className:`@container/card min-w-0`,"data-provider-detail":n.id,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 border-t border-stroke-soft py-2`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-content-muted`,children:n.id}),(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-sm text-content-secondary`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:t(`config:configPage.enabled`)}),(0,J.jsx)(br,{value:n.configured&&n.enabled,disabled:!n.configured||p,onChange:()=>void e.onToggle(n,!n.enabled),ariaLabel:t(`config:configPage.providerEnabled`,{name:n.name})})]}),(0,J.jsxs)(We,{children:[(0,J.jsx)(He,{asChild:!0,children:(0,J.jsx)(z,{variant:`ghost`,size:`icon-sm`,className:`pointer-coarse:size-11 max-[650px]:size-11`,"aria-label":t(`config:providerWorkbench.actions`),children:(0,J.jsx)(N,{size:16})})}),(0,J.jsxs)(Ue,{align:`end`,children:[(0,J.jsxs)(Be,{disabled:n.id===i||!n.configured||!n.enabled||!n.defaultModel||p,onSelect:()=>void e.onSetDefault(n),children:[(0,J.jsx)(Nn,{size:14}),t(`config:configPage.setAsDefaultProvider`)]}),(0,J.jsxs)(Be,{disabled:p,onSelect:()=>e.onClone(n),children:[(0,J.jsx)(M,{size:14}),t(`config:configPage.cloneProvider`)]}),n.custom&&(0,J.jsxs)(Be,{className:`text-destructive`,disabled:p,onSelect:()=>void e.onDelete(n),children:[(0,J.jsx)(be,{size:14}),t(`config:configPage.deleteProvider`)]})]})]})]}),(0,J.jsxs)(bi,{provider:n,draft:o[n.id]??{name:n.name,api:n.api,baseUrl:n.baseUrl||``,apiKey:``},onDraftChange:e=>s(t=>({...t,[n.id]:e})),onSavingChange:u,onSave:e.onSave,children:[(0,J.jsxs)(`div`,{className:`mt-2 flex min-h-10 items-center gap-2 border-t border-stroke-soft pt-2`,children:[(0,J.jsxs)(`h3`,{className:`text-[13px] font-medium text-content-muted`,children:[t(`config:providerWorkbench.models`),(0,J.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,n.models.length]})]}),(0,J.jsxs)(z,{type:`button`,variant:`secondary`,size:`sm`,className:`ml-auto pointer-coarse:h-11 max-[650px]:h-11`,disabled:p,onClick:()=>f({provider:n}),children:[(0,J.jsx)(de,{size:14}),t(`providers:modelEditor.add`)]})]}),n.models.length>0&&(0,J.jsxs)(`div`,{className:L(Oi,`hidden h-8 text-xs font-medium text-content-muted @min-[560px]/card:grid`),children:[(0,J.jsx)(`span`,{children:t(`providers:modelEditor.id`)}),(0,J.jsx)(`span`,{children:t(`config:configPage.displayName`)}),(0,J.jsx)(`span`,{className:`text-right`,children:t(`config:providerWorkbench.contextColumn`)}),(0,J.jsx)(`span`,{children:t(`providers:modelEditor.capabilities`)}),(0,J.jsx)(`span`,{"aria-hidden":`true`})]}),n.models.map(r=>{let i=n.defaultModel===r.id;return(0,J.jsxs)(`div`,{"data-provider-model":r.id,className:L(Oi,`min-h-11.5 border-t border-stroke-soft py-px text-sm text-content-secondary`),children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>f({provider:n,model:r}),disabled:p,className:`flex min-h-11 min-w-0 flex-col justify-center rounded-xs py-1 text-left`,"aria-label":t(`providers:modelEditor.editNamed`,{name:r.name||r.id}),children:[(0,J.jsx)(`span`,{className:`block truncate font-mono text-[12.5px] text-content`,children:r.id}),(0,J.jsxs)(`span`,{className:`mt-0.5 flex min-w-0 items-center gap-2 text-xs text-content-muted @min-[560px]/card:hidden`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:r.name||r.id}),(0,J.jsx)(`span`,{className:`tabular-nums`,children:Ei(r.contextWindow)}),h(r)]})]}),(0,J.jsx)(`span`,{className:`hidden min-w-0 truncate text-content @min-[560px]/card:block`,children:r.name||r.id}),(0,J.jsx)(`span`,{className:`hidden text-right tabular-nums @min-[560px]/card:block`,children:Ei(r.contextWindow)}),(0,J.jsx)(`span`,{className:`hidden items-center gap-2 text-content-muted @min-[560px]/card:flex`,children:h(r)}),(0,J.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[r.kind===`chat`&&(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-sm`,className:L(`pointer-coarse:size-11 max-[650px]:size-11`,i&&`text-star disabled:opacity-100 aria-disabled:opacity-100`),"aria-label":t(`config:configPage.providerDefaultModel`)+`: `+r.id,title:t(`config:configPage.providerDefaultModel`),"aria-pressed":i,disabled:p||!n.configured||i,onClick:()=>void e.onSetDefaultModel(n,r.id),children:(0,J.jsx)(Nn,{size:15,className:L(i&&`fill-current`)})}),(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`pointer-coarse:size-11 max-[650px]:size-11`,"aria-label":t(`providers:modelEditor.optionsNamed`,{name:r.id}),disabled:p,onClick:()=>f({provider:n,model:r}),children:(0,J.jsx)(jn,{size:14})}),(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`hover:bg-danger-soft hover:text-danger pointer-coarse:size-11 max-[650px]:size-11`,disabled:p,"aria-label":t(`providers:modelEditor.deleteNamed`,{name:r.name||r.id}),title:t(`providers:modelEditor.delete`),onClick:()=>void e.onDeleteModel(n,r),children:(0,J.jsx)(be,{size:14})})]})]},r.id)})]},n.id)]});return(0,J.jsxs)(U,{"data-config-card":`models-connections`,"data-model-provider-list":!0,title:t(`config:providerWorkbench.providers`),count:r.length,meta:e.meta,description:t(`config:providerWorkbench.providersHint`),children:[r.length>0?(0,J.jsx)(H,{children:r.map(n=>{let r=n.id===i,o=a?.id===n.id;return(0,J.jsx)(V,{"data-provider-row":n.id,icon:(0,J.jsx)(`span`,{className:`text-[13px] font-semibold text-content-secondary`,children:Ti(n.name)}),name:n.name,description:[g(n),t(`config:configPage.countModels`,{count:n.models.length}),Di(n.api)].join(` · `),status:(0,J.jsxs)(J.Fragment,{children:[r&&(0,J.jsxs)(`span`,{"data-provider-default":!0,className:`text-content-secondary`,children:[t(`config:providerWorkbench.default`),` ·`]}),_(n)]}),expanded:o,onExpandedChange:t=>e.onSelectProvider(t?n.id:``),toggleLabel:t(`config:providerWorkbench.toggleProvider`,{name:n.name}),detail:o?v(n):null},n.id)})}):(0,J.jsxs)(`div`,{className:`grid min-h-48 place-content-center justify-items-center gap-2 border-y border-stroke px-6 py-8 text-center`,children:[(0,J.jsx)(kt,{size:40,className:`mb-1`}),(0,J.jsx)(`p`,{className:`text-sm font-medium text-content`,children:t(`config:providerWorkbench.noConnections`)}),(0,J.jsx)(`p`,{className:`max-w-sm text-xs text-content-muted`,children:t(`config:providerWorkbench.addConnectionHint`)})]}),e.onAddConnection&&(0,J.jsxs)(`button`,{type:`button`,"data-add-provider":!0,disabled:p,onClick:e.onAddConnection,className:`flex min-h-[52px] w-full min-w-0 items-center gap-2.5 text-left text-sm text-content-secondary transition-colors duration-(--d-fast) hover:text-content focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus disabled:opacity-50`,children:[(0,J.jsx)(de,{size:16,"aria-hidden":`true`,className:`flex-none text-content-muted`}),(0,J.jsx)(`span`,{className:`flex-none`,children:t(`config:providerWorkbench.addProvider`)}),(0,J.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:t(`config:providerWorkbench.addProviderHint`)})]}),d&&(0,J.jsx)(Ci,{provider:d.provider,model:d.model,onSave:e.onSave,onClose:()=>f(null)})]})}function Ai(){let e=globalThis.crypto.getRandomValues(new Uint32Array(4));return`custom-${Array.from(e,e=>e.toString(16).padStart(8,`0`)).join(``)}`}function ji({value:e,onChange:t,configured:n=!1,cloning:r=!1}){let{t:i}=l();return(0,J.jsxs)(G,{variant:`control`,children:[i(`config:configPage.apiKey`),(0,J.jsx)(B,{type:`password`,autoComplete:`new-password`,value:e,onChange:e=>t(e.target.value),placeholder:i(r?`config:configPage.leaveBlankToCopySourceKey`:n?`config:configPage.leaveBlankToKeepExistingKey`:`config:configPage.enterTheProviderAPIKey`)})]})}function Mi({ids:e,onChange:t,placeholder:n,primaryId:r=``}){let{t:i}=l(),[a,o]=(0,q.useState)(``),s=()=>{let n=a.trim();!n||n===r.trim()||e.includes(n)||(t([...e,n]),o(``))};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(G,{variant:`control`,children:[i(`config:configPage.manualModelIds`),(0,J.jsxs)(`div`,{className:`flex items-stretch gap-1.5`,children:[(0,J.jsx)(B,{"aria-label":i(`config:configPage.manualModelIds`),value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),s())},placeholder:n}),(0,J.jsx)(z,{type:`button`,size:`icon`,variant:`secondary`,className:`h-auto w-8.5 flex-none pointer-coarse:w-11`,"aria-label":i(`config:configPage.manualModelIds`),disabled:!a.trim(),onClick:s,children:(0,J.jsx)(de,{size:14})})]})]}),e.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col overflow-hidden rounded-md border border-stroke`,children:e.map(n=>(0,J.jsxs)(`div`,{className:`flex min-h-9 min-w-0 items-center gap-2 border-b border-stroke-soft py-1 pr-1 pl-2.5 last:border-b-0`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12.5px] text-content`,children:n}),(0,J.jsx)(`button`,{type:`button`,"aria-label":i(`config:configPage.delete`),className:`grid size-7 flex-none cursor-pointer place-items-center rounded-sm border-0 bg-transparent p-0 text-content-muted hover:bg-danger-soft hover:text-danger pointer-coarse:size-11`,onClick:()=>t(e.filter(e=>e!==n)),children:(0,J.jsx)(Ce,{size:12})})]},n))}),(0,J.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`config:configPage.manualModelIdsHint`)})]})}function Ni(e,t){return e?.models.find(t=>t.id===e.defaultModel)||(t===`visual`?e?.models.find(e=>e.kind===`image`||e.kind===`video`):e?.models.find(e=>e.kind===`chat`)||e?.models[0])}function Pi({onClose:e,onCreated:t,onConfigChanged:n,initialProviderType:r=`chat`,initialProvider:i,cloneProvider:a,embedded:o=!1}){let{t:s}=l(),c=i||a,u=!!a,d=c?.type||r,p=Ni(c,d),[m,h]=(0,q.useState)(``),g=!!(i||m),[_,v]=(0,q.useState)(()=>({name:a?s(`config:configPage.clonedProviderName`,{name:a.name}):i?.name||``,id:a?Ai():i?.id||``,providerType:d,api:i?.api||`openai-responses`,baseUrl:i?.baseUrl||``,model:p?.id||``,modelName:p?.name||``,modelKind:p?.kind===`image`||p?.kind===`video`?p.kind:d===`visual`?`image`:`chat`,reasoning:p?.reasoning!==!1,thinkingLevels:p?.thinkingLevels||[],enabled:i?.enabled??!0})),y=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],[b,x]=(0,q.useState)(!1),S=e=>{x(!0),v(t=>({...t,thinkingLevels:t.thinkingLevels.includes(e)?t.thinkingLevels.filter(t=>t!==e):[...t.thinkingLevels,e]}))},[C,w]=(0,q.useState)(!1),[T,D]=(0,q.useState)(``),[O,k]=(0,q.useState)(``),A=O.trim()||void 0,[j,M]=(0,q.useState)([]),ee=e=>v(t=>({...t,name:e,id:t.id||e.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)}));return(0,q.useEffect)(()=>{if(o||C)return;let t=t=>{t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),e())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[o,e,C]),(0,J.jsx)(`div`,{className:o?`provider-config-inline`:`modal-backdrop max-[650px]:p-[8px] fixed z-[70] inset-0 grid place-items-center overflow-y-auto bg-[var(--modal-overlay)] [padding:20px] [overscroll-behavior:contain] [animation:fade-in_var(--d1)_var(--ease-out)]`,onMouseDown:t=>!o&&!C&&t.target===t.currentTarget&&e(),children:(0,J.jsxs)(`form`,{role:o?void 0:`dialog`,"aria-modal":!o||void 0,className:o?`provider-config-form grid gap-3 text-sm [&_label]:!mt-0 [&_label]:!text-sm [&_label]:font-medium [&_input]:!h-9 [&_input]:!min-h-9 [&_input]:rounded-lg [&_input]:!text-sm [&_select]:!h-9 [&_select]:!min-h-9 [&_select]:rounded-lg [&_select]:!text-sm [&_summary]:text-sm`:`modal provider-config-modal max-h-[calc(100dvh_-_40px)] !w-[min(620px,100%)] overflow-y-auto overscroll-contain rounded-lg border border-stroke bg-solid p-[18px] shadow-float [animation:modal-in_var(--d2)_var(--ease-out)] max-[650px]:max-h-[calc(100dvh_-_16px)]`,onSubmit:async e=>{if(e.preventDefault(),!C){if(!u&&!A&&!i?.configured&&!m){D(s(`config:configPage.enterTheAPIKeyForThisConnection`));return}w(!0),D(``);try{if(a){t(await f(`/api/providers/${encodeURIComponent(a.id)}/clone`,{method:`POST`,body:JSON.stringify({name:_.name,id:_.id,apiKey:A})}));return}let e=g?await f(`/api/config`,{method:`PUT`,body:JSON.stringify({..._,apiKey:A,thinkingLevels:b?_.thinkingLevels:void 0,provider:m||_.id,providerName:_.name,setAsDefault:!1})}):await f(`/api/providers`,{method:`POST`,body:JSON.stringify({..._,apiKey:A,thinkingLevels:b?_.thinkingLevels:void 0})}),r=e.createdProviderId||m||_.id;i||(h(r),v(e=>({...e,id:r})),n?.(e));let o=new Set((i?.models||[]).map(e=>e.id)),s=j.filter(e=>e!==_.model.trim()&&!o.has(e));if(s.length)try{e=await f(`/api/providers/${encodeURIComponent(r)}/models/batch`,{method:`POST`,body:JSON.stringify({models:s.map(e=>({id:e,kind:_.providerType===`visual`?_.modelKind:`chat`}))})})}catch(e){D(e instanceof Error?e.message:String(e));return}t(e)}catch(e){D(e instanceof Error?e.message:String(e))}finally{w(!1)}}},children:[!o&&(0,J.jsxs)(Bt,{children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{children:s(u?`config:configPage.cloneProvider`:g?`config:configPage.editProviderConnection`:`config:configPage.addProviderConnection`)}),!u&&(0,J.jsx)(`p`,{children:s(g?`config:configPage.updateProviderKeyURLAndModelSettings`:`config:configPage.youCanCreateMultipleConnectionsUsingTheSameProtocolEachWithItsOwnKeyAndBaseURL`)})]}),(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`config:configPage.closeDialog`),disabled:C,onClick:t=>{t.preventDefault(),t.stopPropagation(),e()},children:(0,J.jsx)(Ce,{size:17})})]}),(0,J.jsxs)(`div`,{className:`form-grid grid gap-3 sm:grid-cols-2`,children:[(0,J.jsxs)(G,{variant:`control`,children:[s(`config:configPage.displayName`),(0,J.jsx)(B,{value:_.name,onChange:e=>ee(e.target.value),placeholder:s(`config:configPage.forExampleOpenAIOfficial`)})]}),(0,J.jsxs)(G,{variant:`control`,children:[`Provider ID`,(0,J.jsx)(B,{value:_.id,disabled:g,onChange:e=>v({..._,id:e.target.value}),placeholder:`openai-official`})]})]}),(0,J.jsx)(ji,{value:O,onChange:k,configured:i?.configured,cloning:u}),!u&&(0,J.jsxs)(J.Fragment,{children:[!o&&(0,J.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between gap-2 rounded-sm border border-stroke-soft bg-surface-subtle px-2.5 py-2`,children:[(0,J.jsx)(`span`,{className:`text-xs text-content-muted`,children:s(`config:configPage.providerPurpose`)}),(0,J.jsx)(`strong`,{className:`font-mono text-xs font-medium`,children:_.providerType===`visual`?s(`config:configPage.visualProvider`):s(`config:configPage.chatProvider`)})]}),(0,J.jsxs)(G,{variant:`control`,children:[s(`config:configPage.apiProtocol`),(0,J.jsx)(K,{value:_.api,onChange:e=>v({..._,api:e.target.value}),children:mi.map(([e,t])=>(0,J.jsx)(`option`,{value:e,children:t},e))})]}),(0,J.jsxs)(G,{variant:`control`,children:[`Base URL`,(0,J.jsx)(B,{value:_.baseUrl,onChange:e=>v({..._,baseUrl:e.target.value}),placeholder:`https://api.openai.com/v1`})]}),(0,J.jsxs)(`div`,{className:`form-grid grid gap-3 sm:grid-cols-2`,children:[(0,J.jsxs)(G,{variant:`control`,children:[s(g?`config:configPage.providerDefaultModel`:`config:configPage.initialModelID`),(0,J.jsx)(B,{value:_.model,onChange:e=>v({..._,model:e.target.value}),placeholder:_.providerType===`visual`?`gpt-image-2 or grok-imagine-video`:`gpt-5.4 or gpt-image-1`})]}),(0,J.jsxs)(G,{variant:`control`,children:[s(`config:configPage.modelName`),(0,J.jsx)(B,{value:_.modelName,onChange:e=>v({..._,modelName:e.target.value}),placeholder:s(`config:configPage.leaveBlankToUseTheModelID`)})]})]}),(0,J.jsxs)(`details`,{open:!o||void 0,className:`group rounded-lg border border-border px-3 py-2 [&[open]]:space-y-3`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer text-[13px] text-muted-foreground`,children:s(`config:providerWorkbench.modelOptions`)}),(0,J.jsxs)(G,{variant:`control`,children:[s(`config:configPage.modelType`),(0,J.jsxs)(K,{value:_.modelKind,onChange:e=>v({..._,modelKind:e.target.value,providerType:e.target.value===`chat`?`chat`:`visual`}),children:[(0,J.jsx)(`option`,{value:`chat`,children:s(`providers:modelEditor.chat`)}),(0,J.jsx)(`option`,{value:`image`,children:s(`providers:modelEditor.image`)}),(0,J.jsx)(`option`,{value:`video`,children:s(`providers:modelEditor.video`)})]})]}),(0,J.jsx)(`div`,{className:`grid gap-[9px]`,children:(0,J.jsx)(Mi,{ids:j,onChange:M,primaryId:_.model,placeholder:_.providerType===`visual`?`gpt-image-1`:`gpt-5.5`})}),_.modelKind===`chat`&&(0,J.jsxs)(G,{variant:`control`,children:[s(`config:configPage.modelThinkingLevels`),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-[6px]`,children:y.map(e=>{let t=e===`off`,n=t||_.thinkingLevels.includes(e),r=t||!_.reasoning&&e!==`off`;return(0,J.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r,onClick:()=>!t&&S(e),className:L(`inline-flex h-[27px] cursor-pointer items-center gap-[4px] rounded-full border px-[10px] text-[12px] font-medium transition-colors`,n?`border-[var(--control-selected-border)] bg-[var(--control-selected-bg)] text-[var(--control-selected-text)]`:`border-[var(--stroke)] bg-[var(--surface-subtle)] text-[var(--text)] hover:bg-[var(--surface-highlight)]`,t?`cursor-default`:r&&`cursor-not-allowed opacity-40`),children:[n&&(0,J.jsx)(E,{size:12}),e]},e)})}),(0,J.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:s(`config:configPage.modelThinkingLevelsHint`)})]})]}),!o&&(0,J.jsxs)(`div`,{className:`mt-2.5 flex min-h-11 items-center justify-between gap-3 rounded-sm border border-[var(--stroke-soft)] bg-[var(--surface-subtle)] px-2.5 py-2`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,J.jsx)(`strong`,{className:`text-[13px]`,children:g?s(`config:configPage.providerEnabled`,{name:_.name}):s(`config:configPage.enableAfterCreation`)}),_.providerType===`visual`&&(0,J.jsx)(`small`,{className:`text-[13px] text-muted-foreground`,children:s(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]}),(0,J.jsx)(br,{value:_.enabled,onChange:e=>v({..._,enabled:e})})]})]}),T&&(0,J.jsxs)(Rt,{children:[(0,J.jsx)(xe,{size:13}),T]}),(0,J.jsxs)(`div`,{className:`mt-[18px] flex justify-end gap-2`,children:[(0,J.jsx)(z,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:C,onClick:e,children:s(`config:configPage.cancel`)}),(0,J.jsxs)(z,{type:`submit`,className:`max-[650px]:h-11`,disabled:C,children:[C?(0,J.jsx)(R,{className:`text-current`}):g?(0,J.jsx)(E,{size:14}):(0,J.jsx)(de,{size:14}),s(C?`config:configPage.saving`:u?`config:configPage.cloneProvider`:g?`config:configPage.saveChanges`:`config:configPage.createConnection`)]})]})]})})}function Fi(e){return(e.providers||[]).filter(e=>e.importable&&!e.imported&&!e.conflict).length}function Ii(e){return Fi(e)>0}function Li(e,t){return!t&&!Ii(e)}function Ri(e,t,n){let r=e.providers||[],i=e.errors||[],a=Ii(e),o=!!(n||i.length||r.some(e=>e.conflict||!e.imported&&!e.importable||e.warnings?.some(e=>e.code!==`login_auth_not_imported`)));return t||a||o}function zi(e){return e.source===`codex-config`?`Codex config.toml`:e.source===`claude-config`?`Claude settings.json`:e.source===`codex-auth`?`Codex login`:`Claude login`}function Bi(e,t){return e.authType===`environment`?t(`config:configPage.keyVariableName`,{name:e.authVariable}):e.authType===`bearer`||e.authType===`api_key`?t(`config:configPage.authenticationIncludedInConfiguration`):e.authType===`oauth`?t(`config:configPage.loginStateFileDetected`):e.authType===`external-login`?t(`config:configPage.authenticationRequired`):t(`config:configPage.noAuthenticationInConfiguration`)}function Vi(e,t){return t(e===`multiple_auth_values`?`config:configPage.multipleAuthenticationFieldsWereDetectedTheAuthorizationFieldTakesPrecedence`:e===`invalid_url`?`config:configPage.theProviderEndpointIsInvalid`:e===`unsupported_api`?`config:configPage.theAPIProtocolInThisConfigurationIsNotSupportedYet`:e===`invalid_env_name`?`config:configPage.theKeyEnvironmentVariableNameIsInvalid`:`config:configPage.someConfigurationFieldsCannotBeImported`)}function Hi({discovery:e,discovering:t,error:n,importing:r,forceVisible:i=!1,onRefresh:a,onImport:o}){let{t:s}=l(),[c,u]=(0,q.useState)(null),d=e.providers||[],f=e.errors||[];if(!i&&!Ri(e,t,n))return null;let p=c??(!i&&Li(e,t)),m=()=>(u(null),a()),h=e=>(u(null),o(e)),g=e=>[`invalid_json`,`invalid_toml`].includes(e.code)?s(`config:configPage.invalidConfigurationFileFormat`):e.code===`unsupported_config`?s(`config:configPage.noImportableProviderConfigurationWasFound`):e.code===`invalid_login_state`?s(`config:configPage.incompleteLoginState`):e.code===`file_too_large`?s(`config:configPage.configurationFileIsTooLarge`):s(`config:configPage.unableToReadTheConfigurationFile`);return(0,J.jsxs)(_r,{className:`mb-3 py-3.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2.5 max-[650px]:flex-wrap`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-3 rounded-sm border-0 bg-transparent p-0 text-left max-[650px]:basis-full`,"aria-expanded":!p,onClick:()=>u(!p),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-9.5 shrink-0 place-items-center rounded-lg border border-key-border bg-key text-content-muted shadow-key`,children:(0,J.jsx)(ge,{size:18})}),(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium text-content`,children:s(`config:configPage.localProviderConfiguration`)}),(0,J.jsx)(`span`,{className:`text-xs leading-[1.45] text-content-muted`,children:s(`config:configPage.readProviderEndpointModelAndAuthenticationFieldsFromCodexConfigTomlAndClaudeSettingsJson`)})]}),(0,J.jsx)(D,{size:16,"aria-hidden":`true`,className:L(`flex-none text-content-muted transition-transform`,!p&&`rotate-180`)})]}),(0,J.jsxs)(z,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:t||!!r,onClick:m,children:[t?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(fe,{size:13}),s(`config:configPage.rescan`)]})]}),!p&&(0,J.jsxs)(J.Fragment,{children:[t&&!d.length?(0,J.jsxs)(`div`,{role:`status`,className:`mt-3 flex min-h-12 items-center justify-center gap-2 rounded-sm bg-surface-subtle text-xs text-content-muted`,children:[(0,J.jsx)(R,{}),s(`config:configPage.scanningProviderConfigurationFiles`)]}):d.length?(0,J.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 max-[650px]:grid-cols-1`,children:d.map(e=>{let t=zi(e),n=r===e.id,i=e.source.startsWith(`claude-`)?T:w,a=e.kind===`authentication`?s(`config:configPage.officialProviderAuthenticationOnly`):e.models?.length?e.models.map(e=>e.id).join(`, `):s(`config:configPage.noModelSpecified`);return(0,J.jsxs)(`div`,{className:L(`grid min-h-17 min-w-0 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2.5 rounded-md border px-3 py-2 max-[650px]:grid-cols-[auto_minmax(0,1fr)]`,e.imported?`border-success-border bg-success-soft`:`border-stroke bg-panel`),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-7.5 place-items-center rounded-md border border-key-border bg-key text-content-muted shadow-key`,children:(0,J.jsx)(i,{size:15})}),(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,J.jsxs)(`span`,{className:`truncate text-sm font-medium text-content`,children:[t,` · `,e.providerName]}),(0,J.jsxs)(`span`,{className:`truncate font-mono text-xs text-content-muted`,children:[e.api,` · `,a]}),(0,J.jsxs)(`span`,{className:`truncate text-xs text-content-muted`,children:[e.kind===`authentication`?s(`config:configPage.officialEndpointOnly`):e.baseUrl||s(`config:configPage.noBaseURLSpecified`),` `,`· `,Bi(e,s),` · `,e.location]})]}),(0,J.jsx)(`span`,{className:`flex min-w-0 flex-none items-center max-[650px]:col-start-2`,children:e.imported?(0,J.jsx)(yr,{tone:`green`,children:s(`config:configPage.loaded`)}):e.conflict?(0,J.jsx)(yr,{tone:`amber`,children:s(`config:configPage.conflictDetected`)}):e.importable?(0,J.jsxs)(z,{type:`button`,size:`sm`,className:`pointer-coarse:h-11`,disabled:n||!!r,onClick:()=>h(e),children:[n?(0,J.jsx)(R,{className:`size-3 text-current`}):(0,J.jsx)(ee,{size:12}),n?s(`config:configPage.loading`):e.kind===`authentication`?s(`config:configPage.loadLoginState`):s(`config:configPage.loadConfiguration`)]}):(0,J.jsx)(yr,{tone:`gray`,children:s(`config:configPage.cannotLoad`)})})]},e.id)})}):(0,J.jsxs)(`div`,{className:`mt-3 flex min-h-12 items-center justify-center gap-2 rounded-sm bg-surface-subtle px-3 text-center text-xs text-content-muted`,children:[(0,J.jsx)(ge,{size:15,"aria-hidden":`true`}),s(`config:configPage.noImportableCodexOrClaudeProviderConfigurationWasDetected`)]}),(n||f.length>0||d.some(e=>e.warnings?.some(e=>e.code!==`login_auth_not_imported`)))&&(0,J.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1 text-xs text-danger [&_span]:flex [&_span]:items-center [&_span]:gap-1.5`,"aria-live":`polite`,children:[n&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(xe,{size:13}),n]}),f.map((e,t)=>(0,J.jsxs)(`span`,{children:[(0,J.jsx)(xe,{size:13}),zi(e),` · `,g(e)]},`${e.source}-${e.code}-${t}`)),d.flatMap(e=>(e.warnings||[]).filter(e=>e.code!==`login_auth_not_imported`).map((t,n)=>(0,J.jsxs)(`span`,{children:[(0,J.jsx)(xe,{size:13}),zi(e),` · `,Vi(t.code,s)]},`${e.id}-${t.code}-${n}`)))]})]})]})}function Ui(e){try{return{name:new URL(e).hostname.replace(/^www\./i,``)||`Custom Provider`}}catch{return{name:`Custom Provider`}}}function Wi({config:e,providerType:t=`chat`,initialProviderId:n,onClose:r,onConfigChanged:i,onCompleted:a}){let{t:o}=l(),s=n&&e.providers.find(e=>e.id===n)||null,[c,u]=(0,q.useState)(1),[d,p]=(0,q.useState)(s),[m]=(0,q.useState)(Ai),[h,g]=(0,q.useState)(``),_=(0,q.useRef)(null),v=(0,q.useRef)(null),[y,S]=(0,q.useState)(s?.baseUrl||``),[C,w]=(0,q.useState)(s?.api||`openai-responses`),[T,D]=(0,q.useState)(``),O=T.trim()||void 0,[k,A]=(0,q.useState)(s?.organization||``),[j,M]=(0,q.useState)(s?.name||``),[ee,N]=(0,q.useState)(s?.models||[]),[P,te]=(0,q.useState)(s?.defaultModel||``),[ne,re]=(0,q.useState)([]),[ie,ae]=(0,q.useState)(s?.models.find(e=>e.id===s.defaultModel)?.kind||(t===`visual`?`image`:`chat`)),[F,oe]=(0,q.useState)(!1),[se,I]=(0,q.useState)(``),[ce,le]=(0,q.useState)(``),ue=Ui(y),de=o(t===`visual`?`config:configPage.visualProvider`:`config:configPage.chatProvider`),pe=o(c===1?`config:configPage.quickSetupStepBaseUrl`:c===2?`config:configPage.quickSetupStepProtocol`:`config:configPage.quickSetupStepModel`),me=ee.filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`),he=()=>{let e=y.trim();try{let t=new URL(e);if(![`http:`,`https:`].includes(t.protocol))throw Error()}catch{I(o(`config:configPage.providerBaseURLMustBeHTTPOrHTTPS`));return}I(``),j.trim()||M(ue.name),u(2)},_e=()=>{if(!C){I(o(`config:configPage.selectAPIProtocol`));return}I(``),u(3)},ve=async()=>{if(F)return;let e=d;if(!O&&!e?.configured&&!h){I(o(`config:configPage.enterTheAPIKeyForThisConnection`));return}oe(!0),I(``),le(``);try{let n=((await f(`/api/providers/models/discover-connection`,{method:`POST`,body:JSON.stringify({providerId:e?.id||h,providerType:t,api:C,baseUrl:y,organization:k,apiKey:O})})).models||[]).filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`);if(!n.length){I(o(t===`visual`?`config:configPage.fetchOrAddAVisualModel`:`config:configPage.fetchOrAddAChatModel`));return}N(n);let r=n.find(e=>e.id===P)||n[0];te(r.id),ae(t===`visual`?r.kind:`chat`)}catch(n){let r=n instanceof Error?n.message:String(n),i=e?.models.filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`)||[];if(!/\(401\)|\(403\)|鉴权|认证|密钥|API Key/i.test(r)&&i.length){N(i);let e=i.find(e=>e.id===P)||i[0];te(e.id),ae(t===`visual`?e.kind:`chat`),le(r)}else I(r)}finally{oe(!1)}},ye=async()=>{if(F)return;let e=P.trim()||ne[0]||``;if(!e){I(o(`config:configPage.selectModelToFinish`));return}if(!O&&!d?.configured&&!h){I(o(`config:configPage.enterTheAPIKeyForThisConnection`));return}let n=new Set((d?.models||[]).map(e=>e.id)),r=ne.filter(t=>t!==e&&!n.has(t));oe(!0),I(``);try{let n=d?.id||h,o=n?await f(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:n,providerType:t,api:C,baseUrl:y,organization:k,model:e,modelKind:t===`visual`?ie:`chat`,apiKey:O,setAsDefault:!1,enabled:!0})}):await f(`/api/providers`,{method:`POST`,body:JSON.stringify({id:m,name:j.trim()||ue.name,providerType:t,api:C,baseUrl:y,organization:k,apiKey:O,model:e,modelKind:t===`visual`?ie:`chat`,enabled:!0})}),c=n||o.createdProviderId||m,l=s?``:c;l&&g(l);let u=o.providers.find(e=>e.id===c);if(u&&p(u),i?.(l?{...o,createdProviderId:l}:o),r.length){let e=t===`visual`?ie:`chat`;try{o=await f(`/api/providers/${encodeURIComponent(c)}/models/batch`,{method:`POST`,body:JSON.stringify({models:r.map(t=>({id:t,kind:e}))})})}catch(e){I(e instanceof Error?e.message:String(e));return}}a(l?{...o,createdProviderId:l}:o)}catch(e){I(e instanceof Error?e.message:String(e))}finally{oe(!1)}};return(0,J.jsx)(Tt,{open:!0,onOpenChange:e=>{!e&&!F&&r()},children:(0,J.jsxs)(xt,{showCloseButton:!1,className:`modal z-[80] block max-h-[calc(100dvh_-_40px)] w-[calc(100%_-_40px)] max-w-lg overflow-y-auto overscroll-contain rounded-[var(--r-lg)] border border-stroke bg-solid p-[18px] shadow-float sm:max-w-lg max-[650px]:max-h-[calc(100dvh_-_16px)] max-[650px]:w-[calc(100%_-_16px)]`,overlayClassName:`z-[70] bg-[var(--modal-overlay)]`,"aria-busy":F,onEscapeKeyDown:e=>{F&&e.preventDefault()},onInteractOutside:e=>{F&&e.preventDefault()},onOpenAutoFocus:e=>{e.preventDefault(),_.current=document.activeElement instanceof HTMLElement?document.activeElement:null,v.current?.focus()},onCloseAutoFocus:e=>{e.preventDefault(),_.current?.focus()},children:[(0,J.jsxs)(Bt,{children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(St,{asChild:!0,children:(0,J.jsx)(`h2`,{children:o(t===`visual`?`config:configPage.visualQuickSetupTitle`:`config:configPage.quickSetupTitle`)})}),(0,J.jsx)(bt,{asChild:!0,children:(0,J.jsxs)(`p`,{children:[o(`config:configPage.stepIndicator`,{current:c,total:3}),` · `,pe]})})]}),(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,className:`pointer-coarse:size-11`,"aria-label":o(`config:configPage.closeDialog`),disabled:F,onClick:r,children:(0,J.jsx)(Ce,{size:17})})]}),(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`mt-3 grid grid-cols-3 gap-1`,children:[1,2,3].map(e=>(0,J.jsx)(`span`,{className:L(`h-1 rounded-full`,e<=c?`bg-star`:`bg-surface-active`)},e))}),(0,J.jsxs)(`div`,{className:`mt-3 flex items-center gap-2.5 rounded-md border border-stroke-soft bg-surface-subtle px-2.5 py-2`,children:[(0,J.jsx)(`span`,{className:`grid size-7.5 flex-none place-items-center rounded-md border border-key-border bg-key text-content-muted shadow-key`,children:(0,J.jsx)(ge,{size:15,"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`truncate text-sm font-medium text-content`,children:j||ue.name}),(0,J.jsx)(`small`,{className:`text-xs text-content-muted`,children:de})]}),(0,J.jsx)(yr,{tone:`gray`,children:de})]}),c===1&&(0,J.jsxs)(`div`,{className:`[margin-top:14px]`,children:[(0,J.jsxs)(G,{variant:`control`,children:[`Base URL`,(0,J.jsx)(B,{ref:v,value:y,onChange:e=>S(e.target.value),placeholder:`https://api.example.com/v1`,inputMode:`url`})]}),(0,J.jsx)(`p`,{className:`mt-2 text-xs leading-[1.5] text-content-muted`,children:o(`config:configPage.quickSetupBaseUrlHint`)})]}),c===2&&(0,J.jsxs)(`div`,{className:`[margin-top:14px]`,children:[(0,J.jsxs)(G,{variant:`control`,children:[o(`config:configPage.apiProtocol`),(0,J.jsx)(K,{value:C,onChange:e=>w(e.target.value),children:mi.map(([e,t])=>(0,J.jsx)(`option`,{value:e,children:t},e))})]}),(0,J.jsxs)(G,{variant:`control`,children:[`Organization`,(0,J.jsx)(B,{value:k,onChange:e=>A(e.target.value),placeholder:o(`config:configPage.optionalUsedOnlyForOpenAIOrganization`)})]})]}),c===3&&(0,J.jsxs)(`div`,{className:`[margin-top:14px]`,children:[!d&&(0,J.jsxs)(G,{variant:`control`,children:[o(`config:configPage.displayName`),(0,J.jsx)(B,{value:j,onChange:e=>M(e.target.value),placeholder:ue.name})]}),(0,J.jsx)(ji,{value:T,onChange:D,configured:d?.configured}),(0,J.jsxs)(z,{type:`button`,variant:`secondary`,className:`mt-2.5 w-full max-[650px]:h-11`,disabled:F,onClick:()=>void ve(),children:[F?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(fe,{size:14}),o(F?`config:configPage.fetchingModels`:`config:configPage.fetchModels`)]}),ce&&(0,J.jsxs)(Lt,{className:`[margin-top:10px]`,children:[(0,J.jsx)(xe,{size:15}),(0,J.jsx)(`small`,{children:o(`config:configPage.discoverFailedUsingExisting`,{message:ce})})]}),me.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`mt-3.5 mb-2 text-xs leading-[1.5] text-content-muted`,children:o(t===`visual`?`config:configPage.selectVisualModelToFinish`:`config:configPage.selectModelToFinish`)}),(0,J.jsx)(`div`,{className:`flex max-h-[260px] flex-col overflow-y-auto rounded-md border border-stroke`,children:me.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:L(`relative flex min-h-10 min-w-0 cursor-pointer items-center gap-2 border-b border-stroke-soft px-2.5 py-2 text-left last:border-b-0 hover:bg-surface-subtle pointer-coarse:min-h-11`,P===e.id&&`bg-star-soft before:absolute before:inset-y-2 before:left-0 before:w-[3px] before:rounded-r-[3px] before:bg-star hover:bg-star-soft`),onClick:()=>{te(e.id),ae(t===`visual`?e.kind:`chat`)},children:[(0,J.jsx)(`span`,{className:L(`grid size-4 flex-none place-items-center rounded-full border border-control text-transparent`,P===e.id&&`border-star bg-star text-on-accent`),children:(0,J.jsx)(E,{size:11})}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-content`,children:e.name}),t===`visual`&&(0,J.jsx)(yr,{tone:`gray`,children:e.kind===`video`?o(`config:configPage.visualVideoModel`):o(`config:configPage.visualImageModel`)})]},`${e.id}-${e.kind}`))})]}),(0,J.jsxs)(`div`,{className:`mt-3.5 grid gap-2`,children:[(0,J.jsxs)(G,{variant:`control`,children:[o(`config:configPage.manualModelId`),(0,J.jsx)(B,{value:P,onChange:e=>te(e.target.value),placeholder:t===`visual`?`gpt-image-1`:`gpt-5.4`})]}),(0,J.jsx)(`p`,{className:`text-xs text-content-muted`,children:o(`config:configPage.manualModelIdHint`)}),t===`visual`&&(0,J.jsxs)(G,{variant:`control`,children:[o(`config:configPage.modelType`),(0,J.jsxs)(K,{value:ie,onChange:e=>ae(e.target.value),children:[(0,J.jsx)(`option`,{value:`image`,children:o(`config:configPage.imageGenerationAndEditing`)}),(0,J.jsx)(`option`,{value:`video`,children:o(`config:configPage.videoGeneration`)})]})]}),(0,J.jsx)(Mi,{ids:ne,onChange:re,primaryId:P,placeholder:t===`visual`?`gpt-image-1`:`gpt-5.5`})]})]}),se&&(0,J.jsxs)(Rt,{children:[(0,J.jsx)(xe,{size:13}),se]}),(0,J.jsxs)(`div`,{className:`mt-[18px] flex justify-between gap-2`,children:[(0,J.jsxs)(z,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:F||c===1,onClick:()=>{I(``),u(c-1)},children:[(0,J.jsx)(b,{size:14}),o(`config:configPage.previousStep`)]}),c===1?(0,J.jsxs)(z,{type:`button`,className:`max-[650px]:h-11`,disabled:F||!y.trim(),onClick:he,children:[(0,J.jsx)(x,{size:14}),o(`config:configPage.nextStep`)]}):c===2?(0,J.jsxs)(z,{type:`button`,className:`max-[650px]:h-11`,disabled:F,onClick:_e,children:[(0,J.jsx)(x,{size:14}),o(`config:configPage.nextStep`)]}):(0,J.jsxs)(z,{type:`button`,className:`max-[650px]:h-11`,disabled:F||!P.trim()&&ne.length===0,onClick:()=>void ye(),children:[F?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(E,{size:14}),o(F?`config:configPage.saving`:`config:configPage.saveChanges`)]})]})]})})}var Gi=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],Ki=``;function qi(e){return`${e.provider.id}/${e.model.id}`}function Ji({labelId:e,label:t,hint:n,children:r}){return(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-6 gap-y-2 border-b border-stroke py-4 max-[650px]:py-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-[min(240px,100%)] flex-1`,children:[(0,J.jsx)(`div`,{id:e,className:`text-sm font-medium text-content`,children:t}),(0,J.jsx)(`p`,{id:`${e}-hint`,className:`mt-0.5 text-xs text-content-muted`,children:n})]}),(0,J.jsx)(`div`,{className:`w-[min(280px,100%)] min-w-0 max-[650px]:w-full`,children:r})]})}function Yi({config:e,notify:t,busy:n,onConfigChanged:r,onSetDefaultModel:i}){let{t:a}=l(),o=(0,q.useId)(),[s,c]=(0,q.useState)(!1),[u,d]=(0,q.useState)(``),[p,m]=(0,q.useState)(e.thinkingLevel),[h,g]=(0,q.useState)(e.toolMode);(0,q.useEffect)(()=>{m(e.thinkingLevel),g(e.toolMode)},[e.thinkingLevel,e.toolMode]);let _=(e.fallbackModels||[]).join(`
1
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{l as t,m as n}from"./vendor-router-CSN_DGvx.js";import{t as r}from"./index-DT21IKeB.js";import{i,r as a}from"./vendor-react-DwNgTV1j.js";import{c as o,d as s,n as c}from"./i18n-Cewq43aI.js";import{t as l}from"./use-i18n-BPJI6-Ue.js";import{a as u,l as d,t as f}from"./api-3pnTJcsp.js";import{n as p}from"./runtime-capabilities-CHYOF_hE.js";import{t as m}from"./runtime-capabilities-store-CDhzPVU-.js";import{n as h}from"./client-store-B0G8KCEA.js";import{t as g}from"./createLucideIcon-Cd-3GVxJ.js";import{a as _,i as v,t as y}from"./permission-rules-api-DdYftUQE.js";import{t as b}from"./arrow-left-B8oVrQ2S.js";import{t as x}from"./arrow-right-DqLOhpA2.js";import{t as S}from"./arrow-up-right-B6l8qFZz.js";import{t as C}from"./bell-BjONAtgH.js";import{t as w}from"./bot-B3TaBp_T.js";import{t as T}from"./brain-qxhnKqYP.js";import{t as E}from"./check-2vYc6QaP.js";import{t as D}from"./chevron-down-CxtxIjiP.js";import{t as O}from"./chevron-left-BAtyp3_6.js";import{t as k}from"./circle-alert-DCChabnT.js";import{t as A}from"./circle-check-iEdCm3Pw.js";import{t as j}from"./code-xml-BrUXrBax.js";import{t as M}from"./copy-DHmIFc52.js";import{t as ee}from"./download-BCfIiuaL.js";import{t as N}from"./ellipsis-CfGKfbq6.js";import{t as P}from"./external-link-CEQqPcqc.js";import{i as te,o as ne,s as re}from"./settings-navigation-DiP_AM1C.js";import{t as ie}from"./image-BY_c3FYU.js";import{t as ae}from"./info-DATxy0fb.js";import{t as F}from"./loader-circle-BOwQzHB-.js";import{t as oe}from"./message-square-SKjZyY3v.js";import{t as se}from"./monitor-smartphone-B1gIjItA.js";import{n as I,r as ce,t as le}from"./zap-DZHw5afO.js";import{t as ue}from"./play-DNDjDNGn.js";import{t as de}from"./plus-fQbSqB1n.js";import{t as fe}from"./refresh-cw-TbWxTY4K.js";import{t as pe}from"./rocket-BgLSjoHY.js";import{t as me}from"./rotate-ccw-C0v8V77_.js";import{t as he}from"./search-D0mqDaf_.js";import{t as ge}from"./server-BgNvmqwJ.js";import{t as _e}from"./shield-check-Gvek4RJ7.js";import{t as ve}from"./sparkles-S_eeuqn9.js";import{t as ye}from"./square-terminal-BVG6cUT1.js";import{t as be}from"./trash-2-CNrPOoPR.js";import{t as xe}from"./triangle-alert-CE1q54ci.js";import{t as Se}from"./wrench-6pg6_bqI.js";import{t as Ce}from"./x-07u4-129.js";import{t as we}from"./brand-DIEc3fK8.js";import{a as Te}from"./dist-41X0pdUs.js";import{c as Ee,i as De,o as Oe,s as ke}from"./dist-BsRXXcSL.js";import{t as Ae}from"./dist-DzGQ7sLi.js";import{i as je,n as Me,r as Ne,t as Pe}from"./accordion-CiJMkjqX.js";import{t as Fe}from"./dist-OB2r6Xsr.js";import{n as Ie,r as Le,t as Re}from"./dist-BaBySQmo.js";import{c as ze,i as Be,n as Ve,p as He,r as Ue,t as We}from"./dropdown-menu-Ds0gD8S8.js";import{i as Ge,n as Ke,t as qe}from"./popover-CEwCyvso.js";import{a as Je,i as Ye,n as Xe,r as Ze,t as Qe}from"./select-DD_WO-gs.js";import{t as $e}from"./separator-BPh_qxvc.js";import{t as et}from"./slider-DTmAZl-R.js";import{t as tt}from"./switch-D_G8wFhs.js";import{t as L}from"./utils-C8uzG5AZ.js";import{n as R,r as nt,t as z}from"./button-CCcCN8tE.js";import{n as rt,t as it}from"./kbd-CAufZTkl.js";import{i as at,t as ot}from"./config-search-Cnob89Wh.js";import{_ as st,c as ct,d as lt,f as ut,h as dt,l as ft,m as pt,o as mt,p as ht,t as gt,u as _t}from"./shortcuts-zcQP1D4E.js";import{a as vt}from"./format-DMJQzoZ7.js";import{t as yt}from"./StatusGlyph-1KgitlUg.js";import{a as bt,i as xt,l as St,o as Ct,s as wt,t as Tt}from"./dialog-sq6TFrs2.js";import{t as B}from"./input-CPw-zkYh.js";import{t as Et}from"./textarea-DmATpOqT.js";import{t as Dt}from"./model-display-kDwvtxrW.js";import{n as Ot,r as kt,t as At}from"./PageState-Cz6vFMXv.js";import{t as jt}from"./useOverlayFocusReturn-NkxBSSjb.js";import{i as V,n as H,o as U,r as Mt,s as Nt,t as W}from"./FeaturePage-B8dFhtLs.js";import{n as G}from"./field-DoLEb0np.js";import{t as Pt}from"./MarkdownMessage-Dbypp4RC.js";import{t as K}from"./AppSelect-BD6RAaJ5.js";import{n as Ft}from"./public-flags-DZvYvsWH.js";import{t as It}from"./badge-CWB3lj2H.js";import{a as Lt,i as Rt,l as zt,n as Bt,o as Vt,r as Ht,s as Ut,t as Wt}from"./app-primitives-Drz_SjnR.js";import{t as Gt}from"./BrandLogo-k3CvJjd4.js";import{n as Kt,r as qt,t as Jt}from"./collapsible-Dcoy-qnz.js";import{C as Yt,_ as Xt,a as Zt,c as Qt,d as $t,g as en,i as tn,l as nn,o as rn,p as an,r as on,s as sn,v as cn,x as ln,y as un}from"./app-update-C6PjqV-N.js";import{a as dn,n as fn,r as pn,t as mn}from"./ShortcutKeys-CE7wsdx4.js";import{i as hn,n as gn,r as _n,t as vn}from"./browser-notifications-DBS0oXqN.js";var yn=g(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),bn=g(`blend`,[[`circle`,{cx:`9`,cy:`9`,r:`7`,key:`p2h5vp`}],[`circle`,{cx:`15`,cy:`15`,r:`7`,key:`19ennj`}]]),xn=g(`cat`,[[`path`,{d:`M12 5c.67 0 1.35.09 2 .26 1.78-2 5.03-2.84 6.42-2.26 1.4.58-.42 7-.42 7 .57 1.07 1 2.24 1 3.44C21 17.9 16.97 21 12 21s-9-3-9-7.56c0-1.25.5-2.4 1-3.44 0 0-1.89-6.42-.5-7 1.39-.58 4.72.23 6.5 2.23A9.04 9.04 0 0 1 12 5Z`,key:`x6xyqk`}],[`path`,{d:`M8 14v.5`,key:`1nzgdb`}],[`path`,{d:`M16 14v.5`,key:`1lajdz`}],[`path`,{d:`M11.25 16.25h1.5L12 17l-.75-.75Z`,key:`12kq1m`}]]),Sn=g(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),Cn=g(`fold-vertical`,[[`path`,{d:`M12 22v-6`,key:`6o8u61`}],[`path`,{d:`M12 8V2`,key:`1wkif3`}],[`path`,{d:`M4 12H2`,key:`rhcxmi`}],[`path`,{d:`M10 12H8`,key:`s88cx1`}],[`path`,{d:`M16 12h-2`,key:`10asgb`}],[`path`,{d:`M22 12h-2`,key:`14jgyd`}],[`path`,{d:`m15 19-3-3-3 3`,key:`e37ymu`}],[`path`,{d:`m15 5-3 3-3-3`,key:`19d6lf`}]]),wn=g(`laptop`,[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]),Tn=g(`monitor-cog`,[[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`m14.305 7.53.923-.382`,key:`1mlnsw`}],[`path`,{d:`m15.228 4.852-.923-.383`,key:`82mpwg`}],[`path`,{d:`m16.852 3.228-.383-.924`,key:`ln4sir`}],[`path`,{d:`m16.852 8.772-.383.923`,key:`1dejw0`}],[`path`,{d:`m19.148 3.228.383-.924`,key:`192kgf`}],[`path`,{d:`m19.53 9.696-.382-.924`,key:`fiavlr`}],[`path`,{d:`m20.772 4.852.924-.383`,key:`1j8mgp`}],[`path`,{d:`m20.772 7.148.924.383`,key:`zix9be`}],[`path`,{d:`M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7`,key:`1tnzv8`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}]]),En=g(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),Dn=g(`qr-code`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),On=g(`radar`,[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`,key:`qzzz0`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`,key:`1yjesh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`,key:`1u2y91`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]),kn=g(`scale`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]),An=g(`scan-line`,[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}]]),jn=g(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),Mn=g(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Nn=g(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),Pn=g(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Fn=g(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),In=g(`unfold-vertical`,[[`path`,{d:`M12 22v-6`,key:`6o8u61`}],[`path`,{d:`M12 8V2`,key:`1wkif3`}],[`path`,{d:`M4 12H2`,key:`rhcxmi`}],[`path`,{d:`M10 12H8`,key:`s88cx1`}],[`path`,{d:`M16 12h-2`,key:`10asgb`}],[`path`,{d:`M22 12h-2`,key:`14jgyd`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m15 5-3-3-3 3`,key:`itvq4r`}]]),Ln=g(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),q=e(i(),1),J=a(),Rn=Object.defineProperty,Y=(e,t)=>Rn(e,`name`,{value:t,configurable:!0}),zn=`Radio`,[Bn,Vn]=ke(zn),[Hn,Un]=Bn(zn);function Wn(e){let{__scopeRadio:t,checked:n=!1,children:r,disabled:i,form:a,name:o,onCheck:s,required:c,value:l=`on`,internal_do_not_use_render:u}=e,[d,f]=q.useState(null),[p,m]=q.useState(null),h=q.useRef(!1),[g,_]=q.useReducer(e=>e+1,0),v={checked:n,disabled:i,required:c,name:o,form:a,value:l,control:d,setControl:f,hasConsumerStoppedPropagationRef:h,userInteractionCount:g,onUserInteraction:_,isFormControl:!d||!!a||!!d.closest(`form`),bubbleInput:p,setBubbleInput:m,onCheck:Y(()=>s?.(),`onCheck`)};return(0,J.jsx)(Hn,{scope:t,...v,children:Yn(u)?u(v):r})}Y(Wn,`RadioProvider`);var Gn=`RadioTrigger`,Kn=q.forwardRef(Y(function({__scopeRadio:e,onClick:t,...n},r){let{checked:i,disabled:a,value:o,setControl:s,onCheck:c,hasConsumerStoppedPropagationRef:l,onUserInteraction:u,isFormControl:d,bubbleInput:f}=Un(Gn,e),p=Te(r,s);return(0,J.jsx)(Ee.button,{type:`button`,role:`radio`,"aria-checked":i,"data-state":Xn(i),"data-disabled":a?``:void 0,disabled:a,value:o,...n,ref:p,onClick:Oe(t,e=>{i||(u(),c()),f&&d&&(l.current=e.isPropagationStopped(),l.current||e.stopPropagation())})})},`RadioTrigger`)),qn=`RadioBubbleInput`,Jn=q.forwardRef(Y(function({__scopeRadio:e,onClick:t,...n},r){let{control:i,checked:a,required:o,disabled:s,name:c,value:l,form:u,bubbleInput:d,setBubbleInput:f,hasConsumerStoppedPropagationRef:p,userInteractionCount:m}=Un(qn,e),h=Te(r,f),g=Fe(i),_=q.useRef(!1),v=q.useRef(a),y=q.useRef(m);q.useEffect(()=>{let e=d;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=m!==y.current;y.current=m;let i=v.current!==a;v.current=a;let o=!(r&&p.current);if(i&&n){_.current=!r;let t=new Event(`click`,{bubbles:o});n.call(e,a),e.dispatchEvent(t),_.current=!1}},[d,a,p,m]);let b=q.useRef(a);return(0,J.jsx)(Ee.input,{type:`radio`,"aria-hidden":!0,defaultChecked:b.current,required:o,disabled:s,name:c,value:l,form:u,...n,tabIndex:-1,ref:h,onClick:Oe(t,e=>{_.current&&e.stopPropagation()}),style:{...n.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`RadioBubbleInput`));function Yn(e){return typeof e==`function`}Y(Yn,`isFunction`);function Xn(e){return e?`checked`:`unchecked`}Y(Xn,`getState`);var Zn=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`],Qn=`RadioGroup`,[$n,er]=ke(Qn,[Le,Vn]),tr=Le(),nr=Vn(),[rr,ir]=$n(Qn),ar=q.forwardRef(Y(function(e,t){let{__scopeRadioGroup:n,name:r,form:i,defaultValue:a,value:o,required:s=!1,disabled:c=!1,orientation:l,dir:u,loop:d=!0,onValueChange:f,...p}=e,m=tr(n),h=Ae(u),[g,_]=De({prop:o,defaultProp:a??null,onChange:f,caller:Qn}),[v,y]=q.useState(null),b=Te(t,y),x=q.useRef(g);return q.useEffect(()=>{let e=i?v?.ownerDocument.getElementById(i):v?.closest(`form`);if(e instanceof HTMLFormElement){let t=Y(()=>_(x.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[v,i,_]),(0,J.jsx)(rr,{scope:n,name:r,form:i,required:s,disabled:c,value:g,onValueChange:_,children:(0,J.jsx)(Ie,{asChild:!0,...m,orientation:l,dir:h,loop:d,children:(0,J.jsx)(Ee.div,{role:`radiogroup`,"aria-required":s,"aria-orientation":l,"data-disabled":c?``:void 0,dir:h,...p,ref:b})})})},`RadioGroup`)),or=`RadioGroupItemProvider`,sr=`RadioGroupItemTrigger`;function cr(e){let{__scopeRadioGroup:t,value:n,disabled:r,children:i,internal_do_not_use_render:a}=e,o=ir(or,t),s=nr(t),c=o.disabled||r;return(0,J.jsx)(Wn,{...s,checked:o.value===n,disabled:c,required:o.required,name:o.name,form:o.form,value:n,onCheck:()=>o.onValueChange(n),internal_do_not_use_render:a,children:i})}Y(cr,`RadioGroupItemProvider`);var lr=q.forwardRef(Y(function(e,t){let{__scopeRadioGroup:n,...r}=e,i=tr(n),a=nr(n),{checked:o,disabled:s}=Un(sr,a.__scopeRadio),c=q.useRef(null),l=Te(t,c),u=q.useRef(!1);return q.useEffect(()=>{let e=Y(e=>{Zn.includes(e.key)&&(u.current=!0)},`handleKeyDown`),t=Y(()=>u.current=!1,`handleKeyUp`);return document.addEventListener(`keydown`,e),document.addEventListener(`keyup`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`keyup`,t)}},[]),(0,J.jsx)(Re,{asChild:!0,...i,focusable:!s,active:o,children:(0,J.jsx)(Kn,{...a,...r,ref:l,onKeyDown:Oe(r.onKeyDown,e=>{e.key===`Enter`&&e.preventDefault()}),onFocus:Oe(r.onFocus,()=>{u.current&&c.current?.click()})})})},`RadioGroupItemTrigger`)),ur=q.forwardRef(Y(function(e,t){let{__scopeRadioGroup:n,value:r,disabled:i,...a}=e;return(0,J.jsx)(cr,{__scopeRadioGroup:n,value:r,disabled:i,internal_do_not_use_render:({isFormControl:e})=>(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(lr,{...a,ref:t,__scopeRadioGroup:n}),e&&(0,J.jsx)(dr,{__scopeRadioGroup:n})]})})},`RadioGroupItem`)),dr=q.forwardRef(Y(function(e,t){let{__scopeRadioGroup:n,...r}=e,i=nr(n);return(0,J.jsx)(Jn,{...i,...r,ref:t})},`RadioGroupItemBubbleInput`));o.addResourceBundle(`zh-CN`,`labs`,{notice:`实验功能还在开发中,可能不稳定,也可能在之后的版本里调整或移除。每项单独开关,随时可以关掉;遇到问题请点「反馈」告诉我们。`,listTitle:`可试用的功能`,loading:`正在读取实验功能…`,loadFailed:`没能读取实验功能:{error}`,retry:`重试`,emptyTitle:`目前没有实验功能`,emptyDescription:`有新功能进入测试时,会出现在这里。`,"stage.experimental":`实验中`,"stage.preview":`即将毕业`,whenOffPrefix:`关掉后:`,feedback:`反馈`,toggleLabel:`开启或关闭“{name}”`,"saving.on":`正在开启…`,"saving.off":`正在关闭…`,enabledNow:`已开启,立即生效`,saveFailed:`没能保存:{error}。开关已恢复。`,"unavailable.runtime":`当前连接的 Runtime 不支持这个功能。升级那台机器上的 Pisper 后即可开启。`,openLinkFailed:`没能打开链接。`,"feature.bots.title":`Bots`,"feature.bots.description":`新建多个常驻的 Bot,在对话里交代事情;它们在自己的电脑上干活,改代码时用独立分支,改完交给你确认。`,"feature.bots.whenOff":`Bots 和它们的会话都不再显示;记录都保留,重新打开就回来。正在运行的任务会跑完。`}),o.addResourceBundle(`en-US`,`labs`,{notice:`Labs features are still in development. They may be unstable and may change or be removed in later versions. Each one has its own switch and can be turned off at any time; use Feedback to tell us about problems.`,listTitle:`Available to try`,loading:`Loading Labs features…`,loadFailed:`Couldn't load Labs features: {error}`,retry:`Retry`,emptyTitle:`No Labs features right now`,emptyDescription:`New features appear here when they enter testing.`,"stage.experimental":`Experimental`,"stage.preview":`Graduating soon`,whenOffPrefix:`When turned off: `,feedback:`Feedback`,toggleLabel:`Turn “{name}” on or off`,"saving.on":`Turning on…`,"saving.off":`Turning off…`,enabledNow:`On, effective immediately`,saveFailed:`Couldn't save: {error}. The switch was restored.`,"unavailable.runtime":`The connected Runtime doesn't support this feature. Update Pisper on that machine to turn it on.`,openLinkFailed:`Couldn't open the link.`,"feature.bots.title":`Bots`,"feature.bots.description":`Create several always-on Bots and tell them what to do in a chat. They work on their own computer, use a separate branch for code changes and hand the result to you to confirm.`,"feature.bots.whenOff":`Bots and their sessions are hidden everywhere; nothing is deleted, and turning it back on brings them back. Running tasks finish.`});function fr(e,t){if(typeof window>`u`||!window.__PISPER_MOBILE_APP__)return null;e.preventDefault();let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(`mobile_open_external_url`,{url:t}):Promise.reject(Error(`移动端原生桥不可用。`))}var pr={bots:e=>({title:e(`labs:feature.bots.title`),description:e(`labs:feature.bots.description`),whenOff:e(`labs:feature.bots.whenOff`)})};function mr(e,t){return pr[t]?.(e)??{title:t,description:``,whenOff:``}}function hr(e,t){return e(t===`preview`?`labs:stage.preview`:`labs:stage.experimental`)}function gr({notify:e}){let{t}=l(),n=Ft(e=>e.features),r=Ft(e=>e.status),i=Ft(e=>e.error),a=Ft(e=>e.pending),o=Ft(e=>e.rowErrors),s=Ft(e=>e.load),c=Ft(e=>e.setEnabled),[u,d]=(0,q.useState)(()=>new Set);(0,q.useEffect)(()=>{s()},[s]);let f=async(e,t)=>{await c(e,t);let n=Ft.getState(),r=!n.rowErrors[e]&&n.features.some(n=>n.id===e&&n.enabled===t);d(n=>{let i=new Set(n);return r&&t?i.add(e):i.delete(e),i})},p=n=>{fr(n,n.currentTarget.href)?.catch(()=>e(t(`labs:openLinkFailed`),`error`))},m;return m=r===`loading`&&n.length===0?(0,J.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 py-6 text-sm text-content-muted`,children:[(0,J.jsx)(nt,{"aria-hidden":`true`}),t(`labs:loading`)]}):n.length===0?r===`error`?null:(0,J.jsx)(At,{compact:!0,icon:re,title:t(`labs:emptyTitle`),description:t(`labs:emptyDescription`)}):(0,J.jsx)(H,{children:n.map(e=>{let n=mr(t,e.id),r=a[e.id]===!0,i=o[e.id];return(0,J.jsx)(V,{"data-beta-feature":e.id,"data-enabled":e.enabled,icon:(0,J.jsx)(re,{}),name:n.title,status:(0,J.jsx)(It,{variant:`outline`,children:hr(t,e.stage)}),description:n.description||void 0,actions:(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[r&&(0,J.jsxs)(`span`,{role:`status`,className:`flex items-center gap-1.5 text-xs text-content-muted`,children:[(0,J.jsx)(nt,{"aria-hidden":`true`}),e.enabled?t(`labs:saving.on`):t(`labs:saving.off`)]}),(0,J.jsx)(tt,{checked:e.enabled,disabled:r||!e.available,"aria-busy":r,"aria-label":t(`labs:toggleLabel`,{name:n.title}),onCheckedChange:t=>void f(e.id,t)})]}),detail:(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5 pb-3 text-xs leading-relaxed text-content-muted`,children:[n.whenOff&&(0,J.jsxs)(`p`,{children:[t(`labs:whenOffPrefix`),n.whenOff]}),e.feedbackUrl&&(0,J.jsxs)(`a`,{className:`inline-flex w-fit items-center gap-1 text-content-secondary underline decoration-stroke-strong underline-offset-3 hover:text-content`,href:e.feedbackUrl,target:`_blank`,rel:`noopener noreferrer`,"data-web-preview":`external`,onClick:p,children:[t(`labs:feedback`),(0,J.jsx)(P,{className:`size-3.5`,"aria-hidden":`true`})]}),!e.available&&(0,J.jsxs)(`p`,{className:`flex items-start gap-1.5 text-content-secondary`,children:[(0,J.jsx)(ae,{className:`mt-[3px] size-3.5 flex-none`,"aria-hidden":`true`}),t(`labs:unavailable.runtime`)]}),e.enabled&&u.has(e.id)&&!r&&(0,J.jsxs)(`p`,{role:`status`,className:`flex items-center gap-1.5 text-content-secondary`,children:[(0,J.jsx)(E,{className:`size-3.5 flex-none`,"aria-hidden":`true`}),t(`labs:enabledNow`)]}),i&&(0,J.jsx)(W,{className:`mt-1`,children:(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[t(`labs:saveFailed`,{error:i.message}),(0,J.jsx)(z,{size:`sm`,variant:`outline`,onClick:()=>void f(e.id,i.desired),children:t(`labs:retry`)})]})})]})},e.id)})}),(0,J.jsxs)(`div`,{"data-labs-settings":!0,className:`flex min-w-0 flex-col`,children:[(0,J.jsxs)(`p`,{role:`note`,className:`flex items-start gap-2 rounded-[var(--r-md)] bg-surface-subtle px-3 py-2.5 text-[13px] leading-relaxed text-content-secondary`,children:[(0,J.jsx)(re,{className:`mt-[3px] size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),t(`labs:notice`)]}),r===`error`&&(0,J.jsx)(W,{children:(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[t(`labs:loadFailed`,{error:i}),(0,J.jsx)(z,{size:`sm`,variant:`outline`,onClick:()=>void s(),children:t(`labs:retry`)})]})}),(0,J.jsx)(U,{title:t(`labs:listTitle`),count:n.length||void 0,children:m})]})}function _r({className:e,...t}){return(0,J.jsx)(Wt,{"data-settings-card":!0,className:L(`rounded-none border-x-0 border-t border-b-0 border-stroke-soft bg-transparent px-0`,e),...t})}var vr=Vt,yr=zt;function br(e){return(0,J.jsx)(Ut,{density:`compact`,...e})}function xr({className:e,...t}){return(0,J.jsx)(`div`,{"data-settings-group":!0,className:L(`@container/card min-w-0 divide-y divide-stroke-soft border-y border-stroke-soft`,e),...t})}function Sr({label:e,help:t,htmlFor:n,labelId:r,helpId:i,children:a,className:o}){return(0,J.jsxs)(`div`,{className:L(`grid min-w-0 gap-1.5 py-2.5 @min-[480px]/card:grid-cols-[168px_minmax(0,1fr)] @min-[480px]/card:items-center @min-[480px]/card:gap-4`,o),children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`label`,{id:r,htmlFor:n,className:`text-sm font-medium text-content`,children:e}),t&&(0,J.jsx)(`p`,{id:i,className:`mt-0.5 text-xs text-content-muted`,children:t})]}),(0,J.jsx)(`div`,{className:`min-w-0 @min-[480px]/card:max-w-[460px]`,children:a})]})}var Cr=`0.6.19`,wr=`https://github.com/ling-kong-ran/pisper`,Tr=`${wr}/blob/release/LICENSE`;function Er({href:e,icon:t,label:n,value:r,onClick:i}){return(0,J.jsxs)(`a`,{className:`group grid min-h-14 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-3 py-2.5 text-left no-underline`,href:e,target:`_blank`,rel:`noopener noreferrer`,"data-web-preview":`external`,onClick:i,children:[(0,J.jsx)(`span`,{className:`grid size-7.5 place-items-center rounded-md border border-key-border bg-key text-content-muted shadow-key transition-colors group-hover:text-content`,children:(0,J.jsx)(t,{size:16,"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block text-sm font-medium text-content`,children:n}),(0,J.jsx)(`span`,{className:`mt-0.5 block truncate font-mono text-xs text-content-muted`,children:r})]}),(0,J.jsx)(P,{"aria-hidden":`true`,className:`text-content-muted transition-colors group-hover:text-content`,size:14})]})}function Dr({update:e,notify:t}){let{t:n}=l(),r=e.info?.version||Cr,i=e=>{fr(e,e.currentTarget.href)?.catch(()=>t(n(`config:aboutSettings.openLinkFailed`),`error`))};return(0,J.jsxs)(`div`,{className:`mx-auto flex w-full flex-col gap-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 rounded-[15px] shadow-raise`,children:(0,J.jsx)(Gt,{size:56})}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`h2`,{className:`text-[length:calc(var(--ui-font-size)*10/7)] leading-[1.3] font-semibold tracking-[-.015em] text-content`,children:`Pisper`}),(0,J.jsxs)(yr,{tone:`gray`,className:`font-mono`,children:[`v`,r]})]}),(0,J.jsx)(`p`,{className:`mt-1 text-sm text-content-muted`,children:n(`config:aboutSettings.description`)})]})]}),(0,J.jsxs)(`section`,{"data-config-card":`about-project`,children:[(0,J.jsx)(vr,{title:n(`config:aboutSettings.projectInformation`),className:`mb-3 text-[15px] leading-6 font-medium text-content`}),(0,J.jsxs)(xr,{children:[(0,J.jsx)(Er,{href:wr,icon:j,label:n(`config:aboutSettings.sourceCode`),value:`github.com/ling-kong-ran/pisper`,onClick:i}),(0,J.jsx)(Er,{href:Tr,icon:kn,label:n(`config:aboutSettings.license`),value:`MIT License`,onClick:i})]})]}),(0,J.jsx)(_r,{className:`py-4`,"data-config-card":`about-support`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 max-[540px]:flex-col max-[540px]:items-stretch`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(vr,{title:n(`config:aboutSettings.supportPisper`)}),(0,J.jsx)(`p`,{className:`mt-0.5 max-w-[520px] text-xs leading-5 text-content-muted`,children:n(`config:aboutSettings.supportDescription`)})]}),(0,J.jsx)(z,{asChild:!0,className:`max-[650px]:h-11 max-[540px]:w-full`,children:(0,J.jsxs)(`a`,{href:wr,target:`_blank`,rel:`noopener noreferrer`,"data-web-preview":`external`,onClick:i,children:[(0,J.jsx)(Nn,{size:15}),n(`config:aboutSettings.starOnGitHub`)]})})]})}),(0,J.jsx)(`p`,{className:`text-center text-xs text-content-muted`,children:n(`config:aboutSettings.copyright`)})]})}function Or(e){window.dispatchEvent(new CustomEvent(`pisper:desktop-pet-changed`,{detail:e}))}function kr({notify:e,requestConfirm:t}){let{t:n}=l(),r=window.pisperDesktop,i=(0,q.useMemo)(()=>r?.getPetStatus?{getStatus:()=>r.getPetStatus(),setEnabled:e=>r.setPetEnabled(e),setOpacity:e=>r.setPetOpacity(e),search:e=>r.searchPets(e),install:e=>r.installPet(e),select:e=>r.selectPet(e),remove:e=>r.removePet(e),openCatalog:()=>void r.openPetdex?.()}:{getStatus:()=>f(`/api/desktop-pet`),setEnabled:e=>f(`/api/desktop-pet/enabled`,{method:`POST`,body:{enabled:e}}),setOpacity:e=>f(`/api/desktop-pet/opacity`,{method:`POST`,body:{opacity:e}}),search:e=>f(`/api/desktop-pet/catalog?query=${encodeURIComponent(e)}`),install:e=>f(`/api/desktop-pet/install`,{method:`POST`,body:{slug:e}}),select:e=>f(`/api/desktop-pet/select`,{method:`POST`,body:{slug:e}}),remove:e=>f(`/api/desktop-pet/${encodeURIComponent(e)}`,{method:`DELETE`}),openCatalog:()=>window.open(`https://petdex.dev`,`_blank`,`noopener,noreferrer`)},[r]),[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(``),[u,d]=(0,q.useState)([]),[p,m]=(0,q.useState)(100),[h,g]=(0,q.useState)(``),[_,v]=(0,q.useState)(``),y=(0,q.useCallback)(e=>{o(e),m(Math.round((e.opacity??1)*100))},[]),b=(0,q.useCallback)(async()=>{try{v(``),y(await i.getStatus())}catch(e){v(e instanceof Error?e.message:String(e))}},[y,i]),x=(0,q.useCallback)(async()=>{g(`search`);try{v(``),d(await i.search(s))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(``)}},[i,s]);(0,q.useEffect)(()=>{b(),i.search(``).then(d).catch(()=>{})},[i,b]);let S=async t=>{let r=a;o(e=>e&&{...e,enabled:t,running:!!(t&&e.installed.length)}),g(`toggle`);try{v(``);let r=await i.setEnabled(t);y(r),Or(r),e(n(t?`config:desktopPetSettings.petEnabled`:`config:desktopPetSettings.petDisabled`))}catch(e){o(r),v(e instanceof Error?e.message:String(e))}finally{g(``)}},C=async e=>{g(`opacity`);try{v(``);let t=await i.setOpacity(e);y(t),Or(t)}catch(e){m(Math.round((a?.opacity??1)*100)),v(e instanceof Error?e.message:String(e))}finally{g(``)}},w=async(t=s)=>{if(t.trim()){g(`install`);try{v(``);let r=await i.install(t);y(r),Or(r),e(n(`config:desktopPetSettings.petInstalled`,{name:r.selectedName||t}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(``)}}},T=async t=>{if(t!==a?.selectedSlug){g(`select:${t}`);try{v(``);let r=await i.select(t);y(r),Or(r),e(n(`config:desktopPetSettings.petSelected`,{name:r.selectedName||t}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(``)}}},D=async r=>{if(await t({title:n(`config:desktopPetSettings.deleteTitle`),message:n(`config:desktopPetSettings.deleteConfirm`,{name:r.name}),confirmLabel:n(`config:desktopPetSettings.delete`),tone:`danger`})){g(`remove:${r.slug}`);try{v(``);let t=await i.remove(r.slug);y(t),Or(t),e(n(`config:desktopPetSettings.petRemoved`,{name:r.name}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(``)}}};return(0,J.jsxs)(J.Fragment,{children:[_&&(0,J.jsx)(W,{children:_}),(0,J.jsx)(U,{title:n(`config:desktopPetSettings.displayTitle`),"data-config-card":`desktop-pet-settings`,children:a?(0,J.jsxs)(H,{children:[(0,J.jsx)(V,{icon:(0,J.jsx)(xn,{}),name:n(`config:desktopPetSettings.showOnDesktop`),description:a.selectedName?n(`config:desktopPetSettings.currentPet`,{name:a.selectedName}):n(`config:desktopPetSettings.installBeforeEnabling`),status:(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[a.running&&(0,J.jsx)(yt,{status:`done`,className:`size-3.5`}),a.running?n(`config:desktopPetSettings.running`):n(`config:desktopPetSettings.stopped`)]}),actions:(0,J.jsx)(tt,{checked:a.enabled,disabled:!!h||!a.installed.length,onCheckedChange:e=>void S(e),"aria-label":n(`config:desktopPetSettings.showOnDesktop`)})}),(0,J.jsx)(V,{icon:(0,J.jsx)(bn,{}),name:n(`config:desktopPetSettings.opacity`),nameMeta:`${p}%`,actions:(0,J.jsx)(et,{value:[p],min:20,max:100,step:5,disabled:h===`opacity`,onValueChange:([e])=>m(e),onValueCommit:([e])=>void C(e/100),"aria-label":n(`config:desktopPetSettings.opacity`),className:`w-44 max-w-full max-[650px]:w-32`})})]}):(0,J.jsx)(Ot,{kind:`loading`,title:n(`config:desktopPetSettings.loading`)})}),(0,J.jsxs)(U,{title:n(`config:desktopPetSettings.installTitle`),"data-config-card":`desktop-pet-install`,description:n(`config:desktopPetSettings.installDescription`),actions:(0,J.jsxs)(z,{variant:`ghost`,size:`sm`,onClick:i.openCatalog,children:[(0,J.jsx)(P,{}),n(`config:desktopPetSettings.browsePetdex`)]}),children:[(0,J.jsxs)(`div`,{className:`mb-3 flex gap-2`,children:[(0,J.jsx)(B,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&x()},placeholder:n(`config:desktopPetSettings.searchPlaceholder`),"aria-label":n(`config:desktopPetSettings.petSlug`),className:`h-9 min-w-0 flex-1 font-mono pointer-coarse:min-h-11 max-[650px]:min-h-11`}),(0,J.jsxs)(z,{variant:`secondary`,className:`h-9 shrink-0 pointer-coarse:h-11 max-[650px]:h-11`,disabled:h===`search`,onClick:x,children:[h===`search`?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(he,{}),n(`config:desktopPetSettings.search`)]})]}),u.length>0&&(0,J.jsx)(H,{children:u.map(e=>{let t=a?.installed.some(t=>t.slug===e.slug);return(0,J.jsx)(V,{"data-pet-catalog":e.slug,icon:(0,J.jsx)(xn,{}),name:e.displayName,nameMeta:e.slug,status:t?n(`config:desktopPetSettings.installed`):void 0,actions:(0,J.jsxs)(z,{size:`sm`,variant:t?`ghost`:`secondary`,disabled:!!h||t&&e.slug===a?.selectedSlug,"aria-label":`${n(t?`config:desktopPetSettings.use`:`config:desktopPetSettings.install`)}: ${e.displayName}`,onClick:()=>void(t?T(e.slug):w(e.slug)),children:[t?(0,J.jsx)(E,{}):(0,J.jsx)(ee,{}),n(t?`config:desktopPetSettings.use`:`config:desktopPetSettings.install`)]})},e.slug)})})]}),a&&a.installed.length>0&&(0,J.jsx)(U,{title:n(`config:desktopPetSettings.installedTitle`),count:a.installed.length,"data-config-card":`desktop-pet-installed`,description:n(`config:desktopPetSettings.installedDescription`),children:(0,J.jsx)(H,{children:a.installed.map(e=>{let t=e.slug===a.selectedSlug;return(0,J.jsx)(V,{"data-pet-installed":e.slug,"data-selected":t||void 0,className:L(`relative`,t&&`after:absolute after:inset-y-3 after:-left-3 after:w-[3px] after:rounded-full after:bg-star`),icon:(0,J.jsx)(xn,{}),name:e.name,nameMeta:`${e.slug} · ${e.source===`pisper`?`Pisper`:`Petdex`}`,status:t?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,J.jsx)(yt,{status:`done`,className:`size-3.5`}),n(`config:desktopPetSettings.inUse`)]}):void 0,actions:(0,J.jsxs)(J.Fragment,{children:[!t&&(0,J.jsx)(z,{size:`sm`,variant:`ghost`,disabled:!!h,"aria-label":`${n(`config:desktopPetSettings.use`)}: ${e.name}`,onClick:()=>void T(e.slug),children:n(`config:desktopPetSettings.use`)}),e.source===`pisper`&&(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`hover:bg-danger-soft hover:text-danger max-[650px]:size-11 pointer-coarse:size-11`,disabled:!!h,onClick:()=>void D(e),"aria-label":`${n(`config:desktopPetSettings.delete`)}: ${e.name}`,title:n(`config:desktopPetSettings.delete`),children:h===`remove:${e.slug}`?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(be,{})})]})},`${e.source}:${e.slug}`)})})})]})}function X(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function Ar(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}var jr,Z,Mr,Nr,Pr=`__TAURI_TO_IPC_KEY__`;function Fr(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}var Ir=class{constructor(e){jr.set(this,void 0),Z.set(this,0),Mr.set(this,[]),Nr.set(this,void 0),Ar(this,jr,e||(()=>{}),`f`),this.id=Fr(e=>{let t=e.index;if(`end`in e){t==X(this,Z,`f`)?this.cleanupCallback():Ar(this,Nr,t,`f`);return}let n=e.message;if(t==X(this,Z,`f`)){for(X(this,jr,`f`).call(this,n),Ar(this,Z,X(this,Z,`f`)+1,`f`);X(this,Z,`f`)in X(this,Mr,`f`);){let e=X(this,Mr,`f`)[X(this,Z,`f`)];X(this,jr,`f`).call(this,e),delete X(this,Mr,`f`)[X(this,Z,`f`)],Ar(this,Z,X(this,Z,`f`)+1,`f`)}X(this,Z,`f`)===X(this,Nr,`f`)&&this.cleanupCallback()}else X(this,Mr,`f`)[t]=n})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){Ar(this,jr,e,`f`)}get onmessage(){return X(this,jr,`f`)}[(jr=new WeakMap,Z=new WeakMap,Mr=new WeakMap,Nr=new WeakMap,Pr)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[Pr]()}};function Lr(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function Rr(e,t){return Lr(`plugin:barcode-scanner|${e}`,t)}function zr(e){return e instanceof Error?e.message:String(e)}function Br(e){return/cancel(?:led|ed)/i.test(zr(e))}function Vr(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function Hr(e){return Array.isArray(e)?new TextDecoder().decode(Uint8Array.from(e)):``}function Ur(e){if(!e.isActive||!e.port)return null;let t=Hr(e.txt.fp);if(!/^SHA256:[0-9A-F]{64}$/i.test(t))return null;let n=e.addresses.find(e=>/^\d{1,3}(?:\.\d{1,3}){3}$/.test(e))||e.addresses.find(e=>e.includes(`:`));if(!n)return null;let r=n.includes(`:`)?`[${n}]`:n,i=Hr(e.txt.name)||e.name||`Pisper Desktop`,a=`https://${r}:${e.port}`;return{id:`${e.fullName}:${a}`,name:i,url:a,fingerprint:t}}function Wr(e){return new Promise(t=>window.setTimeout(t,e))}function Gr({open:e,onOpenChange:t}){let{t:n}=l(),r=jt(e),[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(!1),[c,u]=(0,q.useState)([]),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(``),[h,g]=(0,q.useState)(``),[_,v]=(0,q.useState)(``),y=(0,q.useRef)(!1),x=(0,q.useRef)(!1),S=(0,q.useRef)(!1),C=(0,q.useRef)(0),w=(0,q.useRef)(``),T=(0,q.useCallback)(e=>{y.current=e,s(e)},[]),E=(0,q.useCallback)(async()=>{x.current=!0,y.current&&await Rr(`cancel`).catch(()=>void 0),T(!1),a(null)},[T]);(0,q.useEffect)(()=>{if(!o)return;let e=document.getElementById(`root`),t=[],n=(e,n,r)=>{e&&(t.push({element:e,property:n,value:e.style.getPropertyValue(n),priority:e.style.getPropertyPriority(n)}),e.style.setProperty(n,r,`important`))};return n(document.documentElement,`background`,`transparent`),n(document.body,`background`,`transparent`),n(e,`background`,`transparent`),n(e,`visibility`,`hidden`),()=>{for(let{element:e,property:n,value:r,priority:i}of t.reverse())r?e.style.setProperty(n,r,i):e.style.removeProperty(n)}},[o]),(0,q.useEffect)(()=>{if(!o)return;let e=`pisper-scanner-${Date.now()}`;window.history.pushState({...window.history.state,pisperScanner:e},``);let t=()=>void E();return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),!S.current&&window.history.state?.pisperScanner===e&&window.history.back()}},[E,o]);let D=e=>{if(!e.proxyUrl)throw Error(n(`config:mobileServer.pairFailed`));window.location.replace(e.proxyUrl)},O=(0,q.useCallback)(async()=>{let e=++C.current;f(!0),m(``),u([]);let t=new Ir;t.onmessage=t=>{if(C.current!==e)return;if(t.reason===`permission-denied`){m(n(`config:mobileServer.localNetworkDenied`));return}if(t.reason?.startsWith(`error:`)){m(n(`config:mobileServer.discoveryFailed`));return}if(!t.service)return;if(!t.service.isActive){u(e=>e.filter(e=>!e.id.startsWith(`${t.service?.fullName}:`)));return}let r=Ur(t.service);r&&u(e=>[...e.filter(e=>e.fingerprint!==r.fingerprint),r])};let r=null;try{await Lr(`mobile_ensure_local_network_permission`),r=(await Lr(`plugin:dns-sd|browse_start`,{options:{service:{type:`pisper`,protocol:`tcp`,domain:`local`},timeoutMs:4e3},channel:t})).browseId,await Wr(4300)}catch(t){C.current===e&&m(zr(t).includes(`local_network_permission_denied`)?n(`config:mobileServer.localNetworkDenied`):n(`config:mobileServer.discoveryFailed`))}finally{r!==null&&await Lr(`plugin:dns-sd|browse_stop`,{browseId:r}).catch(()=>void 0),C.current===e&&f(!1)}},[n]);(0,q.useEffect)(()=>{if(!(!e||o))return O(),()=>{C.current+=1}},[O,e,o]);let k=(0,q.useCallback)(async()=>{let e=w.current;w.current=``,e&&await Lr(`mobile_cancel_lan_pairing`,{operationId:e}).catch(()=>void 0),a(null),g(``)},[]),A=async e=>{let t=globalThis.crypto?.randomUUID?.()||`lan-${Date.now()}-${Math.random().toString(16).slice(2)}`;w.current=t,a(`lan:${e.id}`),v(``),g(n(`config:mobileServer.awaitingApproval`,{name:e.name}));try{let n=await Lr(`mobile_pair_lan`,{operationId:t,name:e.name,url:e.url,fingerprint:e.fingerprint,deviceName:null});if(w.current!==t)return;D(n)}catch(e){w.current===t&&v(zr(e))}finally{w.current===t&&(w.current=``,a(null),g(``))}},j=async()=>{x.current=!1,S.current=!1,a(`scan`),v(``);try{let e=await Rr(`check_permissions`);if(e.camera!==`granted`&&(e=await Rr(`request_permissions`)),e.camera!==`granted`)throw Error(n(`config:mobileServer.cameraDenied`));if(x.current||(T(!0),await Vr(),x.current))return;let t=await Rr(`scan`,{windowed:!0,formats:[]});if(!t.content)throw Error(n(`config:mobileServer.scanFailed`));S.current=!0,D(await Lr(`mobile_pair`,{payloadJson:t.content,deviceName:null}))}catch(e){!x.current&&!Br(e)&&v(zr(e))}finally{T(!1),a(null),x.current=!1}};return(0,J.jsx)(Tt,{open:e,onOpenChange:e=>{if(!e&&o){E();return}if(!e&&i?.startsWith(`lan:`)){k(),t(!1);return}i||(e||v(``),t(e))},children:(0,J.jsx)(xt,{showCloseButton:!o,overlayClassName:o?`bg-transparent supports-backdrop-filter:backdrop-blur-none`:void 0,className:o?`inset-0 top-0 left-0 h-dvh max-h-none w-screen max-w-none translate-x-0 translate-y-0 gap-0 overflow-hidden rounded-none bg-transparent p-0 text-white ring-0 sm:max-w-none`:`sm:max-w-md`,onPointerDownOutside:o?e=>e.preventDefault():void 0,onCloseAutoFocus:r,children:o?(0,J.jsxs)(`div`,{className:`flex h-dvh w-screen flex-col overflow-hidden`,children:[(0,J.jsxs)(wt,{className:`sr-only`,children:[(0,J.jsx)(St,{children:n(`config:mobileServer.scanTitle`)}),(0,J.jsx)(bt,{children:n(`config:mobileServer.scanHint`)})]}),(0,J.jsxs)(`header`,{className:`flex min-h-16 items-center justify-between gap-3 bg-black/60 px-4 pb-3`,style:{paddingTop:`max(env(safe-area-inset-top), 0.75rem)`},children:[(0,J.jsxs)(z,{variant:`ghost`,className:`h-10 bg-black/40 px-3 text-white hover:bg-black/70 hover:text-white`,onClick:()=>void E(),children:[(0,J.jsx)(b,{}),n(`config:mobileServer.cancelScan`)]}),(0,J.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium`,children:n(`config:mobileServer.scanTitle`)}),(0,J.jsx)(`div`,{className:`w-[88px]`,"aria-hidden":`true`})]}),(0,J.jsx)(`main`,{className:`grid min-h-0 flex-1 place-items-center p-6`,children:(0,J.jsx)(`div`,{className:`relative aspect-square w-[min(72vw,20rem)] rounded-md border-2 border-white/90 shadow-[0_0_0_9999px_rgba(0,0,0,0.18)]`,children:(0,J.jsx)(An,{className:`absolute top-1/2 left-1/2 size-10 -translate-x-1/2 -translate-y-1/2 text-white/75`})})}),(0,J.jsxs)(`footer`,{className:`flex flex-col items-center gap-3 bg-black/60 px-5 pt-4 text-center`,style:{paddingBottom:`max(env(safe-area-inset-bottom), 1rem)`},children:[(0,J.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-white/90`,children:n(`config:mobileServer.scanHint`)}),(0,J.jsx)(z,{variant:`outline`,className:`w-full max-w-sm border-white/50 bg-black/30 text-white hover:bg-black/60 hover:text-white`,onClick:()=>void E(),children:n(`config:mobileServer.cancelScan`)})]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(wt,{children:[(0,J.jsx)(St,{children:n(`config:mobileServer.addServer`)}),(0,J.jsx)(bt,{children:n(`config:mobileServer.discoverDescription`)})]}),(0,J.jsxs)(`section`,{className:`grid gap-2`,"aria-live":`polite`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,J.jsx)(On,{className:`size-4`}),n(`config:mobileServer.nearby`)]}),(0,J.jsx)(z,{size:`icon-sm`,variant:`ghost`,disabled:d||i!==null,className:`pointer-coarse:size-11`,"aria-label":n(`config:mobileServer.rediscover`),onClick:()=>void O(),children:(0,J.jsx)(fe,{className:d?`animate-spin`:void 0})})]}),c.length?(0,J.jsx)(`ul`,{className:`m-0 grid max-h-44 list-none divide-y divide-stroke-soft overflow-y-auto border-y border-stroke-soft p-0`,children:c.map(e=>{let t=i===`lan:${e.id}`;return(0,J.jsxs)(`li`,{className:`flex min-h-12 items-center justify-between gap-3 py-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(ge,{className:`size-4 flex-none text-muted-foreground`}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`truncate text-sm`,children:e.name}),(0,J.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.url})]})]}),(0,J.jsxs)(z,{size:`sm`,className:`pointer-coarse:min-h-11`,disabled:i!==null,onClick:()=>void A(e),children:[t?(0,J.jsx)(F,{className:`animate-spin`}):null,n(`config:mobileServer.requestConnect`)]})]},e.id)})}):(0,J.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:n(d?`config:mobileServer.discovering`:`config:mobileServer.noNearby`)}),p?(0,J.jsx)(`p`,{role:`alert`,className:`text-xs leading-relaxed text-content-secondary`,children:p}):null,h?(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-[var(--r-md)] bg-surface-subtle px-3 py-2`,children:[(0,J.jsx)(`p`,{role:`status`,className:`text-xs leading-relaxed`,children:h}),(0,J.jsx)(z,{size:`sm`,variant:`outline`,className:`pointer-coarse:min-h-11`,onClick:()=>void k(),children:n(`config:mobileServer.cancelRequest`)})]}):null]}),(0,J.jsxs)(`div`,{className:`relative py-1`,children:[(0,J.jsx)($e,{}),(0,J.jsx)(`span`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-popover px-2 text-xs text-muted-foreground`,children:n(`config:mobileServer.otherMethods`)})]}),(0,J.jsxs)(z,{className:`w-full pointer-coarse:min-h-11`,disabled:i!==null,onClick:()=>void j(),children:[i===`scan`?(0,J.jsx)(F,{className:`animate-spin`}):(0,J.jsx)(Dn,{}),n(`config:mobileServer.scan`)]}),_?(0,J.jsx)(`p`,{role:`alert`,className:`text-xs leading-relaxed text-content-secondary`,children:_}):null]})})})}function Kr(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function qr({requestConfirm:e}){let{t}=l(),[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(``),[c,u]=(0,q.useState)(!1),d=(0,q.useCallback)(async()=>{try{r(await Kr(`mobile_state`)),a(``)}catch{a(t(`config:mobileServer.loadFailed`))}},[t]);(0,q.useEffect)(()=>{d()},[d]);let f=async(e,t,n=``)=>{s(n||e);try{r(await Kr(e,t)),a(``)}catch(e){a(String(e))}finally{s(``)}},p=async n=>{o||await e({title:t(`config:mobileServer.forget`),message:t(`config:mobileServer.forgetConfirm`),confirmLabel:t(`config:mobileServer.forget`),tone:`danger`})&&await f(`mobile_forget_server`,{id:n.id},n.id)},m=async e=>{s(e);try{let t=await Kr(`mobile_select_server`,{id:e});r(t),a(``),t.proxyUrl&&window.location.replace(t.proxyUrl)}catch(e){a(String(e))}finally{s(``)}},h=n?.mode===`local`,g=n?.mode===`remote`&&!!n.activeId,_=h||g,v=t(h?`config:mobileServer.currentLocal`:g?`config:mobileServer.current`:`config:mobileServer.empty`),y=e=>t(e===`iroh`?`config:mobileServer.transportP2p`:`config:mobileServer.transportLan`);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mt-5 flex min-h-11 items-center gap-2 rounded-[var(--r-md)] border border-stroke bg-surface-subtle px-3 py-2 text-xs text-content-secondary`,role:`status`,"aria-live":`polite`,children:[_?(0,J.jsx)(yt,{status:`done`,className:`size-3.5`}):(0,J.jsx)(k,{className:`size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:v}),n?.activeTransport?(0,J.jsx)(`span`,{className:`flex-none font-mono text-xs text-content-muted`,children:y(n.activeTransport)}):null]}),(0,J.jsx)(Gr,{open:c,onOpenChange:u}),i?(0,J.jsx)(W,{className:`mt-3`,children:i}):null,(0,J.jsx)(U,{title:t(`config:mobileServer.localTitle`),"data-config-card":`mobile-server-local`,children:(0,J.jsx)(H,{children:(0,J.jsx)(V,{icon:(0,J.jsx)(Mn,{}),name:t(`config:mobileServer.localTitle`),description:t(`config:mobileServer.localDescription`),status:h?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,J.jsx)(yt,{status:`done`,className:`size-3.5`}),t(`config:mobileServer.currentLocal`)]}):void 0,actions:h?void 0:(0,J.jsx)(z,{size:`sm`,variant:`secondary`,className:`flex-none max-[650px]:h-11 max-[650px]:px-3 pointer-coarse:h-11`,disabled:!!o,onClick:()=>void(async()=>{s(`mobile_enter_local`);try{let e=await Kr(`mobile_enter_local`);e.onDevice.url&&window.location.replace(e.onDevice.url)}catch(e){a(String(e))}finally{s(``)}})(),children:t(`config:mobileServer.enterLocal`)})})})}),(0,J.jsx)(U,{title:t(`config:mobileServer.title`),count:n?.servers?.length??0,"data-config-card":`mobile-server-main`,description:t(`config:mobileServer.description`),actions:(0,J.jsxs)(z,{size:`sm`,onClick:()=>u(!0),children:[(0,J.jsx)(de,{}),t(`config:mobileServer.addServer`)]}),children:n?.servers?.length?(0,J.jsx)(H,{children:n.servers.map(e=>{let r=n.mode===`remote`&&e.id===n.activeId,i=e.endpoints.find(e=>e.url),a=e.endpoints.find(e=>e.t===`iroh`),s=i?.url||(a?.nodeId?`Iroh ${a.nodeId.slice(0,12)}`:`Iroh`);return(0,J.jsx)(V,{"data-mobile-server":e.id,icon:(0,J.jsx)(ge,{}),name:e.name,nameMeta:t(i&&a?`config:mobileServer.transportLanP2p`:a?`config:mobileServer.transportP2p`:`config:mobileServer.transportLan`),description:(0,J.jsx)(`span`,{className:`font-mono`,children:s}),status:r?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,J.jsx)(yt,{status:`done`,className:`size-3.5`}),n.activeTransport?t(`config:mobileServer.activeTransport`,{transport:y(n.activeTransport)}):t(`config:mobileServer.current`)]}):void 0,actions:(0,J.jsxs)(J.Fragment,{children:[r?null:(0,J.jsx)(z,{size:`sm`,variant:`ghost`,disabled:o===e.id,onClick:()=>void m(e.id),children:t(`config:mobileServer.connect`)}),(0,J.jsx)(z,{size:`icon-sm`,variant:`ghost`,className:`hover:bg-danger-soft hover:text-danger max-[650px]:size-11 pointer-coarse:size-11`,"aria-label":t(`config:mobileServer.forget`),title:t(`config:mobileServer.forget`),disabled:!!o,onClick:()=>void p(e),children:(0,J.jsx)(be,{})})]})},e.id)})}):(0,J.jsx)(At,{compact:!0,title:t(`config:mobileServer.empty`)})})]})}o.addResourceBundle(`zh-CN`,`remote-workspace`,{description:`使用本机的 Pisper 界面,在另一台 Linux 上运行会话、读写文件和执行任务。`,instructions:`先在 Linux 上运行 Pisper,在「设置 → 远程访问」启用连接,然后复制 HTTPS 地址、证书指纹和配对码。请通过可信渠道核对指纹。`,isolation:`每个工作区在独立窗口中打开。会话、文件、模型配置与任务属于远程机器,不会复制本机密钥;关闭窗口不会停止远程正在执行的任务。本机终端与桌面控制不会在远程窗口中启用。`,refresh:`刷新远程工作区`,name:`工作区名称(可选)`,address:`Linux HTTPS 地址`,fingerprint:`证书指纹`,code:`配对码`,pair:`配对并打开`,open:`连接`,show:`显示窗口`,forget:`移除 {name}`,forgetDescription:`这会关闭该工作区的本机窗口并移除保存的连接,不删除远程文件或会话,也不会停止远程任务。如需吊销设备授权,请在 Linux 的远程访问页操作。`,activeTitle:`当前为远程工作区`,activeDescription:`这里的会话、文件和模型设置属于远程 Linux。连接管理请回到本机主窗口;如需修改远程访问服务,请在 Linux 本机操作。`,manualConnection:`手动连接所需信息`,serverAddress:`HTTPS 服务器地址`}),o.addResourceBundle(`en-US`,`remote-workspace`,{description:`Use the local Pisper interface to run conversations, work with files, and execute tasks on another Linux machine.`,instructions:`Run Pisper on Linux and enable Settings → Remote access. Copy its HTTPS address, certificate fingerprint, and pairing code. Verify the fingerprint through a trusted channel.`,isolation:`Each workspace opens in a separate window. Sessions, files, model settings, and tasks belong to the remote machine; local credentials are not copied. Closing the window does not stop remote tasks. Local terminals and desktop controls are not enabled in remote windows.`,refresh:`Refresh remote workspaces`,name:`Workspace name (optional)`,address:`Linux HTTPS address`,fingerprint:`Certificate fingerprint`,code:`Pairing code`,pair:`Pair and open`,open:`Connect`,show:`Show window`,forget:`Remove {name}`,forgetDescription:`Close this workspace’s local windows and forget the saved connection. Remote files, sessions, and running tasks are not deleted or stopped. To revoke the device authorization, use Remote access on Linux.`,activeTitle:`Remote workspace`,activeDescription:`Sessions, files and model settings in this window belong to the remote Linux machine. Manage connections in your local main window; change remote access service settings directly on Linux.`,manualConnection:`Manual connection details`,serverAddress:`HTTPS server address`});function Jr({notify:e}){let{t,language:n}=l(),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)([]),[u,d]=(0,q.useState)([]),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(``),[y,b]=(0,q.useState)(``),[x,S]=(0,q.useState)(!1),[C,w]=(0,q.useState)(``),T=(0,q.useCallback)(async()=>{try{let[e,t,n,r]=await Promise.all([f(`/api/remote/status`),f(`/api/remote/devices`),f(`/api/remote/pairing-requests`).catch(()=>({requests:[]})),f(`/api/remote/firewall`).catch(e=>{if(e&&typeof e==`object`&&`status`in e&&e.status===403)return null;throw e})]);i(e),o(r),c(t.devices.filter(e=>!e.revokedAt)),d(n.requests),w(``)}catch{w(t(`config:remoteAccess.loadFailed`))}},[t]);(0,q.useEffect)(()=>{T()},[T]),(0,q.useEffect)(()=>{if(!r?.listening)return;let e=window.setInterval(()=>void T(),2e3);return()=>window.clearInterval(e)},[T,r?.listening]);let D=async n=>{S(!0);try{await f(`/api/remote/enabled`,{method:`PUT`,body:{enabled:n,configureFirewall:a!==null},timeout:15e4});let e=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;e&&await e(`desktop_iroh_set_enabled`,{enabled:n}).catch(()=>void 0),n||(m(null),g(!1),v(``)),await T()}catch(n){e(t(`config:remoteAccess.toggleFailed`,{message:String(n)}),`error`)}finally{S(!1)}},O=async()=>{S(!0);try{await f(`/api/remote/firewall/retry`,{method:`POST`,body:{},timeout:15e4}),await T()}catch(n){e(t(`config:remoteAccess.firewallRetryFailed`,{message:String(n)}),`error`)}finally{S(!1)}},k={disabled:t(`config:remoteAccess.firewallDisabled`),configured:t(`config:remoteAccess.firewallConfigured`),not_needed:t(`config:remoteAccess.firewallNotNeeded`),needs_authorization:t(`config:remoteAccess.firewallNeedsAuthorization`),unsupported:t(`config:remoteAccess.firewallUnsupported`),cancelled:t(`config:remoteAccess.firewallCancelled`),error:t(`config:remoteAccess.firewallError`),cleanup_pending:t(`config:remoteAccess.firewallCleanupPending`)},A={packaged_app_required:t(`config:remoteAccess.firewallPackagedApp`),unsupported_firewall:t(`config:remoteAccess.firewallUnsupportedBackend`),unsupported_platform:t(`config:remoteAccess.firewallUnsupportedBackend`),permission_denied:t(`config:remoteAccess.firewallPermissionDenied`),cancelled:t(`config:remoteAccess.firewallCancelled`),timeout:t(`config:remoteAccess.firewallTimeout`),block_all:t(`config:remoteAccess.firewallBlockAll`),rule_changed:t(`config:remoteAccess.firewallRuleChanged`),inspection_failed:t(`config:remoteAccess.firewallVerificationFailed`),verification_failed:t(`config:remoteAccess.firewallVerificationFailed`),operation_failed:t(`config:remoteAccess.firewallVerificationFailed`),unsupported:t(`config:remoteAccess.firewallUnsupportedBackend`)},j=async()=>{S(!0),v(``);try{let e=await f(`/api/remote/pairing-code`,{method:`POST`});if(!e?.code||!e?.expiresAt)throw Error(t(`config:remoteAccess.qrUnavailable`));e.connectionInfo=await f(`/api/remote/connection-info`).catch(()=>void 0),m(e),g(!0),e.qrDataUrl||v(t(`config:remoteAccess.qrUnavailable`))}catch(n){let r=t(`config:remoteAccess.pairingFailed`,{message:String(n)});v(r),e(r,`error`)}finally{S(!1)}},M=async(n,r)=>{b(n.id);try{await f(`/api/remote/pairing-requests/${encodeURIComponent(n.id)}/decision`,{method:`POST`,body:{approved:r}}),await T()}catch(n){e(t(`config:remoteAccess.approvalFailed`,{message:String(n)}),`error`)}finally{b(``)}},ee=async n=>{if(window.confirm(t(`config:remoteAccess.revokeConfirm`,{name:n.name})))try{await f(`/api/remote/devices/${encodeURIComponent(n.id)}/revoke`,{method:`POST`}),await T()}catch(n){e(t(`config:remoteAccess.revokeFailed`,{message:String(n)}),`error`)}};if(C&&!r)return(0,J.jsx)(Ot,{kind:`error`,title:t(`config:remoteAccess.loadFailed`),action:(0,J.jsxs)(z,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void T(),children:[(0,J.jsx)(fe,{}),t(`config:remoteAccess.refresh`)]})});if(!r)return(0,J.jsx)(Ot,{kind:`loading`,title:t(`config:remoteAccess.loading`)});let N=r.error?`failed`:r.listening?`on`:r.enabled?`starting`:`off`,P=a!==null&&!a.busy&&[`needs_authorization`,`cancelled`,`error`,`cleanup_pending`].includes(a.state);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Tt,{open:h&&p!==null,onOpenChange:g,children:(0,J.jsxs)(xt,{className:`sm:max-w-md`,children:[(0,J.jsxs)(wt,{children:[(0,J.jsx)(St,{children:t(`config:remoteAccess.pairingQrTitle`)}),(0,J.jsx)(bt,{children:t(`config:remoteAccess.scanQrDescription`)})]}),(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-2`,"aria-live":`polite`,children:[p?.qrDataUrl?(0,J.jsx)(`img`,{src:p.qrDataUrl,alt:t(`config:remoteAccess.qrAlt`),className:`size-64 max-w-full rounded-sm border border-stroke bg-white p-2`}):null,_?(0,J.jsx)(`p`,{role:`alert`,className:`text-center text-xs leading-relaxed text-content-secondary`,children:_}):null,p?(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsx)(`div`,{className:`font-mono text-[20px] font-medium tracking-[0.2em] text-content`,children:p.code}),(0,J.jsx)(`div`,{className:`mt-1 text-xs text-content-muted tabular-nums`,children:t(`config:remoteAccess.codeExpiresAt`,{time:vt(p.expiresAt,n)})})]}):null]}),p?.connectionInfo&&(0,J.jsxs)(`details`,{className:`min-w-0 rounded-md border border-stroke px-3 py-2 text-sm`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer text-content-secondary`,children:t(`remote-workspace:manualConnection`)}),(0,J.jsxs)(`div`,{className:`mt-2 space-y-2 text-xs text-content-muted`,children:[(0,J.jsx)(`div`,{children:t(`remote-workspace:serverAddress`)}),p.connectionInfo.endpoints.map(e=>(0,J.jsx)(`code`,{className:`block font-mono break-all text-content select-all`,children:e.url},e.url)),(0,J.jsx)(`div`,{children:t(`remote-workspace:fingerprint`)}),(0,J.jsx)(`code`,{className:`block font-mono break-all text-content select-all`,children:p.connectionInfo.fingerprint})]})]}),(0,J.jsx)(Ct,{children:(0,J.jsxs)(z,{disabled:x,onClick:()=>void j(),children:[x?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(fe,{}),t(x?`config:remoteAccess.generatingQr`:`config:remoteAccess.regenerate`)]})})]})}),C&&(0,J.jsx)(W,{children:C}),(0,J.jsx)(U,{title:t(`config:remoteAccess.thisComputer`),"data-config-card":`remote-access-main`,children:(0,J.jsxs)(H,{children:[(0,J.jsx)(V,{icon:(0,J.jsx)(se,{}),name:t(`config:remoteAccess.allowConnections`),description:t(`config:remoteAccess.description`),status:(0,J.jsx)(Yr,{attention:N===`failed`,glyph:N===`on`?`done`:N===`starting`?`run`:null,children:t(N===`failed`?`config:remoteAccess.stateFailed`:N===`on`?`config:remoteAccess.stateListening`:N===`starting`?`config:remoteAccess.stateStarting`:`config:remoteAccess.stateOff`)}),actions:(0,J.jsx)(tt,{checked:r.enabled,disabled:x,onCheckedChange:e=>void D(e),"aria-label":t(`config:remoteAccess.title`)}),detail:r.error?(0,J.jsx)(`p`,{className:`text-xs leading-relaxed [overflow-wrap:anywhere] text-st-attn`,children:t(`config:remoteAccess.listenFailed`,{message:r.error})}):void 0}),a?(0,J.jsx)(V,{"aria-live":`polite`,icon:(0,J.jsx)(_e,{}),name:t(`config:remoteAccess.firewallTitle`),description:a.busy?t(`config:remoteAccess.firewallWorking`):k[a.state],status:a.busy?(0,J.jsx)(Yr,{glyph:`run`,children:t(`config:remoteAccess.firewallChecking`)}):P?(0,J.jsx)(Yr,{attention:!0,children:t(`config:remoteAccess.firewallNeedsYou`)}):void 0,actions:r.enabled||a.state===`cleanup_pending`?(0,J.jsxs)(z,{size:`sm`,variant:`secondary`,disabled:x||a.busy,onClick:()=>void O(),children:[x||a.busy?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(fe,{}),r.enabled?t(`config:remoteAccess.firewallRetry`):t(`config:remoteAccess.firewallRetryCleanup`)]}):void 0,detail:(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-xs leading-relaxed text-content-muted`,children:[a.reason&&A[a.reason]?(0,J.jsx)(`p`,{className:`text-content-secondary`,children:A[a.reason]}):null,r.enabled?(0,J.jsx)(`p`,{children:a.scope===`application`?t(`config:remoteAccess.firewallApplicationScope`):a.scope===`program_port`?t(`config:remoteAccess.firewallProgramPortScope`,{port:a.port??`—`}):t(`config:remoteAccess.firewallPortScope`,{port:a.port??`—`})}):null,(0,J.jsx)(`p`,{children:t(`config:remoteAccess.firewallReachability`)}),a.checkedAt?(0,J.jsx)(`p`,{className:`tabular-nums`,children:t(`config:remoteAccess.firewallCheckedAt`,{time:vt(a.checkedAt,n)})}):null]})}):null]})}),r.listening&&u.length?(0,J.jsx)(U,{"aria-live":`polite`,title:t(`config:remoteAccess.pendingApprovals`),count:u.length,meta:(0,J.jsx)(`span`,{className:`font-medium text-st-attn`,children:t(`config:remoteAccess.waitingForYou`)}),description:t(`config:remoteAccess.pendingApprovalsDescription`),children:(0,J.jsx)(H,{children:u.map(e=>(0,J.jsx)(V,{"data-pairing-request":e.id,icon:(0,J.jsx)(Mn,{}),name:e.deviceName,description:(0,J.jsx)(`span`,{className:`font-mono`,children:t(`config:remoteAccess.requestSource`,{ip:e.ip})}),meta:t(`config:remoteAccess.requestedAt`,{time:vt(e.requestedAt,n)}),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(z,{size:`sm`,variant:`ghost`,disabled:y===e.id,onClick:()=>void M(e,!1),children:[(0,J.jsx)(Ce,{}),t(`config:remoteAccess.reject`)]}),(0,J.jsxs)(z,{size:`sm`,disabled:y===e.id,onClick:()=>void M(e,!0),children:[y===e.id?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(E,{}),t(`config:remoteAccess.approve`)]})]})},e.id))})}):null,r.listening?(0,J.jsx)(U,{title:t(`config:remoteAccess.pairing`),"data-config-card":`remote-access-pairing`,children:(0,J.jsx)(H,{children:(0,J.jsx)(V,{icon:(0,J.jsx)(Dn,{}),name:t(`config:remoteAccess.pairWithPhone`),description:t(`config:remoteAccess.pairingDescription`),actions:(0,J.jsxs)(z,{size:`sm`,disabled:x,onClick:()=>void j(),children:[x?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(Dn,{}),t(x?`config:remoteAccess.generatingQr`:`config:remoteAccess.generateQr`)]}),detail:_&&!h?(0,J.jsx)(`p`,{className:`text-xs leading-relaxed text-content-secondary`,"aria-live":`polite`,children:_}):void 0})})}):null,(0,J.jsx)(U,{title:t(`config:remoteAccess.devices`),count:s.length,"data-config-card":`remote-access-devices`,actions:(0,J.jsx)(z,{size:`icon-sm`,variant:`ghost`,className:`pointer-coarse:size-11 max-[650px]:size-11`,onClick:()=>void T(),"aria-label":t(`config:remoteAccess.refresh`),title:t(`config:remoteAccess.refresh`),children:(0,J.jsx)(fe,{})}),children:s.length===0?(0,J.jsx)(At,{compact:!0,title:t(`config:remoteAccess.noDevices`)}):(0,J.jsx)(H,{children:s.map(e=>(0,J.jsx)(V,{icon:(0,J.jsx)(Mn,{}),name:e.name,nameMeta:e.current?t(`config:remoteAccess.currentDevice`):void 0,description:t(`config:remoteAccess.lastSeen`,{time:vt(e.lastSeenAt,n)}),actions:(0,J.jsx)(z,{size:`sm`,variant:`ghost`,className:`hover:bg-danger-soft hover:text-danger`,"aria-label":`${t(`config:remoteAccess.revoke`)}: ${e.name}`,onClick:()=>void ee(e),children:t(`config:remoteAccess.revoke`)})},e.id))})})]})}function Yr({attention:e=!1,glyph:t=null,children:n}){let r=e?`attention`:t;return(0,J.jsxs)(`span`,{className:L(`inline-flex min-w-0 items-center gap-1.5 whitespace-nowrap`,e?`font-medium text-st-attn`:`text-content-secondary`),children:[r&&(0,J.jsx)(yt,{status:r,className:`size-3.5`}),n]})}function Xr({requestConfirm:e}){let{t}=l(),n=window.pisperDesktop?.remoteWorkspaces,[r,i]=(0,q.useState)([]),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(``),[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(``),v=(0,q.useCallback)(async()=>{n&&i(await n.list())},[n]);(0,q.useEffect)(()=>{v().catch(e=>_(String(e)))},[v]);let y=async e=>{if(!m){h(!0),_(``);try{await e()}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}}};return window.__PISPER_REMOTE_WORKSPACE__?(0,J.jsx)(U,{title:t(`config:remoteWorkspace.title`),"data-config-card":`remote-workspaces`,children:(0,J.jsx)(H,{children:(0,J.jsx)(V,{icon:(0,J.jsx)(ge,{}),name:t(`remote-workspace:activeTitle`),description:t(`remote-workspace:activeDescription`),detail:(0,J.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:t(`remote-workspace:isolation`)})})})}):n?(0,J.jsxs)(U,{title:t(`config:remoteWorkspace.title`),count:r.length,"data-config-card":`remote-workspaces`,description:t(`remote-workspace:description`),actions:(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`pointer-coarse:size-11`,disabled:m,"aria-label":t(`remote-workspace:refresh`),title:t(`remote-workspace:refresh`),onClick:()=>void y(v),children:(0,J.jsx)(fe,{className:`size-3.5`})}),children:[r.length>0&&(0,J.jsx)(H,{children:r.map(r=>(0,J.jsx)(V,{icon:(0,J.jsx)(ge,{}),name:r.name,description:(0,J.jsx)(`span`,{className:`font-mono`,children:r.address}),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(z,{type:`button`,size:`sm`,variant:`secondary`,disabled:m,onClick:()=>void y(async()=>{await n.open(r.id),await v()}),children:[r.connected?t(`remote-workspace:show`):t(`remote-workspace:open`),(0,J.jsx)(S,{className:`size-3.5`})]}),(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`hover:bg-danger-soft hover:text-danger max-[650px]:size-11 pointer-coarse:size-11`,disabled:m,"aria-label":t(`remote-workspace:forget`,{name:r.name}),onClick:()=>void y(async()=>{await e({title:t(`remote-workspace:forget`,{name:r.name}),message:t(`remote-workspace:forgetDescription`)})&&(await n.forget(r.id),await v())}),children:(0,J.jsx)(be,{className:`size-3.5`})})]})},r.id))}),(0,J.jsxs)(`div`,{className:`@container/card mt-3 rounded-[var(--r-md)] border border-stroke px-3 pt-2 pb-1`,children:[(0,J.jsx)(`p`,{className:`py-1.5 text-xs leading-relaxed text-content-secondary`,children:t(`remote-workspace:instructions`)}),(0,J.jsxs)(`form`,{className:`divide-y divide-stroke-soft border-t border-stroke-soft`,onSubmit:e=>{e.preventDefault(),y(async()=>{let e=await n.pair({name:a,address:s,fingerprint:u,code:f});p(``),await v(),await n.open(e),await v()})},children:[(0,J.jsx)(Sr,{label:t(`remote-workspace:name`),htmlFor:`remote-workspace-name`,children:(0,J.jsx)(B,{id:`remote-workspace-name`,value:a,maxLength:160,disabled:m,placeholder:`Linux`,onChange:e=>o(e.target.value)})}),(0,J.jsx)(Sr,{label:t(`remote-workspace:address`),htmlFor:`remote-workspace-address`,children:(0,J.jsx)(B,{id:`remote-workspace-address`,type:`url`,value:s,required:!0,disabled:m,placeholder:`https://192.168.1.10:5174`,autoComplete:`off`,spellCheck:!1,className:`font-mono`,onChange:e=>c(e.target.value)})}),(0,J.jsx)(Sr,{label:t(`remote-workspace:fingerprint`),htmlFor:`remote-workspace-fingerprint`,children:(0,J.jsx)(B,{id:`remote-workspace-fingerprint`,value:u,required:!0,disabled:m,placeholder:`SHA256:…`,autoComplete:`off`,spellCheck:!1,className:`font-mono text-xs`,onChange:e=>d(e.target.value)})}),(0,J.jsx)(Sr,{label:t(`remote-workspace:code`),htmlFor:`remote-workspace-code`,children:(0,J.jsx)(B,{id:`remote-workspace-code`,value:f,required:!0,maxLength:64,disabled:m,placeholder:`ABCD-EFGH`,autoComplete:`off`,spellCheck:!1,className:`font-mono`,onChange:e=>p(e.target.value)})}),(0,J.jsx)(`div`,{className:`flex justify-end py-3`,children:(0,J.jsxs)(z,{type:`submit`,className:`max-[650px]:h-11`,disabled:m,children:[m?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(S,{className:`size-3.5`}),t(`remote-workspace:pair`)]})})]})]}),g&&(0,J.jsx)(W,{className:`mt-3`,children:g}),(0,J.jsx)(`p`,{className:`mt-3 text-xs leading-relaxed text-content-muted`,children:t(`remote-workspace:isolation`)})]}):null}function Zr({section:e,notify:t,requestConfirm:n,onBack:r}){let{t:i}=l(),a=m(e=>e.capabilities),o=h(),s=p(a,e,{mobileApp:o}),c=i(e===`remote-access`?`config:configPage.remoteAccess`:e===`mobile-server`?`config:configPage.mobileServer`:`config:configPage.desktopPet`),u=i(e===`remote-access`?`config:deviceFeature.remoteAccessLede`:e===`mobile-server`?`config:deviceFeature.mobileServerLede`:`config:desktopPetSettings.description`),d;return d=s.supported?e===`desktop-pet`?(0,J.jsx)(kr,{notify:t,requestConfirm:n}):e===`mobile-server`?(0,J.jsx)(qr,{requestConfirm:n}):(0,J.jsxs)(J.Fragment,{children:[!window.__PISPER_REMOTE_WORKSPACE__&&(0,J.jsx)(Jr,{notify:t}),(0,J.jsx)(Xr,{requestConfirm:n})]}):(0,J.jsx)(Qr,{section:e,support:s}),(0,J.jsx)(Mt,{"data-device-feature":e,title:c,description:u,back:r&&{label:i(`navigation:sidebar.features`),ariaLabel:i(`navigation:shell.backToFeaturesLabel`),onBack:r},children:(0,J.jsx)(`div`,{"data-config-card":ot,className:`min-w-0`,children:d})})}function Qr({section:e,support:t}){let{t:n}=l(),r=n(e===`desktop-pet`?`config:desktopPetSettings.showOnDesktop`:e===`mobile-server`?`config:mobileServer.title`:`config:remoteAccess.allowConnections`),i=t.reason===`runtime`?n(`config:deviceFeature.runtimeUnavailable`):t.reason===`mobile-only`?n(`config:deviceFeature.mobileOnly`):n(e===`desktop-pet`?`config:desktopPetSettings.desktopOnlyDescription`:`config:deviceFeature.remoteAccessDesktopOnly`);return(0,J.jsx)(U,{title:n(`config:deviceFeature.unavailableTitle`),"data-device-unsupported":!0,children:(0,J.jsx)(H,{children:(0,J.jsx)(V,{icon:e===`desktop-pet`?(0,J.jsx)(w,{}):(0,J.jsx)(se,{}),name:r,description:i,status:n(`config:deviceFeature.unavailable`),actions:(0,J.jsx)(tt,{checked:!1,disabled:!0,"aria-label":r})})})})}function $r({title:e,description:t,action:n,children:r,className:i,...a}){let o=(0,q.useId)();return(0,J.jsxs)(`section`,{"aria-labelledby":o,className:L(`min-w-0`,i),...a,children:[(0,J.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h2`,{id:o,className:`text-[15px] leading-6 font-medium text-content`,children:e}),t&&(0,J.jsx)(`p`,{className:`mt-0.5 text-[13px] text-content-muted`,children:t})]}),n]}),(0,J.jsx)(`div`,{className:`divide-y divide-stroke-soft`,children:r})]})}function Q({title:e,description:t,control:n,nested:r,children:i,className:a,...o}){return(0,J.jsxs)(`div`,{className:L(`min-w-0 py-3`,r&&`pl-4`,a),...o,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-6 gap-y-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 basis-40`,children:[(0,J.jsx)(`div`,{className:`text-[13px] font-medium text-content`,children:e}),t&&(0,J.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-content-muted`,children:t})]}),n&&(0,J.jsx)(`div`,{className:`max-w-full shrink-0`,children:n})]}),i]})}function ei({className:e,...t}){return(0,J.jsx)(ar,{"data-slot":`radio-group`,className:L(`grid w-full gap-2`,e),...t})}function ti({className:e,...t}){return(0,J.jsx)(ur,{"data-slot":`radio-group-option`,className:L(`disabled:pointer-events-none disabled:opacity-50`,e),...t})}function ni(e,t){return t(e===`en-US`?`config:languageSettings.english`:`config:languageSettings.simplifiedChinese`)}function ri({notify:e}){let{language:t,setLanguage:n,t:r}=l(),i=(0,q.useId)(),a=(0,q.useId)(),o=r=>{r!==t&&(n(r),e(s(r===`en-US`?`config:languageSettings.displayLanguageChangedToEnglish`:`config:languageSettings.displayLanguageChangedToSimplifiedChinese`,r)))};return(0,J.jsxs)(`div`,{className:`flex flex-row flex-wrap items-center justify-between gap-x-6 gap-y-3 border-y border-stroke-soft py-3`,"data-config-card":`interface-language`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 basis-40`,children:[(0,J.jsx)(`h2`,{id:i,className:`text-sm font-medium text-content`,children:r(`config:languageSettings.displayLanguage`)}),(0,J.jsx)(`p`,{id:a,className:`mt-0.5 text-xs leading-relaxed text-content-muted`,children:r(`config:languageSettings.interfaceOnlyHint`)})]}),(0,J.jsxs)(Qe,{value:t,onValueChange:e=>{let t=c.find(t=>t.value===e);t&&o(t.value)},children:[(0,J.jsx)(Ye,{"aria-labelledby":i,"aria-describedby":a,className:`min-w-36 shrink-0`,children:(0,J.jsx)(Je,{})}),(0,J.jsx)(Xe,{align:`end`,children:c.map(e=>(0,J.jsx)(Ze,{value:e.value,children:ni(e.value,r)},e.value))})]})]})}function ii({role:e,label:t,value:n,onCommit:r}){let{t:i}=l(),a=(0,q.useId)(),[o,s]=(0,q.useState)(String(n)),c=(0,q.useRef)(o),u=(0,q.useRef)(n),d=e===`ui`?un:cn;(0,q.useEffect)(()=>{u.current=n,c.current=String(n),s(String(n))},[n]);let f=o!==String(n)&&ln(o,e)===null,p=()=>{let t=ln(c.current,e);t!==null&&t!==u.current&&(r(t),u.current=t)};return(0,J.jsxs)(`div`,{className:`flex max-w-full flex-col items-end gap-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(B,{type:`number`,min:d.min,max:d.max,step:1,value:o,"aria-label":t,"aria-invalid":f,"aria-describedby":f?a:void 0,className:`h-8 w-16 text-sm tabular-nums pointer-coarse:min-h-11 max-[650px]:min-h-11`,onChange:e=>{c.current=e.target.value,s(e.target.value)},onPointerUp:p,onBlur:p,onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Enter`?(e.preventDefault(),p()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),c.current=String(n),s(String(n))))}}),(0,J.jsx)(`span`,{className:`text-sm text-content-muted`,children:`px`})]}),f&&(0,J.jsx)(`p`,{id:a,role:`alert`,className:`max-w-56 text-xs text-destructive`,children:i(`config:interfaceSettings.invalidFontSize`,{min:d.min,max:d.max})})]})}function ai({label:e,options:t,value:n,onChange:r}){return(0,J.jsx)(ei,{value:n,onValueChange:e=>{let n=t.find(t=>t.value===e);n&&r(n.value)},className:`grid auto-cols-fr grid-flow-col gap-0.5 rounded-md border border-stroke bg-chrome p-[3px]`,"aria-label":e,children:t.map(e=>(0,J.jsx)(ti,{type:`button`,className:L(`min-h-7 rounded-sm border border-transparent px-2.5 text-sm transition-colors pointer-coarse:min-h-11 max-[650px]:min-h-11`,e.value===n?`border-key-border bg-key font-medium text-content shadow-key`:`text-content-secondary hover:text-content`),value:e.value,children:e.label},e.value))})}var oi={neutral:`var(--primary)`,blue:`#3d4bef`,teal:`#0f766e`,violet:`#6d4ad6`,coral:`#c93a48`,custom:`#3d4bef`};function si(e){let[t,n,r]=[1,3,5].map(t=>parseInt(e.slice(t,t+2),16)/255),i=Math.max(t,n,r),a=i-Math.min(t,n,r),o=0;return a&&(o=i===t?(n-r)/a%6:i===n?(r-t)/a+2:(t-n)/a+4),{hue:(o*60+360)%360,saturation:i?a/i:0,brightness:i}}function ci({hue:e,saturation:t,brightness:n}){let r=n*t,i=r*(1-Math.abs(e/60%2-1));return`#`+[[r,i,0],[i,r,0],[0,r,i],[0,i,r],[i,0,r],[r,0,i]][Math.floor(e/60)%6].map(e=>Math.round((e+n-r)*255).toString(16).padStart(2,`0`)).join(``)}function li({value:e,onCommit:t}){let{t:n}=l(),[r,i]=(0,q.useState)(e),a=(0,q.useRef)(e),[o,s]=(0,q.useState)(()=>si(e)),c=(0,q.useId)(),u=e=>{a.current=e,i(e)};(0,q.useEffect)(()=>{a.current=e,i(e),s(si(e))},[e]);let d=e=>{s(e),u(ci(e))},f=()=>{let n=Yt(a.current);n&&n!==Yt(e)&&t(n)},p=e=>{let t=e.currentTarget.getBoundingClientRect();d({...o,saturation:Math.min(1,Math.max(0,(e.clientX-t.left)/t.width)),brightness:1-Math.min(1,Math.max(0,(e.clientY-t.top)/t.height))})},m=!!r.trim()&&!Yt(r);return(0,J.jsxs)(qe,{onOpenChange:t=>{t||(f(),Yt(a.current)||(u(e),s(si(e))))},children:[(0,J.jsx)(Ge,{asChild:!0,children:(0,J.jsxs)(z,{variant:`outline`,className:`h-8 min-h-0 w-26 gap-1.5 px-2 text-xs tabular-nums pointer-coarse:h-11 max-[650px]:h-11`,"aria-label":n(`config:interfaceSettings.customAccentColor`),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 shrink-0 rounded-full border border-stroke-strong`,style:{backgroundColor:e}}),(0,J.jsx)(`span`,{className:`font-mono`,children:e})]})}),(0,J.jsxs)(Ke,{align:`end`,sideOffset:8,className:`w-auto rounded-xl p-3`,children:[(0,J.jsx)(`div`,{role:`slider`,tabIndex:0,"aria-label":n(`config:interfaceSettings.colorSpectrum`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(o.saturation*100),"aria-valuetext":r,"aria-describedby":c,className:`relative h-34 w-34 touch-none rounded-lg outline-none focus-visible:ring-2 focus-visible:ring-ring`,style:{background:`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), hsl(${o.hue} 100% 50%)`},onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),p(e)},onPointerMove:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&p(e)},onPointerUp:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&(p(e),e.currentTarget.releasePointerCapture(e.pointerId),f())},onPointerCancel:()=>{u(e),s(si(e))},onKeyDown:e=>{[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(e.key)&&(e.preventDefault(),d({...o,saturation:Math.min(1,Math.max(0,o.saturation+(e.key===`ArrowRight`?.01:e.key===`ArrowLeft`?-.01:0))),brightness:Math.min(1,Math.max(0,o.brightness+(e.key===`ArrowUp`?.01:e.key===`ArrowDown`?-.01:0)))}))},onKeyUp:e=>{e.key.startsWith(`Arrow`)&&f()},onBlur:f,children:(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-sm`,style:{left:`${o.saturation*100}%`,top:`${(1-o.brightness)*100}%`}})}),(0,J.jsx)(et,{min:0,max:359,step:1,value:[Math.round(o.hue)],"aria-label":n(`config:interfaceSettings.colorHue`),valueText:`${Math.round(o.hue)}°`,className:`h-7 w-34`,onValueChange:([e])=>d({...o,hue:e}),onValueCommit:()=>f()}),(0,J.jsx)(B,{type:`text`,value:r,spellCheck:!1,"aria-label":n(`config:interfaceSettings.customAccentHex`),"aria-invalid":m,"aria-describedby":c,className:`w-34 font-mono text-xs`,onChange:e=>{u(e.target.value);let t=Yt(e.target.value);t&&s(si(t))},onBlur:f,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f())}}),(0,J.jsx)(`p`,{id:c,className:`max-w-34 text-xs text-muted-foreground`,children:n(m?`config:interfaceSettings.invalidAccentColor`:`config:interfaceSettings.colorSpectrumHint`)})]})]})}function ui({notify:e,defaultAdvancedExpanded:t=!1,navigationKey:n}){let{t:r}=l(),{theme:i,density:a,accent:o,customAccent:s,uiFontSize:c,codeFontSize:u,radius:d,motion:f,setTheme:p,setDensity:m,setAccent:h,setCustomAccent:g,setUiFontSize:y,setCodeFontSize:b,setRadius:x,setMotion:S,resetAppearance:C}=Xt(),w=v(e=>e.pinned),T=v(e=>e.setPinned),[E,O]=(0,q.useState)(t),k=(0,q.useId)(),A=(0,q.useId)();(0,q.useEffect)(()=>{t&&O(!0)},[t,n]);let j=i!==en.theme||a!==en.density||o!==en.accent||s!==en.customAccent||c!==en.uiFontSize||u!==en.codeFontSize||d!==en.radius||f!==en.motion,M=t=>n=>{t(n),e(r(`config:interfaceSettings.preferencesUpdated`))},ee=[{value:`system`,label:r(`config:interfaceSettings.followSystem`),description:r(`config:interfaceSettings.followSystemDescription`),icon:Tn},{value:`light`,label:r(`config:interfaceSettings.light`),description:r(`config:interfaceSettings.lightDescription`),icon:Pn},{value:`dark`,label:r(`config:interfaceSettings.dark`),description:r(`config:interfaceSettings.darkDescription`),icon:En}],N=[{value:`comfortable`,label:r(`config:interfaceSettings.comfortable`),description:r(`config:interfaceSettings.comfortableDescription`),icon:In},{value:`compact`,label:r(`config:interfaceSettings.compact`),description:r(`config:interfaceSettings.compactDescription`),icon:Cn}],P=[{value:`system`,label:r(`config:interfaceSettings.motionSystem`),description:r(`config:interfaceSettings.motionSystemDescription`),icon:Tn},{value:`full`,label:r(`config:interfaceSettings.motionFull`),description:r(`config:interfaceSettings.motionFullDescription`),icon:ve},{value:`reduced`,label:r(`config:interfaceSettings.motionReduced`),description:r(`config:interfaceSettings.motionReducedDescription`),icon:_}],te=[{value:`neutral`,label:r(`config:interfaceSettings.accentNeutral`)},{value:`blue`,label:r(`config:interfaceSettings.accentBlue`)},{value:`teal`,label:r(`config:interfaceSettings.accentTeal`)},{value:`violet`,label:r(`config:interfaceSettings.accentViolet`)},{value:`coral`,label:r(`config:interfaceSettings.accentCoral`)},{value:`custom`,label:r(`config:interfaceSettings.accentCustom`)}],ne=[{value:`sharp`,label:r(`config:interfaceSettings.sharp`)},{value:`default`,label:r(`config:interfaceSettings.standard`)},{value:`soft`,label:r(`config:interfaceSettings.soft`)}];return(0,J.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,J.jsx)($r,{title:r(`config:interfaceSettings.visualStyle`),description:r(`config:interfaceSettings.appearanceDescription`),"data-config-card":`interface-appearance`,action:(0,J.jsxs)(z,{type:`button`,variant:`ghost`,size:`sm`,className:`pointer-coarse:h-11`,disabled:!j,onClick:()=>{C(),e(r(`config:interfaceSettings.defaultsRestored`))},children:[(0,J.jsx)(me,{size:14}),r(`config:interfaceSettings.restoreDefaults`)]}),children:(0,J.jsxs)(xr,{children:[(0,J.jsx)(Q,{title:r(`config:interfaceSettings.colorMode`),control:(0,J.jsx)(`div`,{role:`radiogroup`,"aria-label":r(`config:interfaceSettings.colorMode`),className:`grid w-68 max-w-full grid-cols-3 gap-4`,children:ee.map(e=>(0,J.jsxs)(`label`,{className:`group flex min-w-0 cursor-pointer flex-col items-center gap-2 text-xs text-content-muted`,children:[(0,J.jsx)(`input`,{className:`peer sr-only`,type:`radio`,name:A,value:e.value,checked:i===e.value,onChange:()=>M(p)(e.value)}),(0,J.jsxs)(`span`,{"aria-hidden":`true`,className:L(`relative block aspect-4/3 w-full overflow-hidden rounded-md border border-stroke bg-surface-sunken peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-focus`,i===e.value&&`border-star ring-2 ring-star`),children:[(0,J.jsxs)(`span`,{className:`absolute inset-2 rounded border border-(--preview-light-line) bg-(--preview-light-bg)`,children:[(0,J.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-1/4 border-r border-(--preview-light-line) bg-(--preview-light-side)`}),(0,J.jsx)(`span`,{className:`absolute top-3 right-1 h-0.5 w-1/2 rounded bg-(--preview-light-line)`}),(0,J.jsx)(`span`,{className:`absolute top-5 right-2 h-0.5 w-1/3 rounded bg-(--preview-light-line)`})]}),e.value!==`light`&&(0,J.jsxs)(`span`,{className:L(`absolute inset-2 rounded border border-(--preview-dark-line) bg-(--preview-dark-bg)`,e.value===`system`&&`left-1/2 rounded-l-none border-l-0`),children:[e.value===`dark`&&(0,J.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-1/4 border-r border-(--preview-dark-line) bg-(--preview-dark-side)`}),(0,J.jsx)(`span`,{className:`absolute top-3 right-1 h-0.5 w-1/2 rounded bg-(--preview-dark-line)`}),(0,J.jsx)(`span`,{className:`absolute top-5 right-2 h-0.5 w-1/3 rounded bg-(--preview-dark-line)`})]})]}),(0,J.jsx)(`span`,{className:L(i===e.value&&`font-medium text-content`),children:e.label})]},e.value))})}),(0,J.jsx)(Q,{title:r(`config:interfaceSettings.accentColor`),description:r(`config:interfaceSettings.accentDescription`),control:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,J.jsxs)(Qe,{value:o,onValueChange:e=>{let t=te.find(t=>t.value===e);t&&M(h)(t.value)},children:[(0,J.jsx)(Ye,{"aria-label":r(`config:interfaceSettings.accentColor`),className:`min-w-36`,children:(0,J.jsx)(Je,{})}),(0,J.jsx)(Xe,{align:`end`,children:te.map(e=>(0,J.jsxs)(Ze,{value:e.value,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 rounded-full border border-stroke-strong`,style:{backgroundColor:e.value===`custom`?s:oi[e.value]}}),e.label]},e.value))})]}),o===`custom`&&(0,J.jsx)(li,{value:Yt(s)||en.customAccent,onCommit:M(g)})]})})]})}),(0,J.jsxs)(Jt,{open:E,onOpenChange:O,children:[(0,J.jsx)(qt,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,"aria-controls":k,"aria-expanded":E,className:`flex min-h-9 w-full items-center gap-2 rounded-sm text-left text-[15px] leading-6 font-medium text-content max-[650px]:min-h-11`,children:[(0,J.jsx)(D,{size:16,"aria-hidden":`true`,className:L(`text-content-muted transition-transform`,!E&&`-rotate-90`)}),r(`config:interfaceSettings.advanced`)]})}),(0,J.jsx)(Kt,{id:k,children:(0,J.jsxs)(xr,{className:`mt-3`,children:[(0,J.jsxs)(`div`,{className:`divide-y divide-stroke-soft`,"data-config-card":`interface-style`,children:[(0,J.jsx)(Q,{title:r(`config:interfaceSettings.uiFontSize`),description:r(`config:interfaceSettings.numericFontHint`),control:(0,J.jsx)(ii,{role:`ui`,label:r(`config:interfaceSettings.uiFontSize`),value:c,onCommit:M(y)})}),(0,J.jsx)(Q,{title:r(`config:interfaceSettings.codeFontSize`),control:(0,J.jsx)(ii,{role:`code`,label:r(`config:interfaceSettings.codeFontSize`),value:u,onCommit:M(b)})}),(0,J.jsx)(Q,{title:r(`config:interfaceSettings.cornerStyle`),control:(0,J.jsx)(ai,{label:r(`config:interfaceSettings.cornerStyle`),options:ne,value:d,onChange:M(x)})})]}),(0,J.jsxs)(`div`,{className:`divide-y divide-stroke-soft`,"data-config-card":`interface-motion`,children:[(0,J.jsx)(Q,{title:r(`config:interfaceSettings.interfaceDensity`),control:(0,J.jsx)(ai,{label:r(`config:interfaceSettings.interfaceDensity`),options:N,value:a,onChange:M(m)})}),(0,J.jsx)(Q,{title:r(`config:interfaceSettings.pinInspector`),description:r(`config:interfaceSettings.pinInspectorDescription`),control:(0,J.jsx)(tt,{checked:w,onCheckedChange:M(T),"aria-label":r(`config:interfaceSettings.pinInspector`),"data-setting":`pin-inspector`})}),(0,J.jsx)(Q,{title:r(`config:interfaceSettings.motion`),control:(0,J.jsx)(ai,{label:r(`config:interfaceSettings.motion`),options:P,value:f,onChange:M(S)})}),(0,J.jsx)(Q,{title:r(`config:interfaceSettings.automaticByTime`),description:r(`config:interfaceSettings.automaticByTimeDescription`),control:(0,J.jsx)(tt,{checked:i===`scheduled`,onCheckedChange:e=>M(p)(e?`scheduled`:`system`),"aria-label":r(`config:interfaceSettings.automaticByTime`)})})]})]})})]}),(0,J.jsx)(ri,{notify:e})]})}function di({requestConfirm:e}){let{t}=l(),n=ct(e=>e.bindings),r=ct(e=>e.boardBindings),i=ct(e=>e.setBinding),a=ct(e=>e.setBoardBinding),o=ct(e=>e.resetBindings),[s,c]=(0,q.useState)(null),[u,d]=(0,q.useState)(null),[f,p]=(0,q.useState)(!1),m=dn(),h=m.actions,g=m.boardActions,_=(e,n)=>{p(!1);let i=pt(r,e,n);if(i){d({action:e,message:t(`config:shortcuts.conflict`,{action:g[i]})});return}try{a(e,n),c(null),d(null),p(!0)}catch{d({action:e,message:t(`config:shortcuts.saveFailed`)})}},v=(e,r)=>{p(!1);let a=dt(n,e,r);if(a){d({action:e,message:t(`config:shortcuts.conflict`,{action:h[a]})});return}try{st({...n,[e]:r})}catch{d({action:e,message:t(`config:shortcuts.invalid`)});return}try{i(e,r),c(null),d(null),p(!0)}catch{d({action:e,message:t(`config:shortcuts.saveFailed`)})}},y=(e,n)=>{if(s!==n)return;if(e.key===`Tab`){c(null);return}let r=ft.includes(n),i=r?ht(e.nativeEvent):mt(e.nativeEvent);if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){c(null),d(null);return}i&&r?_(n,i):i?v(n,i):!e.nativeEvent.isComposing&&e.keyCode!==229&&!e.repeat&&![`Control`,`Meta`,`Alt`,`Shift`,`AltGraph`,`Dead`,`Process`].includes(e.key)&&d({action:n,message:t(`config:shortcuts.invalid`)})},b=async()=>{if(c(null),await e({title:t(`config:shortcuts.resetAll`),message:t(`config:shortcuts.resetConfirm`),confirmLabel:t(`config:shortcuts.resetAll`)}))try{o(),d(null),p(!0)}catch{d({action:null,message:t(`config:shortcuts.saveFailed`)})}},x=ut.some(e=>n[e]!==lt[e])||ft.some(e=>r[e]!==_t[e]),S=e=>{let i=ft.includes(e),a=i?g[e]:h[e],o=i?r[e]:n[e],l=i?_t[e]:lt[e],f=t=>i?_(e,t):v(e,t);return(0,J.jsxs)(`div`,{className:`py-2.5`,"data-shortcut-action":e,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-5 gap-y-2`,children:[(0,J.jsx)(`label`,{htmlFor:`shortcut-${e}`,className:`min-w-0 text-sm font-medium text-content`,children:a}),(0,J.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1 max-[650px]:w-full`,children:[(0,J.jsx)(z,{id:`shortcut-${e}`,"data-shortcut-recorder":!0,variant:`outline`,className:L(`h-8 w-44 min-w-0 justify-center gap-2 border-input bg-panel px-2.5 text-xs font-normal shadow-none hover:bg-surface-subtle pointer-coarse:h-11 max-[650px]:h-11 max-[650px]:flex-1`,s===e&&`border-focus text-accent-fg ring-3 ring-focus-ring hover:bg-panel`),"aria-label":t(`config:shortcuts.edit`,{action:a}),"aria-pressed":s===e,"aria-describedby":u?.action===e?`shortcut-error-${e}`:void 0,onClick:()=>{c(e),d(null),p(!1)},onBlur:()=>c(t=>t===e?null:t),onKeyDown:t=>y(t,e),children:s===e?(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:t(`config:shortcuts.recording`)}):gt(o)?(0,J.jsx)(rt,{className:`min-w-0 flex-wrap justify-center`,children:gt(o).split(` + `).map((e,t)=>(0,J.jsx)(it,{className:`text-content-secondary`,children:e},t))}):(0,J.jsx)(`span`,{className:`text-content-muted`,children:t(`config:shortcuts.disabled`)})}),(0,J.jsxs)(We,{children:[(0,J.jsx)(He,{asChild:!0,children:(0,J.jsx)(z,{variant:`ghost`,size:`icon`,className:`pointer-coarse:size-11 max-[650px]:size-11`,title:t(`config:shortcuts.options`,{action:a}),"aria-label":t(`config:shortcuts.options`,{action:a}),children:(0,J.jsx)(N,{className:`size-4`})})}),(0,J.jsxs)(Ue,{align:`end`,className:`w-40`,onCloseAutoFocus:e=>{document.activeElement?.hasAttribute(`data-shortcut-recorder`)&&e.preventDefault()},children:[(0,J.jsxs)(Be,{disabled:o===null,onSelect:()=>f(null),children:[(0,J.jsx)(Ce,{className:`size-4`}),t(`config:shortcuts.disableKey`)]}),(0,J.jsxs)(Be,{disabled:o===l,onSelect:()=>f(l),children:[(0,J.jsx)(me,{className:`size-4`}),t(`config:shortcuts.resetAll`)]})]})]})]})]}),u?.action===e&&(0,J.jsx)(`p`,{id:`shortcut-error-${e}`,role:`alert`,className:`mt-2 text-xs text-danger`,children:u.message})]},e)},C=e=>e.kind===`fixed`?(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-5 gap-y-2 py-2.5`,"data-shortcut-fixed":e.id,children:[(0,J.jsxs)(`span`,{className:`min-w-0 text-sm text-content-secondary`,children:[m.label(e),(0,J.jsx)(`span`,{className:`ml-1.5 text-xs text-content-muted`,children:t(`board:shortcuts.fixed`)})]}),(0,J.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1 max-[650px]:w-full`,children:[(0,J.jsx)(mn,{keys:e.keys,className:`h-8 w-44 justify-center px-2.5 max-[650px]:flex-1`}),(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-7 flex-none pointer-coarse:size-11 max-[650px]:size-11`})]})]},pn(e)):S(e.action);return(0,J.jsxs)(`section`,{className:`w-full min-w-0`,"data-config-card":`shortcuts-bindings`,children:[(0,J.jsx)(`div`,{className:`flex flex-col gap-5`,children:fn.map((e,n)=>(0,J.jsxs)(`section`,{"aria-labelledby":`shortcut-group-${e.id}`,"data-shortcut-group":e.id,children:[(0,J.jsxs)(`div`,{className:`flex min-h-7 items-center justify-between gap-3`,children:[(0,J.jsx)(`h3`,{id:`shortcut-group-${e.id}`,className:`text-[13px] leading-6 font-semibold text-content`,children:m.groups[e.id].title}),n===0&&(0,J.jsxs)(z,{variant:`ghost`,size:`sm`,"data-shortcuts-reset-all":!0,className:`-mr-2 text-content-secondary max-[650px]:h-11 pointer-coarse:h-11`,disabled:!x,onClick:()=>void b(),children:[(0,J.jsx)(me,{className:`size-3.5`,"aria-hidden":`true`}),t(`config:shortcuts.resetAll`)]})]}),(0,J.jsx)(`p`,{className:`mb-2 text-xs text-content-muted`,children:m.groups[e.id].hint}),(0,J.jsx)(xr,{children:e.entries.map(C)})]},e.id))}),(0,J.jsx)(`div`,{className:`mt-3 min-h-5 text-xs text-content-muted`,role:`status`,"aria-live":`polite`,children:u?.action===null?(0,J.jsx)(`span`,{className:`text-destructive`,children:u.message}):t(f?`config:shortcuts.saved`:`config:shortcuts.deviceScope`)})]})}function fi(e,t){let n=(0,q.useRef)(t);n.current=t,(0,q.useEffect)(()=>{if(e)return e(()=>n.current?.())},[e])}o.addResourceBundle(`zh-CN`,`providers`,{"modelEditor.edit":`编辑模型`,"modelEditor.add":`添加模型`,"modelEditor.description":`能力与思考强度`,"modelEditor.id":`模型 ID`,"modelEditor.capabilities":`模型能力`,"modelEditor.chat":`对话`,"modelEditor.image":`图像生成`,"modelEditor.video":`视频生成`,"modelEditor.capabilitiesHint":`可单选或多选。仅选图像生成时,复用此连接的密钥,不会出现在对话模型中。`,"modelEditor.chatCapabilities":`对话能力`,"modelEditor.vision":`图片理解`,"modelEditor.reasoning":`深度思考`,"modelEditor.contextWindow":`上下文窗口(Token)`,"modelEditor.maxTokens":`最大输出(Token)`,"modelEditor.editNamed":`编辑模型 {name}`,"modelEditor.optionsNamed":`模型能力:{name}`,"modelEditor.delete":`删除模型`,"modelEditor.deleteNamed":`删除模型 {name}`,"modelEditor.deleteConfirmation":`删除“{name}”?供应商连接和密钥会保留。若它是默认模型,将选用其他可用模型,没有可用模型时清空默认值;已有会话的模型不会自动替换。之后可以重新添加此模型。`,"modelEditor.deleted":`模型已删除`}),o.addResourceBundle(`en-US`,`providers`,{"modelEditor.edit":`Edit model`,"modelEditor.add":`Add model`,"modelEditor.description":`Capabilities and reasoning levels`,"modelEditor.id":`Model ID`,"modelEditor.capabilities":`Model capabilities`,"modelEditor.chat":`Chat`,"modelEditor.image":`Image generation`,"modelEditor.video":`Video generation`,"modelEditor.capabilitiesHint":`Choose one or more. Image-only models reuse this connection’s key and stay out of the chat model picker.`,"modelEditor.chatCapabilities":`Chat capabilities`,"modelEditor.vision":`Image understanding`,"modelEditor.reasoning":`Reasoning`,"modelEditor.contextWindow":`Context window (tokens)`,"modelEditor.maxTokens":`Maximum output (tokens)`,"modelEditor.editNamed":`Edit model {name}`,"modelEditor.optionsNamed":`Model capabilities: {name}`,"modelEditor.delete":`Delete model`,"modelEditor.deleteNamed":`Delete model {name}`,"modelEditor.deleteConfirmation":`Delete “{name}”? The provider connection and credentials will remain. If this is the default model, another available model will be selected, or the default will be cleared if none is available. Existing conversations will keep their model bindings. You can add this model again later.`,"modelEditor.deleted":`Model deleted`});function pi(e){let t=(0,q.useContext)(an);return(0,q.useLayoutEffect)(()=>{t?.update(e)}),(0,q.useLayoutEffect)(()=>()=>t?.remove(e.id),[t,e.id]),{requestClose:(0,q.useCallback)(n=>{t?t.requestClose(e.id,n):n()},[t,e.id])}}var mi=[[`openai-responses`,`OpenAI Responses`],[`openai-completions`,`OpenAI Chat Completions`],[`anthropic-messages`,`Anthropic Messages`],[`google-generative-ai`,`Google Generative AI`]],hi={"openai-codex-responses":`OpenAI Codex Responses`,"azure-openai-responses":`Azure OpenAI Responses`,"mistral-conversations":`Mistral Conversations`,"bedrock-converse-stream":`Amazon Bedrock Converse`,"google-vertex":`Google Vertex AI`,"pi-messages":`Pi Messages`};function gi(e){return!e||mi.some(([t])=>t===e)?mi:[...mi,[e,hi[e]||e]]}var _i={openai:w,"openai-codex":w,anthropic:T,google:ve,deepseek:j,xai:le,openrouter:ce,"kimi-coding":ve,"zai-coding-cn":T},vi={saveFallbackModels(e){return f(`/api/config/fallback-models`,{method:`PUT`,body:JSON.stringify({models:e})})},saveAuxiliaryModel(e){return f(`/api/config/auxiliary-model`,{method:`PUT`,body:JSON.stringify({model:e})})},deleteModel(e,t){return f(`/api/providers/`+encodeURIComponent(e)+`/models`,{method:`DELETE`,body:JSON.stringify({modelId:t})})},saveModel(e,t,n=!1){return f(`/api/providers/`+encodeURIComponent(e)+`/models`+(n?``:`/options`),{method:n?`POST`:`PUT`,body:JSON.stringify(n?{...t,id:t.modelId,kind:t.capabilities[0]}:t)})},saveConnection(e,t){return f(`/api/providers/`+encodeURIComponent(e)+`/connection`,{method:`PUT`,body:JSON.stringify(t)})},importLocal(){return f(`/api/providers/import-local`,{method:`POST`,body:`{}`})}};function yi(e,t){return t.name!==e.name||t.api!==e.api||t.baseUrl!==(e.baseUrl||``)||!!t.apiKey}function bi({provider:e,onSave:t,draft:n,onDraftChange:r,onSavingChange:i,children:a}){let{t:o}=l(),[s,c]=(0,q.useState)(!1),[u,d]=(0,q.useState)(``),f=(0,q.useId)(),p=yi(e,n),m=async a=>{if(a.preventDefault(),!s){c(!0),i(!0),d(``);try{t(await vi.saveConnection(e.id,{...n,apiKey:n.apiKey.trim()||void 0})),r(void 0)}catch(e){d(e instanceof Error?e.message:String(e))}finally{c(!1),i(!1)}}};return(0,J.jsxs)(`form`,{onSubmit:e=>void m(e),"data-provider-connection-editor":!0,children:[(0,J.jsxs)(`fieldset`,{disabled:s,className:`min-w-0 divide-y divide-stroke-soft`,children:[(0,J.jsx)(Sr,{label:o(`config:configPage.displayName`),htmlFor:`${f}-name`,children:(0,J.jsx)(B,{id:`${f}-name`,required:!0,value:n.name,onChange:e=>r({...n,name:e.target.value})})}),(0,J.jsx)(Sr,{label:o(`config:configPage.apiKey`),htmlFor:`${f}-key`,children:(0,J.jsx)(B,{id:`${f}-key`,type:`password`,autoComplete:`new-password`,className:`font-mono placeholder:font-sans`,value:n.apiKey,placeholder:e.configured?o(`config:configPage.leaveBlankToKeepExistingKey`):o(`config:configPage.enterTheProviderAPIKey`),onChange:e=>r({...n,apiKey:e.target.value})})}),(0,J.jsx)(Sr,{label:o(`config:configPage.apiProtocol`),labelId:`${f}-api-label`,help:(0,J.jsx)(`span`,{className:`font-mono`,children:n.api}),children:(0,J.jsx)(K,{"aria-labelledby":`${f}-api-label`,value:n.api,onChange:e=>r({...n,api:e.target.value}),children:gi(n.api).map(([e,t])=>(0,J.jsx)(`option`,{value:e,children:t},e))})}),(0,J.jsx)(Sr,{label:`Base URL`,htmlFor:`${f}-url`,children:(0,J.jsx)(B,{id:`${f}-url`,required:!0,type:`url`,className:`font-mono`,value:n.baseUrl,onChange:e=>r({...n,baseUrl:e.target.value})})})]}),u&&(0,J.jsx)(W,{className:`mt-2 mb-3`,children:u}),a,(0,J.jsxs)(`div`,{className:L(`flex flex-wrap items-center justify-end gap-2 border-t border-stroke-soft py-3`,p&&`sticky bottom-0 z-[1] bg-background`),children:[p&&(0,J.jsx)(`span`,{role:`status`,className:`mr-auto text-xs text-content-muted`,children:o(`config:configPage.unsavedChanges`)}),(0,J.jsx)(z,{type:`submit`,className:`max-[650px]:h-11`,disabled:!p,loading:s,children:o(s?`config:configPage.saving`:`config:configPage.saveChanges`)})]})]})}var xi=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function Si({label:e,checked:t,disabled:n,onChange:r}){return(0,J.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t,disabled:n,onClick:r,className:L(`inline-flex h-8 items-center gap-2 rounded-sm border px-2.5 text-sm transition-colors disabled:opacity-50 pointer-coarse:h-11`,t?`border-star-border bg-star-soft text-star-strong`:`border-stroke text-content-secondary hover:bg-surface-hover hover:text-content`),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:L(`grid size-3.5 place-items-center rounded-[3px] border border-control`,t&&`border-star bg-star text-on-accent`),children:t&&(0,J.jsx)(E,{size:11})}),e]})}function Ci({provider:e,model:t,onSave:n,onClose:r}){let{t:i}=l(),[a]=(0,q.useState)(()=>t?.contextWindow||2e5),[o,s]=(0,q.useState)(()=>({modelId:t?.id||``,name:t?.name||``,capabilities:t?.capabilities||[t?.kind===`image`?`image`:t?.kind===`video`?`video`:`chat`],input:t?.input||[`text`],reasoning:t?.reasoning??!0})),[c,u]=(0,q.useState)(()=>({contextWindow:String(a),maxTokens:String(t?.maxTokens||8192)})),[d,f]=(0,q.useState)(t?.thinkingLevels||[`off`,`low`,`medium`,`high`]),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(``),y=o.capabilities.includes(`chat`),b=async i=>{if(i.preventDefault(),!h){g(!0),v(``);try{n(await vi.saveModel(e.id,{...o,modelId:o.modelId.trim(),thinkingLevels:p||!t?d:void 0,contextWindow:Number(c.contextWindow)===a?void 0:Number(c.contextWindow),maxTokens:Number(c.maxTokens)},!t)),r()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}};return(0,J.jsx)(Tt,{open:!0,onOpenChange:e=>{!e&&!h&&r()},children:(0,J.jsxs)(xt,{className:`sm:max-w-[540px] p-5`,showCloseButton:!h,onEscapeKeyDown:e=>{h&&e.preventDefault()},onInteractOutside:e=>e.preventDefault(),children:[(0,J.jsxs)(wt,{children:[(0,J.jsx)(St,{children:i(t?`providers:modelEditor.edit`:`providers:modelEditor.add`)}),(0,J.jsxs)(bt,{children:[e.name,` · `,i(`providers:modelEditor.description`)]})]}),(0,J.jsxs)(`form`,{onSubmit:e=>void b(e),className:`space-y-5`,children:[(0,J.jsxs)(`fieldset`,{disabled:h,className:`space-y-5`,children:[(0,J.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(`providers:modelEditor.id`),(0,J.jsx)(B,{required:!0,disabled:!!t,value:o.modelId,onChange:e=>s({...o,modelId:e.target.value})})]}),(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(`config:configPage.modelName`),(0,J.jsx)(B,{value:o.name,onChange:e=>s({...o,name:e.target.value})})]})]}),(0,J.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,J.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`providers:modelEditor.capabilities`)}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`chat`,`image`,`video`].map(e=>(0,J.jsx)(Si,{label:i(e===`chat`?`providers:modelEditor.chat`:e===`image`?`providers:modelEditor.image`:`providers:modelEditor.video`),checked:o.capabilities.includes(e),onChange:()=>s({...o,capabilities:o.capabilities.includes(e)?o.capabilities.filter(t=>t!==e):[...o.capabilities,e]})},e))}),(0,J.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:i(`providers:modelEditor.capabilitiesHint`)})]}),y&&(0,J.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,J.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`providers:modelEditor.chatCapabilities`)}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(Si,{label:i(`providers:modelEditor.vision`),checked:o.input.includes(`image`),onChange:()=>s({...o,input:o.input.includes(`image`)?[`text`]:[`text`,`image`]})}),(0,J.jsx)(Si,{label:i(`providers:modelEditor.reasoning`),checked:o.reasoning,onChange:()=>s({...o,reasoning:!o.reasoning})})]})]}),y&&o.reasoning&&(0,J.jsxs)(`fieldset`,{children:[(0,J.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`config:configPage.modelThinkingLevels`)}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:xi.map(e=>(0,J.jsx)(Si,{label:e,checked:e===`off`||d.includes(e),disabled:e===`off`,onChange:()=>{m(!0),f(d.includes(e)?d.filter(t=>t!==e):[...d,e])}},e))})]}),y&&(0,J.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[`contextWindow`,`maxTokens`].map(e=>(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(e===`contextWindow`?`providers:modelEditor.contextWindow`:`providers:modelEditor.maxTokens`),(0,J.jsx)(B,{required:!0,type:`number`,min:1,max:1e8,step:1,value:c[e],onChange:t=>u({...c,[e]:t.target.value})})]},e))})]}),_&&(0,J.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:_}),(0,J.jsxs)(Ct,{children:[(0,J.jsx)(z,{type:`button`,variant:`ghost`,disabled:h,onClick:r,children:i(`config:configPage.cancel`)}),(0,J.jsxs)(z,{type:`submit`,disabled:h||!o.capabilities.length||!o.modelId.trim(),children:[h&&(0,J.jsx)(F,{className:`animate-spin`,size:14}),` `,i(h?`config:configPage.saving`:`config:configPage.saveChanges`)]})]})]})]})})}function wi(e,t){let n=e.providers.filter(e=>e.configured||e.custom),r=e.defaultProvider||e.provider;return{providers:n,selected:n.find(e=>e.id===t)??n.find(e=>e.id===r)??n[0],defaultId:r}}function Ti(e){let t=e.trim().split(/[\s_\-/.]+/).filter(Boolean);if(t.length>1)return(Array.from(t[0])[0]+Array.from(t[1])[0]).toUpperCase();let n=Array.from(t[0]||`?`);return n[0].toUpperCase()+(n[1]||``)}function Ei(e){return e?e>=1e6?`${Number((e/1e6).toFixed(2))}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e):`—`}function Di(e){return gi(e).find(([t])=>t===e)?.[1]||e}var Oi=`grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 @min-[560px]/card:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)_64px_76px_minmax(88px,auto)]`;function ki(e){let{t}=l(),n=(0,q.useId)(),{providers:r,defaultId:i}=wi(e.config,e.selectedProviderId),a=r.find(t=>t.id===e.selectedProviderId),[o,s]=(0,q.useState)({}),[c,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(null),p=!!(c||e.settingDefault||e.settingModel||e.toggling||e.deletingModel);pi({id:`provider-drafts-${n}`,dirty:r.some(e=>!!(o[e.id]&&yi(e,o[e.id]))),saving:p,discard:()=>s({})});let m={chat:t(`providers:modelEditor.chat`),image:t(`providers:modelEditor.image`),video:t(`providers:modelEditor.video`),reasoning:t(`providers:modelEditor.reasoning`)},h=e=>{let t=e.capabilities||[e.kind];return[[`chat`,oe,t.includes(`chat`)],[`image`,ie,t.includes(`image`)],[`video`,I,t.includes(`video`)],[`reasoning`,T,!!e.reasoning&&t.includes(`chat`)]].filter(([,,e])=>e).map(([e,t])=>(0,J.jsxs)(`span`,{title:m[e],className:`inline-flex`,children:[(0,J.jsx)(t,{size:13,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`sr-only`,children:m[e]})]},e))},g=e=>e.configured?t(`config:providerWorkbench.keyConfigured`):e.id===`openai-codex`?t(`config:configPage.codexCLILoginRequired`):t(`config:configPage.apiKeyRequired`),_=e=>e.configured?e.enabled?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,J.jsx)(E,{className:`size-3.5`,"aria-hidden":`true`}),t(`config:providerWorkbench.connected`)]}):t(`config:configPage.disabled2`):t(`config:providerWorkbench.notConnected`),v=n=>(0,J.jsxs)(`div`,{className:`@container/card min-w-0`,"data-provider-detail":n.id,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 border-t border-stroke-soft py-2`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-content-muted`,children:n.id}),(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-sm text-content-secondary`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:t(`config:configPage.enabled`)}),(0,J.jsx)(br,{value:n.configured&&n.enabled,disabled:!n.configured||p,onChange:()=>void e.onToggle(n,!n.enabled),ariaLabel:t(`config:configPage.providerEnabled`,{name:n.name})})]}),(0,J.jsxs)(We,{children:[(0,J.jsx)(He,{asChild:!0,children:(0,J.jsx)(z,{variant:`ghost`,size:`icon-sm`,className:`pointer-coarse:size-11 max-[650px]:size-11`,"aria-label":t(`config:providerWorkbench.actions`),children:(0,J.jsx)(N,{size:16})})}),(0,J.jsxs)(Ue,{align:`end`,children:[(0,J.jsxs)(Be,{disabled:n.id===i||!n.configured||!n.enabled||!n.defaultModel||p,onSelect:()=>void e.onSetDefault(n),children:[(0,J.jsx)(Nn,{size:14}),t(`config:configPage.setAsDefaultProvider`)]}),(0,J.jsxs)(Be,{disabled:p,onSelect:()=>e.onClone(n),children:[(0,J.jsx)(M,{size:14}),t(`config:configPage.cloneProvider`)]}),n.custom&&(0,J.jsxs)(Be,{className:`text-destructive`,disabled:p,onSelect:()=>void e.onDelete(n),children:[(0,J.jsx)(be,{size:14}),t(`config:configPage.deleteProvider`)]})]})]})]}),(0,J.jsxs)(bi,{provider:n,draft:o[n.id]??{name:n.name,api:n.api,baseUrl:n.baseUrl||``,apiKey:``},onDraftChange:e=>s(t=>({...t,[n.id]:e})),onSavingChange:u,onSave:e.onSave,children:[(0,J.jsxs)(`div`,{className:`mt-2 flex min-h-10 items-center gap-2 border-t border-stroke-soft pt-2`,children:[(0,J.jsxs)(`h3`,{className:`text-[13px] font-medium text-content-muted`,children:[t(`config:providerWorkbench.models`),(0,J.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,n.models.length]})]}),(0,J.jsxs)(z,{type:`button`,variant:`secondary`,size:`sm`,className:`ml-auto pointer-coarse:h-11 max-[650px]:h-11`,disabled:p,onClick:()=>f({provider:n}),children:[(0,J.jsx)(de,{size:14}),t(`providers:modelEditor.add`)]})]}),n.models.length>0&&(0,J.jsxs)(`div`,{className:L(Oi,`hidden h-8 text-xs font-medium text-content-muted @min-[560px]/card:grid`),children:[(0,J.jsx)(`span`,{children:t(`providers:modelEditor.id`)}),(0,J.jsx)(`span`,{children:t(`config:configPage.displayName`)}),(0,J.jsx)(`span`,{className:`text-right`,children:t(`config:providerWorkbench.contextColumn`)}),(0,J.jsx)(`span`,{children:t(`providers:modelEditor.capabilities`)}),(0,J.jsx)(`span`,{"aria-hidden":`true`})]}),n.models.map(r=>{let i=n.defaultModel===r.id;return(0,J.jsxs)(`div`,{"data-provider-model":r.id,className:L(Oi,`min-h-11.5 border-t border-stroke-soft py-px text-sm text-content-secondary`),children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>f({provider:n,model:r}),disabled:p,className:`flex min-h-11 min-w-0 flex-col justify-center rounded-xs py-1 text-left`,"aria-label":t(`providers:modelEditor.editNamed`,{name:r.name||r.id}),children:[(0,J.jsx)(`span`,{className:`block truncate font-mono text-[12.5px] text-content`,children:r.id}),(0,J.jsxs)(`span`,{className:`mt-0.5 flex min-w-0 items-center gap-2 text-xs text-content-muted @min-[560px]/card:hidden`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:r.name||r.id}),(0,J.jsx)(`span`,{className:`tabular-nums`,children:Ei(r.contextWindow)}),h(r)]})]}),(0,J.jsx)(`span`,{className:`hidden min-w-0 truncate text-content @min-[560px]/card:block`,children:r.name||r.id}),(0,J.jsx)(`span`,{className:`hidden text-right tabular-nums @min-[560px]/card:block`,children:Ei(r.contextWindow)}),(0,J.jsx)(`span`,{className:`hidden items-center gap-2 text-content-muted @min-[560px]/card:flex`,children:h(r)}),(0,J.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[r.kind===`chat`&&(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-sm`,className:L(`pointer-coarse:size-11 max-[650px]:size-11`,i&&`text-star disabled:opacity-100 aria-disabled:opacity-100`),"aria-label":t(`config:configPage.providerDefaultModel`)+`: `+r.id,title:t(`config:configPage.providerDefaultModel`),"aria-pressed":i,disabled:p||!n.configured||i,onClick:()=>void e.onSetDefaultModel(n,r.id),children:(0,J.jsx)(Nn,{size:15,className:L(i&&`fill-current`)})}),(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`pointer-coarse:size-11 max-[650px]:size-11`,"aria-label":t(`providers:modelEditor.optionsNamed`,{name:r.id}),disabled:p,onClick:()=>f({provider:n,model:r}),children:(0,J.jsx)(jn,{size:14})}),(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`hover:bg-danger-soft hover:text-danger pointer-coarse:size-11 max-[650px]:size-11`,disabled:p,"aria-label":t(`providers:modelEditor.deleteNamed`,{name:r.name||r.id}),title:t(`providers:modelEditor.delete`),onClick:()=>void e.onDeleteModel(n,r),children:(0,J.jsx)(be,{size:14})})]})]},r.id)})]},n.id)]});return(0,J.jsxs)(U,{"data-config-card":`models-connections`,"data-model-provider-list":!0,title:t(`config:providerWorkbench.providers`),count:r.length,meta:e.meta,description:t(`config:providerWorkbench.providersHint`),children:[r.length>0?(0,J.jsx)(H,{children:r.map(n=>{let r=n.id===i,o=a?.id===n.id;return(0,J.jsx)(V,{"data-provider-row":n.id,icon:(0,J.jsx)(`span`,{className:`text-[13px] font-semibold text-content-secondary`,children:Ti(n.name)}),name:n.name,description:[g(n),t(`config:configPage.countModels`,{count:n.models.length}),Di(n.api)].join(` · `),status:(0,J.jsxs)(J.Fragment,{children:[r&&(0,J.jsxs)(`span`,{"data-provider-default":!0,className:`text-content-secondary`,children:[t(`config:providerWorkbench.default`),` ·`]}),_(n)]}),expanded:o,onExpandedChange:t=>e.onSelectProvider(t?n.id:``),toggleLabel:t(`config:providerWorkbench.toggleProvider`,{name:n.name}),detail:o?v(n):null},n.id)})}):(0,J.jsxs)(`div`,{className:`grid min-h-48 place-content-center justify-items-center gap-2 border-y border-stroke px-6 py-8 text-center`,children:[(0,J.jsx)(kt,{size:40,className:`mb-1`}),(0,J.jsx)(`p`,{className:`text-sm font-medium text-content`,children:t(`config:providerWorkbench.noConnections`)}),(0,J.jsx)(`p`,{className:`max-w-sm text-xs text-content-muted`,children:t(`config:providerWorkbench.addConnectionHint`)})]}),e.onAddConnection&&(0,J.jsxs)(`button`,{type:`button`,"data-add-provider":!0,disabled:p,onClick:e.onAddConnection,className:`flex min-h-[52px] w-full min-w-0 items-center gap-2.5 text-left text-sm text-content-secondary transition-colors duration-(--d-fast) hover:text-content focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus disabled:opacity-50`,children:[(0,J.jsx)(de,{size:16,"aria-hidden":`true`,className:`flex-none text-content-muted`}),(0,J.jsx)(`span`,{className:`flex-none`,children:t(`config:providerWorkbench.addProvider`)}),(0,J.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:t(`config:providerWorkbench.addProviderHint`)})]}),d&&(0,J.jsx)(Ci,{provider:d.provider,model:d.model,onSave:e.onSave,onClose:()=>f(null)})]})}function Ai(){let e=globalThis.crypto.getRandomValues(new Uint32Array(4));return`custom-${Array.from(e,e=>e.toString(16).padStart(8,`0`)).join(``)}`}function ji({value:e,onChange:t,configured:n=!1,cloning:r=!1}){let{t:i}=l();return(0,J.jsxs)(G,{variant:`control`,children:[i(`config:configPage.apiKey`),(0,J.jsx)(B,{type:`password`,autoComplete:`new-password`,value:e,onChange:e=>t(e.target.value),placeholder:i(r?`config:configPage.leaveBlankToCopySourceKey`:n?`config:configPage.leaveBlankToKeepExistingKey`:`config:configPage.enterTheProviderAPIKey`)})]})}function Mi({ids:e,onChange:t,placeholder:n,primaryId:r=``}){let{t:i}=l(),[a,o]=(0,q.useState)(``),s=()=>{let n=a.trim();!n||n===r.trim()||e.includes(n)||(t([...e,n]),o(``))};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(G,{variant:`control`,children:[i(`config:configPage.manualModelIds`),(0,J.jsxs)(`div`,{className:`flex items-stretch gap-1.5`,children:[(0,J.jsx)(B,{"aria-label":i(`config:configPage.manualModelIds`),value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),s())},placeholder:n}),(0,J.jsx)(z,{type:`button`,size:`icon`,variant:`secondary`,className:`h-auto w-8.5 flex-none pointer-coarse:w-11`,"aria-label":i(`config:configPage.manualModelIds`),disabled:!a.trim(),onClick:s,children:(0,J.jsx)(de,{size:14})})]})]}),e.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col overflow-hidden rounded-md border border-stroke`,children:e.map(n=>(0,J.jsxs)(`div`,{className:`flex min-h-9 min-w-0 items-center gap-2 border-b border-stroke-soft py-1 pr-1 pl-2.5 last:border-b-0`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12.5px] text-content`,children:n}),(0,J.jsx)(`button`,{type:`button`,"aria-label":i(`config:configPage.delete`),className:`grid size-7 flex-none cursor-pointer place-items-center rounded-sm border-0 bg-transparent p-0 text-content-muted hover:bg-danger-soft hover:text-danger pointer-coarse:size-11`,onClick:()=>t(e.filter(e=>e!==n)),children:(0,J.jsx)(Ce,{size:12})})]},n))}),(0,J.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`config:configPage.manualModelIdsHint`)})]})}function Ni(e,t){return e?.models.find(t=>t.id===e.defaultModel)||(t===`visual`?e?.models.find(e=>e.kind===`image`||e.kind===`video`):e?.models.find(e=>e.kind===`chat`)||e?.models[0])}function Pi({onClose:e,onCreated:t,onConfigChanged:n,initialProviderType:r=`chat`,initialProvider:i,cloneProvider:a,embedded:o=!1}){let{t:s}=l(),c=i||a,u=!!a,d=c?.type||r,p=Ni(c,d),[m,h]=(0,q.useState)(``),g=!!(i||m),[_,v]=(0,q.useState)(()=>({name:a?s(`config:configPage.clonedProviderName`,{name:a.name}):i?.name||``,id:a?Ai():i?.id||``,providerType:d,api:i?.api||`openai-responses`,baseUrl:i?.baseUrl||``,model:p?.id||``,modelName:p?.name||``,modelKind:p?.kind===`image`||p?.kind===`video`?p.kind:d===`visual`?`image`:`chat`,reasoning:p?.reasoning!==!1,thinkingLevels:p?.thinkingLevels||[],enabled:i?.enabled??!0})),y=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],[b,x]=(0,q.useState)(!1),S=e=>{x(!0),v(t=>({...t,thinkingLevels:t.thinkingLevels.includes(e)?t.thinkingLevels.filter(t=>t!==e):[...t.thinkingLevels,e]}))},[C,w]=(0,q.useState)(!1),[T,D]=(0,q.useState)(``),[O,k]=(0,q.useState)(``),A=O.trim()||void 0,[j,M]=(0,q.useState)([]),ee=e=>v(t=>({...t,name:e,id:t.id||e.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)}));return(0,q.useEffect)(()=>{if(o||C)return;let t=t=>{t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),e())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[o,e,C]),(0,J.jsx)(`div`,{className:o?`provider-config-inline`:`modal-backdrop max-[650px]:p-[8px] fixed z-[70] inset-0 grid place-items-center overflow-y-auto bg-[var(--modal-overlay)] [padding:20px] [overscroll-behavior:contain] [animation:fade-in_var(--d1)_var(--ease-out)]`,onMouseDown:t=>!o&&!C&&t.target===t.currentTarget&&e(),children:(0,J.jsxs)(`form`,{role:o?void 0:`dialog`,"aria-modal":!o||void 0,className:o?`provider-config-form grid gap-3 text-sm [&_label]:!mt-0 [&_label]:!text-sm [&_label]:font-medium [&_input]:!h-9 [&_input]:!min-h-9 [&_input]:rounded-lg [&_input]:!text-sm [&_select]:!h-9 [&_select]:!min-h-9 [&_select]:rounded-lg [&_select]:!text-sm [&_summary]:text-sm`:`modal provider-config-modal max-h-[calc(100dvh_-_40px)] !w-[min(620px,100%)] overflow-y-auto overscroll-contain rounded-lg border border-stroke bg-solid p-[18px] shadow-float [animation:modal-in_var(--d2)_var(--ease-out)] max-[650px]:max-h-[calc(100dvh_-_16px)]`,onSubmit:async e=>{if(e.preventDefault(),!C){if(!u&&!A&&!i?.configured&&!m){D(s(`config:configPage.enterTheAPIKeyForThisConnection`));return}w(!0),D(``);try{if(a){t(await f(`/api/providers/${encodeURIComponent(a.id)}/clone`,{method:`POST`,body:JSON.stringify({name:_.name,id:_.id,apiKey:A})}));return}let e=g?await f(`/api/config`,{method:`PUT`,body:JSON.stringify({..._,apiKey:A,thinkingLevels:b?_.thinkingLevels:void 0,provider:m||_.id,providerName:_.name,setAsDefault:!1})}):await f(`/api/providers`,{method:`POST`,body:JSON.stringify({..._,apiKey:A,thinkingLevels:b?_.thinkingLevels:void 0})}),r=e.createdProviderId||m||_.id;i||(h(r),v(e=>({...e,id:r})),n?.(e));let o=new Set((i?.models||[]).map(e=>e.id)),s=j.filter(e=>e!==_.model.trim()&&!o.has(e));if(s.length)try{e=await f(`/api/providers/${encodeURIComponent(r)}/models/batch`,{method:`POST`,body:JSON.stringify({models:s.map(e=>({id:e,kind:_.providerType===`visual`?_.modelKind:`chat`}))})})}catch(e){D(e instanceof Error?e.message:String(e));return}t(e)}catch(e){D(e instanceof Error?e.message:String(e))}finally{w(!1)}}},children:[!o&&(0,J.jsxs)(Bt,{children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{children:s(u?`config:configPage.cloneProvider`:g?`config:configPage.editProviderConnection`:`config:configPage.addProviderConnection`)}),!u&&(0,J.jsx)(`p`,{children:s(g?`config:configPage.updateProviderKeyURLAndModelSettings`:`config:configPage.youCanCreateMultipleConnectionsUsingTheSameProtocolEachWithItsOwnKeyAndBaseURL`)})]}),(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`config:configPage.closeDialog`),disabled:C,onClick:t=>{t.preventDefault(),t.stopPropagation(),e()},children:(0,J.jsx)(Ce,{size:17})})]}),(0,J.jsxs)(`div`,{className:`form-grid grid gap-3 sm:grid-cols-2`,children:[(0,J.jsxs)(G,{variant:`control`,children:[s(`config:configPage.displayName`),(0,J.jsx)(B,{value:_.name,onChange:e=>ee(e.target.value),placeholder:s(`config:configPage.forExampleOpenAIOfficial`)})]}),(0,J.jsxs)(G,{variant:`control`,children:[`Provider ID`,(0,J.jsx)(B,{value:_.id,disabled:g,onChange:e=>v({..._,id:e.target.value}),placeholder:`openai-official`})]})]}),(0,J.jsx)(ji,{value:O,onChange:k,configured:i?.configured,cloning:u}),!u&&(0,J.jsxs)(J.Fragment,{children:[!o&&(0,J.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between gap-2 rounded-sm border border-stroke-soft bg-surface-subtle px-2.5 py-2`,children:[(0,J.jsx)(`span`,{className:`text-xs text-content-muted`,children:s(`config:configPage.providerPurpose`)}),(0,J.jsx)(`strong`,{className:`font-mono text-xs font-medium`,children:_.providerType===`visual`?s(`config:configPage.visualProvider`):s(`config:configPage.chatProvider`)})]}),(0,J.jsxs)(G,{variant:`control`,children:[s(`config:configPage.apiProtocol`),(0,J.jsx)(K,{value:_.api,onChange:e=>v({..._,api:e.target.value}),children:mi.map(([e,t])=>(0,J.jsx)(`option`,{value:e,children:t},e))})]}),(0,J.jsxs)(G,{variant:`control`,children:[`Base URL`,(0,J.jsx)(B,{value:_.baseUrl,onChange:e=>v({..._,baseUrl:e.target.value}),placeholder:`https://api.openai.com/v1`})]}),(0,J.jsxs)(`div`,{className:`form-grid grid gap-3 sm:grid-cols-2`,children:[(0,J.jsxs)(G,{variant:`control`,children:[s(g?`config:configPage.providerDefaultModel`:`config:configPage.initialModelID`),(0,J.jsx)(B,{value:_.model,onChange:e=>v({..._,model:e.target.value}),placeholder:_.providerType===`visual`?`gpt-image-2 or grok-imagine-video`:`gpt-5.4 or gpt-image-1`})]}),(0,J.jsxs)(G,{variant:`control`,children:[s(`config:configPage.modelName`),(0,J.jsx)(B,{value:_.modelName,onChange:e=>v({..._,modelName:e.target.value}),placeholder:s(`config:configPage.leaveBlankToUseTheModelID`)})]})]}),(0,J.jsxs)(`details`,{open:!o||void 0,className:`group rounded-lg border border-border px-3 py-2 [&[open]]:space-y-3`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer text-[13px] text-muted-foreground`,children:s(`config:providerWorkbench.modelOptions`)}),(0,J.jsxs)(G,{variant:`control`,children:[s(`config:configPage.modelType`),(0,J.jsxs)(K,{value:_.modelKind,onChange:e=>v({..._,modelKind:e.target.value,providerType:e.target.value===`chat`?`chat`:`visual`}),children:[(0,J.jsx)(`option`,{value:`chat`,children:s(`providers:modelEditor.chat`)}),(0,J.jsx)(`option`,{value:`image`,children:s(`providers:modelEditor.image`)}),(0,J.jsx)(`option`,{value:`video`,children:s(`providers:modelEditor.video`)})]})]}),(0,J.jsx)(`div`,{className:`grid gap-[9px]`,children:(0,J.jsx)(Mi,{ids:j,onChange:M,primaryId:_.model,placeholder:_.providerType===`visual`?`gpt-image-1`:`gpt-5.5`})}),_.modelKind===`chat`&&(0,J.jsxs)(G,{variant:`control`,children:[s(`config:configPage.modelThinkingLevels`),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-[6px]`,children:y.map(e=>{let t=e===`off`,n=t||_.thinkingLevels.includes(e),r=t||!_.reasoning&&e!==`off`;return(0,J.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r,onClick:()=>!t&&S(e),className:L(`inline-flex h-[27px] cursor-pointer items-center gap-[4px] rounded-full border px-[10px] text-[12px] font-medium transition-colors`,n?`border-[var(--control-selected-border)] bg-[var(--control-selected-bg)] text-[var(--control-selected-text)]`:`border-[var(--stroke)] bg-[var(--surface-subtle)] text-[var(--text)] hover:bg-[var(--surface-highlight)]`,t?`cursor-default`:r&&`cursor-not-allowed opacity-40`),children:[n&&(0,J.jsx)(E,{size:12}),e]},e)})}),(0,J.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:s(`config:configPage.modelThinkingLevelsHint`)})]})]}),!o&&(0,J.jsxs)(`div`,{className:`mt-2.5 flex min-h-11 items-center justify-between gap-3 rounded-sm border border-[var(--stroke-soft)] bg-[var(--surface-subtle)] px-2.5 py-2`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,J.jsx)(`strong`,{className:`text-[13px]`,children:g?s(`config:configPage.providerEnabled`,{name:_.name}):s(`config:configPage.enableAfterCreation`)}),_.providerType===`visual`&&(0,J.jsx)(`small`,{className:`text-[13px] text-muted-foreground`,children:s(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]}),(0,J.jsx)(br,{value:_.enabled,onChange:e=>v({..._,enabled:e})})]})]}),T&&(0,J.jsxs)(Rt,{children:[(0,J.jsx)(xe,{size:13}),T]}),(0,J.jsxs)(`div`,{className:`mt-[18px] flex justify-end gap-2`,children:[(0,J.jsx)(z,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:C,onClick:e,children:s(`config:configPage.cancel`)}),(0,J.jsxs)(z,{type:`submit`,className:`max-[650px]:h-11`,disabled:C,children:[C?(0,J.jsx)(R,{className:`text-current`}):g?(0,J.jsx)(E,{size:14}):(0,J.jsx)(de,{size:14}),s(C?`config:configPage.saving`:u?`config:configPage.cloneProvider`:g?`config:configPage.saveChanges`:`config:configPage.createConnection`)]})]})]})})}function Fi(e){return(e.providers||[]).filter(e=>e.importable&&!e.imported&&!e.conflict).length}function Ii(e){return Fi(e)>0}function Li(e,t){return!t&&!Ii(e)}function Ri(e,t,n){let r=e.providers||[],i=e.errors||[],a=Ii(e),o=!!(n||i.length||r.some(e=>e.conflict||!e.imported&&!e.importable||e.warnings?.some(e=>e.code!==`login_auth_not_imported`)));return t||a||o}function zi(e){return e.source===`codex-config`?`Codex config.toml`:e.source===`claude-config`?`Claude settings.json`:e.source===`codex-auth`?`Codex login`:`Claude login`}function Bi(e,t){return e.authType===`environment`?t(`config:configPage.keyVariableName`,{name:e.authVariable}):e.authType===`bearer`||e.authType===`api_key`?t(`config:configPage.authenticationIncludedInConfiguration`):e.authType===`oauth`?t(`config:configPage.loginStateFileDetected`):e.authType===`external-login`?t(`config:configPage.authenticationRequired`):t(`config:configPage.noAuthenticationInConfiguration`)}function Vi(e,t){return t(e===`multiple_auth_values`?`config:configPage.multipleAuthenticationFieldsWereDetectedTheAuthorizationFieldTakesPrecedence`:e===`invalid_url`?`config:configPage.theProviderEndpointIsInvalid`:e===`unsupported_api`?`config:configPage.theAPIProtocolInThisConfigurationIsNotSupportedYet`:e===`invalid_env_name`?`config:configPage.theKeyEnvironmentVariableNameIsInvalid`:`config:configPage.someConfigurationFieldsCannotBeImported`)}function Hi({discovery:e,discovering:t,error:n,importing:r,forceVisible:i=!1,onRefresh:a,onImport:o}){let{t:s}=l(),[c,u]=(0,q.useState)(null),d=e.providers||[],f=e.errors||[];if(!i&&!Ri(e,t,n))return null;let p=c??(!i&&Li(e,t)),m=()=>(u(null),a()),h=e=>(u(null),o(e)),g=e=>[`invalid_json`,`invalid_toml`].includes(e.code)?s(`config:configPage.invalidConfigurationFileFormat`):e.code===`unsupported_config`?s(`config:configPage.noImportableProviderConfigurationWasFound`):e.code===`invalid_login_state`?s(`config:configPage.incompleteLoginState`):e.code===`file_too_large`?s(`config:configPage.configurationFileIsTooLarge`):s(`config:configPage.unableToReadTheConfigurationFile`);return(0,J.jsxs)(_r,{className:`mb-3 py-3.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2.5 max-[650px]:flex-wrap`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-3 rounded-sm border-0 bg-transparent p-0 text-left max-[650px]:basis-full`,"aria-expanded":!p,onClick:()=>u(!p),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-9.5 shrink-0 place-items-center rounded-lg border border-key-border bg-key text-content-muted shadow-key`,children:(0,J.jsx)(ge,{size:18})}),(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium text-content`,children:s(`config:configPage.localProviderConfiguration`)}),(0,J.jsx)(`span`,{className:`text-xs leading-[1.45] text-content-muted`,children:s(`config:configPage.readProviderEndpointModelAndAuthenticationFieldsFromCodexConfigTomlAndClaudeSettingsJson`)})]}),(0,J.jsx)(D,{size:16,"aria-hidden":`true`,className:L(`flex-none text-content-muted transition-transform`,!p&&`rotate-180`)})]}),(0,J.jsxs)(z,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:t||!!r,onClick:m,children:[t?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(fe,{size:13}),s(`config:configPage.rescan`)]})]}),!p&&(0,J.jsxs)(J.Fragment,{children:[t&&!d.length?(0,J.jsxs)(`div`,{role:`status`,className:`mt-3 flex min-h-12 items-center justify-center gap-2 rounded-sm bg-surface-subtle text-xs text-content-muted`,children:[(0,J.jsx)(R,{}),s(`config:configPage.scanningProviderConfigurationFiles`)]}):d.length?(0,J.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 max-[650px]:grid-cols-1`,children:d.map(e=>{let t=zi(e),n=r===e.id,i=e.source.startsWith(`claude-`)?T:w,a=e.kind===`authentication`?s(`config:configPage.officialProviderAuthenticationOnly`):e.models?.length?e.models.map(e=>e.id).join(`, `):s(`config:configPage.noModelSpecified`);return(0,J.jsxs)(`div`,{className:L(`grid min-h-17 min-w-0 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2.5 rounded-md border px-3 py-2 max-[650px]:grid-cols-[auto_minmax(0,1fr)]`,e.imported?`border-success-border bg-success-soft`:`border-stroke bg-panel`),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-7.5 place-items-center rounded-md border border-key-border bg-key text-content-muted shadow-key`,children:(0,J.jsx)(i,{size:15})}),(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,J.jsxs)(`span`,{className:`truncate text-sm font-medium text-content`,children:[t,` · `,e.providerName]}),(0,J.jsxs)(`span`,{className:`truncate font-mono text-xs text-content-muted`,children:[e.api,` · `,a]}),(0,J.jsxs)(`span`,{className:`truncate text-xs text-content-muted`,children:[e.kind===`authentication`?s(`config:configPage.officialEndpointOnly`):e.baseUrl||s(`config:configPage.noBaseURLSpecified`),` `,`· `,Bi(e,s),` · `,e.location]})]}),(0,J.jsx)(`span`,{className:`flex min-w-0 flex-none items-center max-[650px]:col-start-2`,children:e.imported?(0,J.jsx)(yr,{tone:`green`,children:s(`config:configPage.loaded`)}):e.conflict?(0,J.jsx)(yr,{tone:`amber`,children:s(`config:configPage.conflictDetected`)}):e.importable?(0,J.jsxs)(z,{type:`button`,size:`sm`,className:`pointer-coarse:h-11`,disabled:n||!!r,onClick:()=>h(e),children:[n?(0,J.jsx)(R,{className:`size-3 text-current`}):(0,J.jsx)(ee,{size:12}),n?s(`config:configPage.loading`):e.kind===`authentication`?s(`config:configPage.loadLoginState`):s(`config:configPage.loadConfiguration`)]}):(0,J.jsx)(yr,{tone:`gray`,children:s(`config:configPage.cannotLoad`)})})]},e.id)})}):(0,J.jsxs)(`div`,{className:`mt-3 flex min-h-12 items-center justify-center gap-2 rounded-sm bg-surface-subtle px-3 text-center text-xs text-content-muted`,children:[(0,J.jsx)(ge,{size:15,"aria-hidden":`true`}),s(`config:configPage.noImportableCodexOrClaudeProviderConfigurationWasDetected`)]}),(n||f.length>0||d.some(e=>e.warnings?.some(e=>e.code!==`login_auth_not_imported`)))&&(0,J.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1 text-xs text-danger [&_span]:flex [&_span]:items-center [&_span]:gap-1.5`,"aria-live":`polite`,children:[n&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(xe,{size:13}),n]}),f.map((e,t)=>(0,J.jsxs)(`span`,{children:[(0,J.jsx)(xe,{size:13}),zi(e),` · `,g(e)]},`${e.source}-${e.code}-${t}`)),d.flatMap(e=>(e.warnings||[]).filter(e=>e.code!==`login_auth_not_imported`).map((t,n)=>(0,J.jsxs)(`span`,{children:[(0,J.jsx)(xe,{size:13}),zi(e),` · `,Vi(t.code,s)]},`${e.id}-${t.code}-${n}`)))]})]})]})}function Ui(e){try{return{name:new URL(e).hostname.replace(/^www\./i,``)||`Custom Provider`}}catch{return{name:`Custom Provider`}}}function Wi({config:e,providerType:t=`chat`,initialProviderId:n,onClose:r,onConfigChanged:i,onCompleted:a}){let{t:o}=l(),s=n&&e.providers.find(e=>e.id===n)||null,[c,u]=(0,q.useState)(1),[d,p]=(0,q.useState)(s),[m]=(0,q.useState)(Ai),[h,g]=(0,q.useState)(``),_=(0,q.useRef)(null),v=(0,q.useRef)(null),[y,S]=(0,q.useState)(s?.baseUrl||``),[C,w]=(0,q.useState)(s?.api||`openai-responses`),[T,D]=(0,q.useState)(``),O=T.trim()||void 0,[k,A]=(0,q.useState)(s?.organization||``),[j,M]=(0,q.useState)(s?.name||``),[ee,N]=(0,q.useState)(s?.models||[]),[P,te]=(0,q.useState)(s?.defaultModel||``),[ne,re]=(0,q.useState)([]),[ie,ae]=(0,q.useState)(s?.models.find(e=>e.id===s.defaultModel)?.kind||(t===`visual`?`image`:`chat`)),[F,oe]=(0,q.useState)(!1),[se,I]=(0,q.useState)(``),[ce,le]=(0,q.useState)(``),ue=Ui(y),de=o(t===`visual`?`config:configPage.visualProvider`:`config:configPage.chatProvider`),pe=o(c===1?`config:configPage.quickSetupStepBaseUrl`:c===2?`config:configPage.quickSetupStepProtocol`:`config:configPage.quickSetupStepModel`),me=ee.filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`),he=()=>{let e=y.trim();try{let t=new URL(e);if(![`http:`,`https:`].includes(t.protocol))throw Error()}catch{I(o(`config:configPage.providerBaseURLMustBeHTTPOrHTTPS`));return}I(``),j.trim()||M(ue.name),u(2)},_e=()=>{if(!C){I(o(`config:configPage.selectAPIProtocol`));return}I(``),u(3)},ve=async()=>{if(F)return;let e=d;if(!O&&!e?.configured&&!h){I(o(`config:configPage.enterTheAPIKeyForThisConnection`));return}oe(!0),I(``),le(``);try{let n=((await f(`/api/providers/models/discover-connection`,{method:`POST`,body:JSON.stringify({providerId:e?.id||h,providerType:t,api:C,baseUrl:y,organization:k,apiKey:O})})).models||[]).filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`);if(!n.length){I(o(t===`visual`?`config:configPage.fetchOrAddAVisualModel`:`config:configPage.fetchOrAddAChatModel`));return}N(n);let r=n.find(e=>e.id===P)||n[0];te(r.id),ae(t===`visual`?r.kind:`chat`)}catch(n){let r=n instanceof Error?n.message:String(n),i=e?.models.filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`)||[];if(!/\(401\)|\(403\)|鉴权|认证|密钥|API Key/i.test(r)&&i.length){N(i);let e=i.find(e=>e.id===P)||i[0];te(e.id),ae(t===`visual`?e.kind:`chat`),le(r)}else I(r)}finally{oe(!1)}},ye=async()=>{if(F)return;let e=P.trim()||ne[0]||``;if(!e){I(o(`config:configPage.selectModelToFinish`));return}if(!O&&!d?.configured&&!h){I(o(`config:configPage.enterTheAPIKeyForThisConnection`));return}let n=new Set((d?.models||[]).map(e=>e.id)),r=ne.filter(t=>t!==e&&!n.has(t));oe(!0),I(``);try{let n=d?.id||h,o=n?await f(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:n,providerType:t,api:C,baseUrl:y,organization:k,model:e,modelKind:t===`visual`?ie:`chat`,apiKey:O,setAsDefault:!1,enabled:!0})}):await f(`/api/providers`,{method:`POST`,body:JSON.stringify({id:m,name:j.trim()||ue.name,providerType:t,api:C,baseUrl:y,organization:k,apiKey:O,model:e,modelKind:t===`visual`?ie:`chat`,enabled:!0})}),c=n||o.createdProviderId||m,l=s?``:c;l&&g(l);let u=o.providers.find(e=>e.id===c);if(u&&p(u),i?.(l?{...o,createdProviderId:l}:o),r.length){let e=t===`visual`?ie:`chat`;try{o=await f(`/api/providers/${encodeURIComponent(c)}/models/batch`,{method:`POST`,body:JSON.stringify({models:r.map(t=>({id:t,kind:e}))})})}catch(e){I(e instanceof Error?e.message:String(e));return}}a(l?{...o,createdProviderId:l}:o)}catch(e){I(e instanceof Error?e.message:String(e))}finally{oe(!1)}};return(0,J.jsx)(Tt,{open:!0,onOpenChange:e=>{!e&&!F&&r()},children:(0,J.jsxs)(xt,{showCloseButton:!1,className:`modal z-[80] block max-h-[calc(100dvh_-_40px)] w-[calc(100%_-_40px)] max-w-lg overflow-y-auto overscroll-contain rounded-[var(--r-lg)] border border-stroke bg-solid p-[18px] shadow-float sm:max-w-lg max-[650px]:max-h-[calc(100dvh_-_16px)] max-[650px]:w-[calc(100%_-_16px)]`,overlayClassName:`z-[70] bg-[var(--modal-overlay)]`,"aria-busy":F,onEscapeKeyDown:e=>{F&&e.preventDefault()},onInteractOutside:e=>{F&&e.preventDefault()},onOpenAutoFocus:e=>{e.preventDefault(),_.current=document.activeElement instanceof HTMLElement?document.activeElement:null,v.current?.focus()},onCloseAutoFocus:e=>{e.preventDefault(),_.current?.focus()},children:[(0,J.jsxs)(Bt,{children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(St,{asChild:!0,children:(0,J.jsx)(`h2`,{children:o(t===`visual`?`config:configPage.visualQuickSetupTitle`:`config:configPage.quickSetupTitle`)})}),(0,J.jsx)(bt,{asChild:!0,children:(0,J.jsxs)(`p`,{children:[o(`config:configPage.stepIndicator`,{current:c,total:3}),` · `,pe]})})]}),(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,className:`pointer-coarse:size-11`,"aria-label":o(`config:configPage.closeDialog`),disabled:F,onClick:r,children:(0,J.jsx)(Ce,{size:17})})]}),(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`mt-3 grid grid-cols-3 gap-1`,children:[1,2,3].map(e=>(0,J.jsx)(`span`,{className:L(`h-1 rounded-full`,e<=c?`bg-star`:`bg-surface-active`)},e))}),(0,J.jsxs)(`div`,{className:`mt-3 flex items-center gap-2.5 rounded-md border border-stroke-soft bg-surface-subtle px-2.5 py-2`,children:[(0,J.jsx)(`span`,{className:`grid size-7.5 flex-none place-items-center rounded-md border border-key-border bg-key text-content-muted shadow-key`,children:(0,J.jsx)(ge,{size:15,"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`truncate text-sm font-medium text-content`,children:j||ue.name}),(0,J.jsx)(`small`,{className:`text-xs text-content-muted`,children:de})]}),(0,J.jsx)(yr,{tone:`gray`,children:de})]}),c===1&&(0,J.jsxs)(`div`,{className:`[margin-top:14px]`,children:[(0,J.jsxs)(G,{variant:`control`,children:[`Base URL`,(0,J.jsx)(B,{ref:v,value:y,onChange:e=>S(e.target.value),placeholder:`https://api.example.com/v1`,inputMode:`url`})]}),(0,J.jsx)(`p`,{className:`mt-2 text-xs leading-[1.5] text-content-muted`,children:o(`config:configPage.quickSetupBaseUrlHint`)})]}),c===2&&(0,J.jsxs)(`div`,{className:`[margin-top:14px]`,children:[(0,J.jsxs)(G,{variant:`control`,children:[o(`config:configPage.apiProtocol`),(0,J.jsx)(K,{value:C,onChange:e=>w(e.target.value),children:mi.map(([e,t])=>(0,J.jsx)(`option`,{value:e,children:t},e))})]}),(0,J.jsxs)(G,{variant:`control`,children:[`Organization`,(0,J.jsx)(B,{value:k,onChange:e=>A(e.target.value),placeholder:o(`config:configPage.optionalUsedOnlyForOpenAIOrganization`)})]})]}),c===3&&(0,J.jsxs)(`div`,{className:`[margin-top:14px]`,children:[!d&&(0,J.jsxs)(G,{variant:`control`,children:[o(`config:configPage.displayName`),(0,J.jsx)(B,{value:j,onChange:e=>M(e.target.value),placeholder:ue.name})]}),(0,J.jsx)(ji,{value:T,onChange:D,configured:d?.configured}),(0,J.jsxs)(z,{type:`button`,variant:`secondary`,className:`mt-2.5 w-full max-[650px]:h-11`,disabled:F,onClick:()=>void ve(),children:[F?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(fe,{size:14}),o(F?`config:configPage.fetchingModels`:`config:configPage.fetchModels`)]}),ce&&(0,J.jsxs)(Lt,{className:`[margin-top:10px]`,children:[(0,J.jsx)(xe,{size:15}),(0,J.jsx)(`small`,{children:o(`config:configPage.discoverFailedUsingExisting`,{message:ce})})]}),me.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`mt-3.5 mb-2 text-xs leading-[1.5] text-content-muted`,children:o(t===`visual`?`config:configPage.selectVisualModelToFinish`:`config:configPage.selectModelToFinish`)}),(0,J.jsx)(`div`,{className:`flex max-h-[260px] flex-col overflow-y-auto rounded-md border border-stroke`,children:me.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:L(`relative flex min-h-10 min-w-0 cursor-pointer items-center gap-2 border-b border-stroke-soft px-2.5 py-2 text-left last:border-b-0 hover:bg-surface-subtle pointer-coarse:min-h-11`,P===e.id&&`bg-star-soft before:absolute before:inset-y-2 before:left-0 before:w-[3px] before:rounded-r-[3px] before:bg-star hover:bg-star-soft`),onClick:()=>{te(e.id),ae(t===`visual`?e.kind:`chat`)},children:[(0,J.jsx)(`span`,{className:L(`grid size-4 flex-none place-items-center rounded-full border border-control text-transparent`,P===e.id&&`border-star bg-star text-on-accent`),children:(0,J.jsx)(E,{size:11})}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-content`,children:e.name}),t===`visual`&&(0,J.jsx)(yr,{tone:`gray`,children:e.kind===`video`?o(`config:configPage.visualVideoModel`):o(`config:configPage.visualImageModel`)})]},`${e.id}-${e.kind}`))})]}),(0,J.jsxs)(`div`,{className:`mt-3.5 grid gap-2`,children:[(0,J.jsxs)(G,{variant:`control`,children:[o(`config:configPage.manualModelId`),(0,J.jsx)(B,{value:P,onChange:e=>te(e.target.value),placeholder:t===`visual`?`gpt-image-1`:`gpt-5.4`})]}),(0,J.jsx)(`p`,{className:`text-xs text-content-muted`,children:o(`config:configPage.manualModelIdHint`)}),t===`visual`&&(0,J.jsxs)(G,{variant:`control`,children:[o(`config:configPage.modelType`),(0,J.jsxs)(K,{value:ie,onChange:e=>ae(e.target.value),children:[(0,J.jsx)(`option`,{value:`image`,children:o(`config:configPage.imageGenerationAndEditing`)}),(0,J.jsx)(`option`,{value:`video`,children:o(`config:configPage.videoGeneration`)})]})]}),(0,J.jsx)(Mi,{ids:ne,onChange:re,primaryId:P,placeholder:t===`visual`?`gpt-image-1`:`gpt-5.5`})]})]}),se&&(0,J.jsxs)(Rt,{children:[(0,J.jsx)(xe,{size:13}),se]}),(0,J.jsxs)(`div`,{className:`mt-[18px] flex justify-between gap-2`,children:[(0,J.jsxs)(z,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:F||c===1,onClick:()=>{I(``),u(c-1)},children:[(0,J.jsx)(b,{size:14}),o(`config:configPage.previousStep`)]}),c===1?(0,J.jsxs)(z,{type:`button`,className:`max-[650px]:h-11`,disabled:F||!y.trim(),onClick:he,children:[(0,J.jsx)(x,{size:14}),o(`config:configPage.nextStep`)]}):c===2?(0,J.jsxs)(z,{type:`button`,className:`max-[650px]:h-11`,disabled:F,onClick:_e,children:[(0,J.jsx)(x,{size:14}),o(`config:configPage.nextStep`)]}):(0,J.jsxs)(z,{type:`button`,className:`max-[650px]:h-11`,disabled:F||!P.trim()&&ne.length===0,onClick:()=>void ye(),children:[F?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(E,{size:14}),o(F?`config:configPage.saving`:`config:configPage.saveChanges`)]})]})]})})}var Gi=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],Ki=``;function qi(e){return`${e.provider.id}/${e.model.id}`}function Ji({labelId:e,label:t,hint:n,children:r}){return(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-6 gap-y-2 border-b border-stroke py-4 max-[650px]:py-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-[min(240px,100%)] flex-1`,children:[(0,J.jsx)(`div`,{id:e,className:`text-sm font-medium text-content`,children:t}),(0,J.jsx)(`p`,{id:`${e}-hint`,className:`mt-0.5 text-xs text-content-muted`,children:n})]}),(0,J.jsx)(`div`,{className:`w-[min(280px,100%)] min-w-0 max-[650px]:w-full`,children:r})]})}function Yi({config:e,notify:t,busy:n,onConfigChanged:r,onSetDefaultModel:i}){let{t:a}=l(),o=(0,q.useId)(),[s,c]=(0,q.useState)(!1),[u,d]=(0,q.useState)(``),[p,m]=(0,q.useState)(e.thinkingLevel),[h,g]=(0,q.useState)(e.toolMode);(0,q.useEffect)(()=>{m(e.thinkingLevel),g(e.toolMode)},[e.thinkingLevel,e.toolMode]);let _=(e.fallbackModels||[]).join(`
2
2
  `),[v,y]=(0,q.useState)(e.fallbackModels||[]);(0,q.useEffect)(()=>{y(_?_.split(`
3
3
  `):[])},[_]);let[b,x]=(0,q.useState)(e.auxiliaryModel||``);(0,q.useEffect)(()=>{x(e.auxiliaryModel||``)},[e.auxiliaryModel]);let S=e.defaultProvider||e.provider,C=e.defaultModel||e.model,w=e.providers.find(e=>e.id===S),T=!!(w?.configured&&C),E=e.providers.filter(e=>e.type===`chat`&&e.configured&&e.enabled),D=E.flatMap(e=>e.models.filter(e=>e.kind===`chat`).map(t=>({provider:e,model:t,value:`${e.id}${Ki}${t.id}`}))),O=w&&C?`${w.id}${Ki}${C}`:``,k=async n=>{if(!(!w||!C)){c(!0),d(``);try{r(await f(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:w.id,providerType:w.type,api:w.api,baseUrl:w.baseUrl||``,organization:w.organization||``,model:C,thinkingLevel:n.thinkingLevel??e.thinkingLevel,toolMode:n.toolMode??e.toolMode,setAsDefault:!1})})),t(a(`config:configPage.runtimePolicySaved`))}catch(t){m(e.thinkingLevel),g(e.toolMode),d(t instanceof Error?t.message:String(t))}finally{c(!1)}}},A=!T||s||n,j=async(e,n)=>{let i=[...v];i[e]=n;let o=i.filter((e,t)=>e&&i.indexOf(e)===t),s=v;y(o),c(!0),d(``);try{r(await vi.saveFallbackModels(o)),t(a(`config:providerWorkbench.fallbackModelsSaved`))}catch(e){y(s),d(e instanceof Error?e.message:String(e))}finally{c(!1)}},M=async e=>{let n=b;x(e),c(!0),d(``);try{r(await vi.saveAuxiliaryModel(e)),t(a(`config:providerWorkbench.auxiliaryModelSaved`))}catch(e){x(n),d(e instanceof Error?e.message:String(e))}finally{c(!1)}},ee=(e,t)=>(0,J.jsxs)(K,{"aria-labelledby":t,className:`w-full`,disabled:!D.length||n||s||e>0&&!v[0],value:v[e]||``,onChange:t=>void j(e,t.target.value),children:[(0,J.jsx)(`option`,{value:``,children:a(`config:providerWorkbench.fallbackNone`)}),v[e]&&!D.some(t=>qi(t)===v[e])&&(0,J.jsx)(`option`,{value:v[e],children:v[e]}),D.map(e=>(0,J.jsx)(`option`,{value:qi(e),children:`${e.model.name||e.model.id} · ${e.provider.name}`},e.value))]});return(0,J.jsxs)(`section`,{"data-config-card":`models-current-model`,"aria-labelledby":`${o}-heading`,"aria-busy":s||void 0,className:`mt-6 min-w-0`,children:[(0,J.jsx)(`h2`,{id:`${o}-heading`,className:`sr-only`,children:a(`config:configPage.currentChatModel`)}),(0,J.jsxs)(`div`,{"data-config-target":`models-runtime-policy`,className:`border-t border-stroke`,children:[(0,J.jsx)(Ji,{labelId:`${o}-model`,label:a(`config:providerWorkbench.defaultModel`),hint:a(`config:providerWorkbench.defaultModelHint`),children:(0,J.jsxs)(K,{"aria-labelledby":`${o}-model`,className:`w-full`,disabled:!D.length||n||s,value:D.some(e=>e.value===O)?O:``,onChange:e=>{let[t,n]=e.target.value.split(Ki),r=E.find(e=>e.id===t);r&&n&&i(r,n)},children:[!D.length&&(0,J.jsx)(`option`,{value:``,children:a(`config:providerWorkbench.noChatModel`)}),D.map(({provider:e,model:t,value:n})=>(0,J.jsx)(`option`,{value:n,children:`${Dt(t.name||t.id,D.map(e=>e.model.name||e.model.id))} · ${e.name}`},n))]})}),(0,J.jsx)(Ji,{labelId:`${o}-fallback`,label:a(`config:providerWorkbench.fallbackModels`),hint:a(`config:providerWorkbench.fallbackModelsHint`),children:(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,J.jsx)(`span`,{id:`${o}-fallback-1`,className:`sr-only`,children:a(`config:providerWorkbench.fallbackFirst`)}),ee(0,`${o}-fallback ${o}-fallback-1`),v[0]&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{id:`${o}-fallback-2`,className:`sr-only`,children:a(`config:providerWorkbench.fallbackSecond`)}),ee(1,`${o}-fallback ${o}-fallback-2`)]})]})}),(0,J.jsx)(Ji,{labelId:`${o}-auxiliary`,label:a(`config:providerWorkbench.auxiliaryModel`),hint:a(`config:providerWorkbench.auxiliaryModelHint`),children:(0,J.jsxs)(K,{"aria-labelledby":`${o}-auxiliary`,"aria-describedby":`${o}-auxiliary-hint`,className:`w-full`,disabled:!D.length||n||s,value:b,onChange:e=>void M(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:a(`config:providerWorkbench.auxiliaryFollowSession`)}),b&&!D.some(e=>qi(e)===b)&&(0,J.jsx)(`option`,{value:b,children:b}),D.map(e=>(0,J.jsx)(`option`,{value:qi(e),children:`${e.model.name||e.model.id} · ${e.provider.name}`},e.value))]})}),(0,J.jsx)(Ji,{labelId:`${o}-thinking`,label:a(`config:configPage.thinkingLevel`),hint:a(`config:providerWorkbench.thinkingHint`),children:(0,J.jsx)(K,{"aria-labelledby":`${o}-thinking`,className:`w-full font-mono`,disabled:A,value:p,onChange:e=>{m(e.target.value),k({thinkingLevel:e.target.value})},children:Gi.map(e=>(0,J.jsx)(`option`,{children:e},e))})}),(0,J.jsx)(Ji,{labelId:`${o}-tools`,label:a(`config:configPage.availableTools`),hint:a(`config:providerWorkbench.toolsHint`),children:(0,J.jsxs)(K,{"aria-labelledby":`${o}-tools`,className:`w-full`,disabled:A,value:h,onChange:e=>{g(e.target.value),k({toolMode:e.target.value})},children:[(0,J.jsx)(`option`,{value:`full`,children:a(`config:configPage.fullToolAccess`)}),(0,J.jsx)(`option`,{value:`custom`,children:a(`config:configPage.customManageEachToolOnThePluginsPage`)})]})})]}),(!T||s)&&(0,J.jsxs)(`p`,{className:`mt-2 flex items-center gap-2 text-xs text-content-muted`,role:`status`,children:[s&&(0,J.jsx)(R,{className:`size-3`}),a(s?`config:configPage.saving`:`config:providerWorkbench.defaultsNeedProvider`)]}),u&&(0,J.jsx)(W,{children:u})]})}var Xi=[`fast`,`standard`,`strong`],Zi={listProfiles(){return f(`/api/agent-profiles`)},saveModelTiers(e){return f(`/api/config/subagent-model-tiers`,{method:`PUT`,body:JSON.stringify({tiers:e})})}};function Qi({config:e,notify:t,busy:n,onConfigChanged:r}){let{t:i}=l(),a=e=>i(e===`fast`?`config:subagents.tierFast`:e===`standard`?`config:subagents.tierStandard`:`config:subagents.tierStrong`),o=e=>i(e===`fast`?`config:subagents.tierFastHint`:e===`standard`?`config:subagents.tierStandardHint`:`config:subagents.tierStrongHint`),s=(0,q.useId)(),[c,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(``),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(``),_=e.subagentModelTiers||{},v=Xi.map(e=>_[e]||``).join(`
4
4
  `),[y,b]=(0,q.useState)(_);(0,q.useEffect)(()=>{let e=v.split(`
5
- `);b(Object.fromEntries(Xi.map((t,n)=>[t,e[n]]).filter(([,e])=>e)))},[v]),(0,q.useEffect)(()=>{let e=!0;return Zi.listProfiles().then(t=>e&&m(t)).catch(t=>{e&&(m({profiles:[],errors:[]}),g(t instanceof Error?t.message:String(t)))}),()=>{e=!1}},[]);let x=e.providers.filter(e=>e.type===`chat`&&e.configured&&e.enabled).flatMap(e=>e.models.filter(e=>e.kind===`chat`).map(t=>({provider:e,name:t.name||t.id,id:t.id}))),S=x.map(({provider:e,name:t,id:n})=>({value:`${e.id}/${n}`,label:`${Dt(t,x.map(e=>e.name))} · ${e.name}`})),C=async(e,n)=>{let a=y,o={...y,[e]:n};n||delete o[e],b(o),u(!0),f(``);try{r(await Zi.saveModelTiers(o)),t(i(`config:subagents.tiersSaved`))}catch(e){b(a),f(e instanceof Error?e.message:String(e))}finally{u(!1)}},w=Xi.filter(e=>y[e]).length,T=p?.profiles||[],E=p?.errors||[];return(0,J.jsx)(`section`,{"aria-labelledby":`${s}-heading`,"aria-busy":c||void 0,"data-config-card":`models-subagents`,"data-config-target":`models-subagents`,className:`min-w-0 border-t border-stroke`,children:(0,J.jsx)(Pe,{type:`single`,collapsible:!0,children:(0,J.jsxs)(Ne,{value:`subagents`,children:[(0,J.jsx)(je,{children:(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,J.jsx)(`span`,{id:`${s}-heading`,children:i(`config:subagents.title`)}),(0,J.jsx)(`span`,{className:`truncate text-xs font-normal text-content-muted`,children:w?i(`config:subagents.configuredSummary`,{count:w}):i(`config:subagents.followSession`)})]})}),(0,J.jsxs)(Me,{className:`h-auto`,children:[(0,J.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`config:subagents.hint`)}),(0,J.jsx)(`div`,{className:`mt-3 border-t border-stroke`,children:Xi.map(e=>{let t=y[e]||``;return(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-6 gap-y-2 border-b border-stroke py-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-[min(240px,100%)] flex-1`,children:[(0,J.jsxs)(`div`,{id:`${s}-${e}`,className:`text-sm text-content`,children:[a(e),(0,J.jsx)(`code`,{className:`ml-2 font-mono text-xs text-content-muted`,children:e})]}),(0,J.jsx)(`p`,{id:`${s}-${e}-hint`,className:`mt-0.5 text-xs text-content-muted`,children:o(e)})]}),(0,J.jsx)(`div`,{className:`w-[min(280px,100%)] min-w-0 max-[650px]:w-full`,children:(0,J.jsxs)(K,{"aria-labelledby":`${s}-${e}`,"aria-describedby":`${s}-${e}-hint`,className:`w-full`,disabled:!S.length||n||c,value:t,onChange:t=>void C(e,t.target.value),children:[(0,J.jsx)(`option`,{value:``,children:i(`config:subagents.followSession`)}),t&&!S.some(e=>e.value===t)&&(0,J.jsx)(`option`,{value:t,children:t}),S.map(e=>(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value))]})})]},e)})}),d&&(0,J.jsx)(W,{children:d}),(0,J.jsx)(`h3`,{className:`mt-5 text-[13px] font-medium text-content`,children:i(`config:subagents.globalDefinitions`)}),(0,J.jsx)(`p`,{className:`mt-0.5 text-xs text-content-muted`,children:i(`config:subagents.definitionsHint`)}),p===null?(0,J.jsxs)(`p`,{role:`status`,className:`mt-3 flex items-center gap-2 text-xs text-content-muted`,children:[(0,J.jsx)(R,{className:`size-3`}),i(`config:subagents.loading`)]}):T.length===0&&E.length===0?(0,J.jsx)(`p`,{className:`mt-3 text-xs text-content-muted`,children:i(`config:subagents.empty`)}):(0,J.jsxs)(`ul`,{className:`mt-3 flex min-w-0 flex-col border-t border-stroke`,children:[T.map(e=>(0,J.jsxs)(`li`,{className:`min-w-0 border-b border-stroke py-2 text-[13px]`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`code`,{className:`shrink-0 font-mono text-content`,children:e.name}),(0,J.jsxs)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:[e.modelRef||e.tier||i(`config:subagents.inheritModel`),e.thinkingLevel?` · ${e.thinkingLevel}`:``,e.tools?` · ${i(`config:subagents.toolCount`,{count:e.tools.length})}`:``]})]}),(0,J.jsx)(`p`,{className:`mt-0.5 text-xs text-content-secondary`,children:e.description})]},e.name)),E.map(e=>(0,J.jsxs)(`li`,{className:`min-w-0 border-b border-stroke py-2 text-[13px]`,children:[(0,J.jsx)(`code`,{className:`font-mono text-danger`,children:e.file||e.scope}),(0,J.jsx)(`p`,{className:`mt-0.5 text-xs text-danger`,children:e.message})]},`${e.scope}:${e.file}`))]}),h&&(0,J.jsx)(W,{children:h})]})]})})})}function $i(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)||e}function ea({notify:e}){let{t}=l(),n=(0,q.useId)(),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(!1),[u,d]=(0,q.useState)(`allow`),[f,p]=(0,q.useState)(`bash`),[m,h]=(0,q.useState)(``);(0,q.useEffect)(()=>{let e=!0;return y.list().then(t=>e&&i(t.rules)).catch(t=>{e&&(i([]),o(t instanceof Error?t.message:String(t)))}),()=>{e=!1}},[]);let g=async(t,n)=>{c(!0),o(``);try{return i((await t()).rules),e(n),!0}catch(e){return o(e instanceof Error?e.message:String(e)),!1}finally{c(!1)}},_=async()=>{let e=m.trim();e&&await g(()=>y.add({effect:u,tool:f,pattern:e}),t(`config:permissionRules.added`))&&h(``)};return(0,J.jsx)(`section`,{"aria-labelledby":`${n}-heading`,"data-config-card":`models-permission-rules`,"data-config-target":`models-permission-rules`,className:`min-w-0 border-b border-stroke`,children:(0,J.jsx)(Pe,{type:`single`,collapsible:!0,children:(0,J.jsxs)(Ne,{value:`rules`,children:[(0,J.jsx)(je,{children:(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,J.jsx)(`span`,{id:`${n}-heading`,children:t(`config:permissionRules.title`)}),(0,J.jsx)(`span`,{className:`truncate text-xs font-normal text-content-muted`,children:r===null?``:r.length?t(`config:permissionRules.countSummary`,{count:r.length}):t(`config:permissionRules.noneSummary`)})]})}),(0,J.jsxs)(Me,{className:`h-auto`,children:[(0,J.jsx)(`p`,{className:`text-xs text-content-muted`,children:t(`config:permissionRules.hint`)}),r===null?(0,J.jsxs)(`p`,{role:`status`,className:`mt-3 flex items-center gap-2 text-xs text-content-muted`,children:[(0,J.jsx)(R,{className:`size-3`}),t(`config:permissionRules.loading`)]}):r.length===0?(0,J.jsx)(`p`,{className:`mt-3 text-xs text-content-muted`,children:t(`config:permissionRules.empty`)}):(0,J.jsx)(`ul`,{className:`mt-3 flex min-w-0 flex-col border-t border-stroke`,children:r.map(e=>(0,J.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 border-b border-stroke py-2 text-[13px]`,children:[(0,J.jsx)(`span`,{className:e.effect===`deny`?`shrink-0 rounded-sm bg-danger-soft px-1.5 text-xs text-danger`:`shrink-0 rounded-sm bg-surface-hover px-1.5 text-xs text-content-secondary`,children:e.effect===`deny`?t(`config:permissionRules.deny`):t(`config:permissionRules.allow`)}),(0,J.jsx)(`span`,{className:`shrink-0 text-xs text-content-muted`,children:e.tool===`files`?t(`config:permissionRules.files`):t(`config:permissionRules.command`)}),(0,J.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-content`,title:e.pattern,children:e.pattern}),(0,J.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate text-xs text-content-muted`,title:e.cwd||void 0,children:e.cwd?$i(e.cwd):t(`config:permissionRules.global`)}),(0,J.jsx)(z,{variant:`ghost`,size:`icon-xs`,className:`shrink-0 pointer-coarse:size-11`,disabled:s,"aria-label":t(`config:permissionRules.remove`,{pattern:e.pattern}),title:t(`config:permissionRules.remove`,{pattern:e.pattern}),onClick:()=>void g(()=>y.remove(e.id),t(`config:permissionRules.removed`)),children:(0,J.jsx)(be,{})})]},e.id))}),(0,J.jsxs)(`form`,{className:`mt-3 flex min-w-0 flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,J.jsxs)(K,{"aria-label":t(`config:permissionRules.effectLabel`),className:`w-28`,disabled:s,value:u,onChange:e=>{let t=e.target.value===`deny`?`deny`:`allow`;d(t),t===`deny`&&p(`bash`)},children:[(0,J.jsx)(`option`,{value:`allow`,children:t(`config:permissionRules.allow`)}),(0,J.jsx)(`option`,{value:`deny`,children:t(`config:permissionRules.deny`)})]}),(0,J.jsxs)(K,{"aria-label":t(`config:permissionRules.toolLabel`),className:`w-32`,disabled:s||u===`deny`,value:f,onChange:e=>p(e.target.value===`files`?`files`:`bash`),children:[(0,J.jsx)(`option`,{value:`bash`,children:t(`config:permissionRules.command`)}),(0,J.jsx)(`option`,{value:`files`,children:t(`config:permissionRules.files`)})]}),(0,J.jsx)(B,{"aria-label":t(`config:permissionRules.patternLabel`),className:`h-[34px] min-w-[12rem] flex-1 font-mono text-[13px] max-[650px]:h-11`,disabled:s,maxLength:200,placeholder:t(f===`files`?`config:permissionRules.filesPlaceholder`:`config:permissionRules.commandPlaceholder`),value:m,onChange:e=>h(e.target.value)}),(0,J.jsxs)(z,{type:`submit`,variant:`secondary`,disabled:s||!m.trim(),className:`max-[650px]:min-h-11`,children:[s&&(0,J.jsx)(R,{className:`size-3`}),t(`config:permissionRules.add`)]})]}),a&&(0,J.jsx)(W,{children:a})]})]})})})}function ta(e){return e instanceof Error?e.message:String(e)}function na({notify:e,requestConfirm:t,t:n}){let[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(!0),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(``),[d,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(``),[g,_]=(0,q.useState)(``),v=(0,q.useRef)(0),y=(0,q.useRef)(!1);(0,q.useEffect)(()=>{let e=!0;y.current=!0;let t=v.current;return f(`/api/config`).then(n=>{if(e)return v.current===t&&i(n),o(!1),f(`/api/providers/models/refresh`,{method:`POST`,body:`{}`})}).then(n=>{!e||v.current!==t||!n?.config||i(n.config)}).catch(n=>{!e||v.current!==t||(c(ta(n)),o(!1))}),()=>{e=!1,y.current=!1,v.current+=1}},[]);let b=(0,q.useCallback)(e=>{v.current+=1,i(e),o(!1),c(``)},[]),x=(0,q.useCallback)(async()=>{let e=v.current,t=await f(`/api/config`);y.current&&v.current===e&&b(t)},[b]),S=(0,q.useCallback)(async(t,r)=>{u(t.id),c(``);try{let i=await f(`/api/providers/${encodeURIComponent(t.id)}/enabled`,{method:`PUT`,body:JSON.stringify({enabled:r})});b(i),e(n(`config:configPage.nameState`,{name:t.name,state:n(r?`config:configPage.enabled`:`config:configPage.disabled`)}))}catch(e){c(ta(e))}finally{u(``)}},[b,e,n]),C=(0,q.useCallback)(async t=>{p(t.id),c(``);try{let r=await f(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:t.id,setAsDefault:!0})});b(r),e(n(`config:configPage.defaultProviderUpdated`,{name:t.name}))}catch(e){c(ta(e))}finally{p(``)}},[b,e,n]),w=(0,q.useCallback)(async(t,r)=>{h(t.id),c(``);try{let i=await f(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:t.id,model:r,setAsDefault:!1})});b(i),e(n(`config:configPage.providerConnectionUpdated`))}catch(e){c(ta(e))}finally{h(``)}},[b,e,n]),T=(0,q.useCallback)(async(t,r)=>{p(t.id),c(``);try{let i=await f(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:t.id,model:r,setAsDefault:!1})});(i.defaultProvider||i.provider)!==t.id&&(i=await f(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:t.id,setAsDefault:!0})})),b(i),e(n(`config:configPage.defaultProviderUpdated`,{name:t.name}))}catch(e){c(ta(e))}finally{p(``)}},[b,e,n]),E=(0,q.useCallback)(async()=>{o(!0),c(``);let e=v.current;try{let t=await f(`/api/config`);y.current&&v.current===e&&b(t)}catch(e){y.current&&c(ta(e))}finally{y.current&&o(!1)}},[b]),D=(0,q.useCallback)(async(r,i)=>{if(await t({title:n(`providers:modelEditor.delete`),message:n(`providers:modelEditor.deleteConfirmation`,{name:i.name||i.id}),confirmLabel:n(`config:configPage.delete`)})){_(`${r.id}/${i.id}`),c(``);try{b(await vi.deleteModel(r.id,i.id)),e(n(`providers:modelEditor.deleted`))}catch(e){c(ta(e))}finally{_(``)}}},[b,e,t,n]);return{config:r,loading:a,error:s,toggling:l,settingDefault:d,settingModel:m,deletingModel:g,applyConfig:b,refreshConfig:x,setDefaultProvider:C,setDefaultChatModel:T,setProviderDefaultModel:w,reload:E,toggleProvider:S,deleteProvider:(0,q.useCallback)(async r=>{if(await t({title:n(`config:configPage.deleteProviderConnection`),message:n(`config:configPage.deleteNameItsModelSettingsAndAuthenticationDetailsWillAlsoBeRemoved`,{name:r.name}),confirmLabel:n(`config:configPage.delete`)})){c(``);try{let t=await f(`/api/providers/${encodeURIComponent(r.id)}`,{method:`DELETE`});b(t),e(n(`config:configPage.providerConnectionDeleted`))}catch(e){c(ta(e))}}},[b,e,t,n]),deleteModel:D}}function ra({requestConfirm:e,onImported:t,onAutoImported:n,t:r}){let[i,a]=(0,q.useState)({providers:[],errors:[]}),[o,s]=(0,q.useState)(!0),[c,l]=(0,q.useState)(``),[u,d]=(0,q.useState)(``),[p,m]=(0,q.useState)(``),[h,g]=(0,q.useState)({imported:0,skipped:0}),_=(0,q.useRef)(0),v=(0,q.useRef)(n);v.current=n;let y=(0,q.useCallback)(async()=>{let e=++_.current;s(!0),l(``);try{let t=await vi.importLocal();if(e!==_.current)return;a(t.discovery),g({imported:t.imported.length,skipped:t.skipped.length}),t.imported.length&&await v.current()}catch(t){e===_.current&&l(ta(t))}finally{e===_.current&&s(!1)}},[]);return(0,q.useEffect)(()=>(y(),()=>{_.current+=1}),[y]),{discovery:i,autoImport:h,discovering:o,error:c,operationError:u,importing:p,refresh:y,importProvider:(0,q.useCallback)(async n=>{let i=n.source===`codex-config`?`Codex config.toml`:n.source===`claude-config`?`Claude settings.json`:n.source===`codex-auth`?`Codex login`:`Claude login`,o=n.kind===`authentication`;if(await e({title:r(o?`config:configPage.loadLoginState`:`config:configPage.loadProviderConfiguration`),message:r(o?`config:configPage.loadOfficialProviderLoginStateFromSource`:`config:configPage.loadThisProviderConfigurationFromSource`,{source:i}),confirmLabel:r(o?`config:configPage.loadLoginState`:`config:configPage.loadConfiguration`)})){m(n.id),d(``);try{let e=await f(`/api/providers/${encodeURIComponent(n.id)}/import`,{method:`POST`,body:`{}`});a(e.discovery),t(e)}catch(e){d(ta(e))}finally{m(``)}}},[t,e,r])}}function ia({providers:e,defaultProviderId:t=``,toggling:n,settingDefault:r=``,settingModel:i=``,onConfigure:a,onClone:o,onSetDefault:s,onSetDefaultModel:c,onToggle:u,onDelete:d}){let{t:f}=l(),p=e.filter(e=>e.configured||e.custom);return(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:p.map(e=>{let l=_i[e.id]||ge,p=e.id===t,m=e.configured?e.enabled?f(`config:configPage.authenticationReady`):f(`config:configPage.disabled2`):e.id===`openai-codex`?f(`config:configPage.codexCLILoginRequired`):f(`config:configPage.apiKeyRequired`);return(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 rounded-md border border-stroke bg-panel px-3 py-2.5`,children:[(0,J.jsxs)(`button`,{type:`button`,title:f(`config:configPage.configure`),className:`flex min-h-9 min-w-0 cursor-pointer items-center gap-2.5 rounded-sm border-0 bg-transparent p-0 text-left text-content hover:text-accent-fg`,onClick:()=>a(e),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-7.5 flex-none place-items-center rounded-md border border-key-border bg-key text-content-muted shadow-key`,children:(0,J.jsx)(l,{size:15})}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),p&&(0,J.jsx)(It,{variant:`accent`,children:f(`config:configPage.defaultBadge`)})]}),c&&e.models.some(e=>e.kind===`chat`)?(0,J.jsxs)(`label`,{className:`grid min-w-0 gap-1 text-xs text-content-muted`,children:[f(`config:configPage.providerDefaultModel`),(0,J.jsxs)(K,{"aria-label":`${f(`config:configPage.providerDefaultModel`)}: ${e.name}`,value:e.defaultModel||``,disabled:!!(i||r),onChange:t=>void c(e,t.target.value),children:[!e.models.some(t=>t.kind===`chat`&&t.id===e.defaultModel)&&(0,J.jsx)(`option`,{value:e.defaultModel||``,disabled:!0,children:e.defaultModel||f(`config:configPage.selectModel`)}),e.models.filter(e=>e.kind===`chat`).map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}):e.defaultModel?(0,J.jsxs)(`small`,{className:`truncate font-mono text-xs text-content-muted`,title:e.defaultModel,children:[f(`config:configPage.providerDefaultModel`),`: `,e.defaultModel]}):null,(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`small`,{className:`text-xs text-content-muted`,children:m}),(0,J.jsxs)(`div`,{className:`flex flex-none items-center gap-1.5`,children:[s&&(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 pointer-coarse:size-11`,title:f(`config:configPage.setAsDefaultProvider`),"aria-label":f(`config:configPage.setAsDefaultProvider`),"aria-pressed":p,disabled:p||!e.configured||!e.enabled||!e.defaultModel||!!(r||i),onClick:()=>void s(e),children:(0,J.jsx)(Nn,{size:13})}),(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 pointer-coarse:size-11`,title:f(`config:configPage.cloneProvider`),"aria-label":f(`config:configPage.cloneProvider`),onClick:()=>o(e),children:(0,J.jsx)(M,{size:13})}),(0,J.jsx)(br,{ariaLabel:f(`config:configPage.providerEnabled`,{name:e.name}),value:e.configured&&e.enabled,disabled:!e.configured||n===e.id,onChange:t=>u(e,t)}),e.custom&&(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 hover:bg-danger-soft hover:text-danger pointer-coarse:size-11`,title:f(`config:configPage.deleteProvider`),"aria-label":f(`config:configPage.deleteProvider`),onClick:()=>void d(e),children:(0,J.jsx)(be,{size:13})})]})]})]},e.id)})})}var aa=`pisper.config.visualConnectionsOpen`,$={running:null,result:null,error:``};function oa(){return r.getItem(aa)===`1`}function sa({config:e,notify:t,toggling:n,onToggleProvider:i,onDeleteProvider:a,onCloneProvider:o,onQuickSetup:s,onEditVisualProvider:c}){let{t:u}=l(),[d,p]=(0,q.useState)(null),[m,h]=(0,q.useState)(!0),[g,_]=(0,q.useState)(``),[v,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(``),[w,T]=(0,q.useState)(oa),O=(0,q.useCallback)(async()=>{try{p(await f(`/api/visual/models`)),C(``)}catch(e){C(e instanceof Error?e.message:String(e))}finally{h(!1)}},[]);(0,q.useEffect)(()=>{O()},[O,e]),(0,q.useEffect)(()=>{$.result&&x($.result),$.error&&C($.error);let e=$.running;if(!e)return;y(!0);let t=!0;return e.then(e=>{t&&x(e)}).catch(()=>{t&&C($.error)}).finally(()=>{t&&y(!1)}),()=>{t=!1}},[]);let j=async(e,n)=>{_(e),C(``);try{p(await f(`/api/visual/models/${e}`,{method:`PUT`,body:JSON.stringify({model:n})})),t(u(`config:configPage.visualModelUpdated`))}catch(e){C(e instanceof Error?e.message:String(e))}finally{_(``)}},M=async()=>{if($.running)return;y(!0),C(``),x(null),$.result=null,$.error=``;let e=f(`/api/visual/test`,{method:`POST`,body:`{}`,timeout:21e4});$.running=e;try{let n=await e;$.result=n,x(n),t(u(`config:configPage.testSucceeded`))}catch(e){let n=e instanceof Error?e.message:String(e);$.error=n,C(n),t(n)}finally{$.running=null,y(!1)}},ee=e=>{T(e),r.setItem(aa,e?`1`:`0`)},N=e.providers.filter(e=>e.type===`visual`),P=N.filter(e=>e.configured||e.custom),te=d?.imageModels||[],ne=d?.videoModels||[];return(0,J.jsxs)(`section`,{className:`mt-3`,children:[(0,J.jsxs)(_r,{className:`mb-3 py-3.5`,"data-config-card":`models-visual`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:L(`grid size-9.5 flex-none place-items-center rounded-lg border border-key-border bg-key shadow-key`,d?.image?`text-accent-fg`:`text-content-muted`),children:(0,J.jsx)(ve,{size:18})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-content-muted`,children:u(`config:configPage.currentVisualModel`)}),m?(0,J.jsxs)(`span`,{role:`status`,className:`flex items-center gap-2 text-xs text-content-muted`,children:[(0,J.jsx)(R,{className:`size-3.5`}),u(`config:configPage.loadingVisualStatus`)]}):d?.image?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`span`,{className:`truncate text-sm font-medium text-content`,children:[d.image.providerName,` / `,d.image.name]}),(0,J.jsxs)(yr,{tone:`green`,children:[(0,J.jsx)(A,{size:11,className:`mr-[3px] inline`}),u(`config:configPage.authenticationReady`)]})]}),d.video&&(0,J.jsxs)(`small`,{className:`text-xs text-content-muted [overflow-wrap:anywhere]`,children:[u(`config:configPage.visualVideoModel`),`:`,d.video.providerName,` /`,` `,d.video.name]})]}):(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-warning-strong`,children:[(0,J.jsx)(k,{size:14,"aria-hidden":`true`}),u(`config:configPage.visualNoneConfigured`)]}),(0,J.jsx)(`small`,{className:`text-xs text-content-muted`,children:u(`config:configPage.visualEmptyHint`)})]})]}),(0,J.jsxs)(`div`,{className:`flex w-full max-w-full min-w-0 flex-none flex-wrap items-center gap-2 sm:w-auto`,children:[d?.image&&(0,J.jsxs)(z,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:v,onClick:()=>void M(),children:[v?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(re,{size:13}),u(v?`config:configPage.testingGeneration`:`config:configPage.testGeneration`)]}),(0,J.jsxs)(z,{className:`max-[650px]:h-11`,onClick:s,children:[(0,J.jsx)(Ln,{size:13}),u(`config:configPage.visualQuickSetup`)]})]})]}),b&&(0,J.jsxs)(`div`,{className:`mt-3 flex items-center gap-2.5 rounded-sm border border-stroke-soft bg-surface-subtle px-2.5 py-2`,children:[b.previewDataUrl?(0,J.jsx)(`img`,{src:b.previewDataUrl,alt:b.modelName,className:`size-11 flex-none rounded-xs object-cover`}):(0,J.jsx)(E,{size:16,className:`flex-none text-success`}),(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-px text-xs`,children:[(0,J.jsx)(`span`,{className:`font-medium text-success-strong`,children:u(`config:configPage.testSucceeded`)}),(0,J.jsxs)(`span`,{className:`truncate font-mono text-content-muted`,children:[b.providerName,` / `,b.modelName,` · `,b.path]})]})]})]}),(0,J.jsxs)(Jt,{open:w,onOpenChange:ee,children:[(0,J.jsx)(qt,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`group flex min-h-9 w-full cursor-pointer items-center gap-2 rounded-sm border-0 bg-transparent px-0.5 text-left max-[650px]:min-h-11`,children:[(0,J.jsx)(D,{size:16,"aria-hidden":`true`,className:`flex-none text-content-muted transition-transform group-data-[state=closed]:-rotate-90`}),(0,J.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-content`,children:u(`config:configPage.visualConnections`)}),(0,J.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:u(`config:configPage.visualConnectionsHint`)})]})}),(0,J.jsx)(Kt,{children:(0,J.jsxs)(_r,{className:`mt-2 py-4`,children:[(0,J.jsx)(ia,{providers:N,toggling:n,onClone:o,onConfigure:e=>c(e.id),onToggle:i,onDelete:a}),P.length===0&&(0,J.jsx)(`p`,{className:`text-xs text-content-muted`,children:u(`config:configPage.visualEmptyHint`)}),(te.length>0||ne.length>0)&&(0,J.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 border-t border-stroke-soft pt-3`,children:[te.length>0&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`w-16 flex-none text-xs text-content-muted`,children:u(`config:configPage.visualImageModel`)}),(0,J.jsxs)(K,{className:`min-w-0 flex-1`,value:d?.imageSelection||``,disabled:g===`image`,"aria-label":u(`config:configPage.visualImageModel`),onChange:e=>void j(`image`,e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:u(`config:configPage.visualAutoSelected`)}),te.map(e=>(0,J.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),ne.length>0&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`w-16 flex-none text-xs text-content-muted`,children:u(`config:configPage.visualVideoModel`)}),(0,J.jsxs)(K,{className:`min-w-0 flex-1`,value:d?.videoSelection||``,disabled:g===`video`,"aria-label":u(`config:configPage.visualVideoModel`),onChange:e=>void j(`video`,e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:u(`config:configPage.visualAutoSelected`)}),ne.map(e=>(0,J.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),(0,J.jsx)(`small`,{className:`text-xs text-content-muted`,children:u(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]})]})})]}),S&&(0,J.jsx)(`div`,{className:`mt-2.5`,children:(0,J.jsxs)(Rt,{children:[(0,J.jsx)(xe,{size:13}),S]})})]})}var ca=`pisper.config.manageConnectionsOpen`;function la(){let e=r.getItem(ca);return e===`1`||e!==`0`&&null}function ua({defaultAdvancedExpanded:e=!1,navigationKey:n,notify:i,registerPrimaryAction:a,requestConfirm:o}){let{t:s}=l(),c=t(),u=new URLSearchParams(c.search).get(`import`)===`1`,[d,f]=(0,q.useState)(``),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(null),[_,v]=(0,q.useState)(()=>u||e?!0:la());(0,q.useEffect)(()=>{u&&v(!0)},[u]),(0,q.useEffect)(()=>{e&&v(!0)},[e,n]);let y=na({notify:i,requestConfirm:o,t:s}),{config:b}=y,x=ra({requestConfirm:o,onAutoImported:y.refreshConfig,onImported:e=>{y.applyConfig(e.config);let t=e.config.providers.find(t=>t.id===e.providerId);i(e.kind===`authentication`?s(`config:configPage.nameLoginStateHasBeenLoadedIntoPisper`,{name:t?.name||e.providerId}):s(`config:configPage.nameConfigurationHasBeenLoadedIntoPisper`,{name:t?.name||e.providerId}))},t:s});if(fi(a,()=>m({providerType:`chat`})),!b)return y.error&&!y.loading?(0,J.jsx)(Ot,{kind:`error`,title:s(`config:providerWorkbench.loadFailed`),description:y.error,action:(0,J.jsx)(z,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void y.reload(),children:s(`common:pageTemplate.retry`)})}):(0,J.jsx)(Ot,{kind:`loading`,title:s(`config:configPage.loadingModelCatalog`),description:s(`config:configPage.readingProvidersAndAuthenticationStatus`)});let S=_??!1,C=Fi(x.discovery),w=e=>{v(e),r.setItem(ca,e?`1`:`0`)},T=e=>g(e);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Yi,{config:b,notify:i,busy:!!(y.settingDefault||y.toggling),onConfigChanged:y.applyConfig,onSetDefaultModel:y.setDefaultChatModel}),(0,J.jsx)(ki,{config:b,selectedProviderId:d,onSelectProvider:f,toggling:y.toggling,settingDefault:y.settingDefault,settingModel:y.settingModel,onSave:e=>{y.applyConfig(e),i(s(`config:configPage.providerConnectionUpdated`))},onClone:T,onDelete:y.deleteProvider,deletingModel:y.deletingModel,onDeleteModel:y.deleteModel,onToggle:y.toggleProvider,onSetDefault:y.setDefaultProvider,onSetDefaultModel:y.setProviderDefaultModel,onAddConnection:()=>m({providerType:`chat`}),meta:(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,role:`status`,children:[x.discovering&&(0,J.jsx)(R,{className:`size-3`}),x.discovering?s(`config:providerWorkbench.scanningLocal`):s(`config:providerWorkbench.localImportStatus`,{imported:x.autoImport.imported,skipped:x.autoImport.skipped})]})}),y.error&&(0,J.jsx)(W,{children:y.error}),(0,J.jsxs)(`div`,{className:`mt-8`,"data-config-advanced":!0,children:[(0,J.jsx)(Qi,{config:b,notify:i,busy:!!(y.settingDefault||y.toggling),onConfigChanged:y.applyConfig}),(0,J.jsx)(ea,{notify:i})]}),C>0&&(0,J.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-2 gap-y-0 text-xs text-content-muted`,children:[(0,J.jsx)(`span`,{children:s(`config:configPage.localProviderImportHint`,{count:C})}),(0,J.jsx)(z,{type:`button`,variant:`link`,size:`sm`,className:`h-auto min-h-11 shrink-0 px-1 py-0 font-medium sm:min-h-8`,"aria-expanded":S,"aria-controls":`model-connection-management`,onClick:()=>w(!0),children:s(`config:configPage.reviewLocalProviders`)})]}),(0,J.jsxs)(Jt,{open:S,onOpenChange:w,"data-config-card":`models-advanced`,children:[(0,J.jsx)(qt,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`group mt-6 mb-3 flex min-h-9 w-full cursor-pointer items-center gap-2 rounded-sm border-0 bg-transparent px-0.5 text-left max-[650px]:min-h-11`,children:[(0,J.jsx)(D,{size:16,"aria-hidden":`true`,className:`shrink-0 text-content-muted transition-transform group-data-[state=closed]:-rotate-90`}),(0,J.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-content`,children:s(`config:providerWorkbench.advanced`)}),(0,J.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:s(`config:providerWorkbench.advancedHint`)})]})}),(0,J.jsxs)(Kt,{id:`model-connection-management`,children:[(0,J.jsx)(Hi,{discovery:x.discovery,discovering:x.discovering,error:x.error||x.operationError,importing:x.importing,forceVisible:u,onRefresh:x.refresh,onImport:x.importProvider}),(0,J.jsx)(sa,{config:b,notify:i,toggling:y.toggling,onToggleProvider:y.toggleProvider,onCloneProvider:T,onDeleteProvider:y.deleteProvider,onQuickSetup:()=>m({providerType:`visual`}),onEditVisualProvider:e=>{let t=b.providers.find(t=>t.id===e);t&&(f(t.id),requestAnimationFrame(()=>document.querySelector(`[data-provider-row="${CSS.escape(t.id)}"]`)?.scrollIntoView({block:`start`,behavior:`smooth`})))}})]})]}),p&&(0,J.jsx)(Wi,{config:b,providerType:p.providerType||`chat`,initialProviderId:p.providerId,onConfigChanged:e=>{y.applyConfig(e),e.createdProviderId&&f(e.createdProviderId)},onClose:()=>m(null),onCompleted:e=>{y.applyConfig(e),e.createdProviderId&&f(e.createdProviderId),i(s(`config:configPage.setupComplete`)),m(null)}}),h&&(0,J.jsx)(Pi,{initialProviderType:h.type,cloneProvider:h,onClose:()=>g(null),onCreated:e=>{y.applyConfig(e),e.createdProviderId&&f(e.createdProviderId),i(s(`config:configPage.providerConnectionCreated`)),g(null)}})]})}var da=[`browser`,`feishu`,`weixin`,`qq`,`telegram`];function fa(e){if(!e||typeof e!=`object`||Array.isArray(e))throw d();return e}function pa(e,t){if(typeof e!=`string`||e.length>t)throw d();return e}function ma(e){let t=fa(e),n=fa(t.browser);if(typeof n.enabled!=`boolean`||!Array.isArray(t.templates)||!Array.isArray(t.scopes))throw d();let r={},i=fa(t.connections);for(let e of da){if(e===`browser`||i[e]===void 0)continue;let t=i[e];if(t===null){r[e]=null;continue}let n=fa(t);if(n.enabled!==void 0&&typeof n.enabled!=`boolean`||n.status!==void 0&&typeof n.status!=`string`)throw d();r[e]={...n,enabled:n.enabled,status:n.status}}let a=new Set,o=t.templates.map(e=>{let t=fa(e),n=pa(t.id,200);if(!n||a.has(n)||typeof t.enabled!=`boolean`||!Array.isArray(t.variables))throw d();a.add(n);let r={},i=fa(t.channels);for(let e of da){if(i[e]===void 0)continue;let t=fa(i[e]);if(t.enabled!==void 0&&typeof t.enabled!=`boolean`)throw d();r[e]={content:pa(t.content,12e3),...t.enabled===void 0?{}:{enabled:t.enabled}}}return{id:n,name:pa(t.name,500),description:pa(t.description,2e3),enabled:t.enabled,variables:t.variables.map(e=>pa(e,200)),channels:r}}),s=t.scopes.map(e=>{let t=fa(e);if(!da.includes(t.platform))throw d();return{...t,platform:t.platform}});return{browser:{enabled:n.enabled},connections:r,scopes:s,templates:o}}function ha(e){let t=fa(e);if(typeof t.sent!=`number`||!Number.isInteger(t.sent)||t.sent<0)throw d();return{sent:t.sent,...t.title===void 0?{}:{title:pa(t.title,2e3)},...t.body===void 0?{}:{body:pa(t.body,12e3)},...t.preview===void 0?{}:{preview:pa(t.preview,12e3)}}}function ga(e){return e.templates.length>0&&e.templates.every(e=>da.every(t=>typeof e.channels[t]?.enabled==`boolean`))}var _a=(e,t)=>`/api/settings/notifications/templates/${encodeURIComponent(e)}/${t}`,va=(e,t,n,r)=>u(_a(e,t),{method:`PUT`,body:n,...r,parse:ma}),ya={load:(e={})=>u(`/api/settings/notifications`,{...e,parse:ma}),setBrowserEnabled:(e,t={})=>u(`/api/settings/notifications/browser`,{method:`PATCH`,body:{enabled:e},...t,parse:ma}),setEventEnabled:(e,t,n={})=>va(e,`browser`,{enabled:t},n),setChannelEnabled:async(e,t,n,r={})=>{let i=await va(e,t,{channelEnabled:n},r);if(i.templates.find(t=>t.id===e)?.channels[t]?.enabled!==n)throw d();return i},saveTemplate:(e,t,n,r={})=>va(e,t,{content:n},r),testSavedTemplate:(e,t,n={})=>u(`${_a(e,t)}/test`,{method:`POST`,body:{},...n,parse:ha})},ba=e=>e instanceof Error?e.message:String(e),xa=(e,t)=>`${e}\0${t}`,Sa=e=>e.kind===`browser`?`browser`:e.kind===`event`?`event:${e.event}`:`channel:${e.event}:${e.platform}`;function Ca(e,t){if(t.kind===`browser`)return e.browser.enabled;let n=e.templates.find(e=>e.id===t.event);return t.kind===`event`?n?.enabled===!0:n?.channels[t.platform]?.enabled!==!1}function wa(e,t,n){return t.kind===`browser`?{...e,browser:{enabled:n}}:{...e,templates:e.templates.map(e=>e.id===t.event?t.kind===`event`?{...e,enabled:n}:{...e,channels:{...e.channels,[t.platform]:{...e.channels[t.platform],enabled:n}}}:e)}}function Ta(e){let[t,n]=(0,q.useState)(null),r=(0,q.useRef)(null),i=(0,q.useRef)(e);i.current=e;let[a,o]=(0,q.useState)(!0),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)({}),[f,p]=(0,q.useState)({}),m=(0,q.useRef)({}),[h,g]=(0,q.useState)({}),[_,v]=(0,q.useState)({}),y=(0,q.useRef)(!1),b=(0,q.useRef)(null),x=(0,q.useRef)(new Map),S=(0,q.useRef)(new Map),C=(0,q.useRef)(new Set),w=(0,q.useRef)(0),T=(0,q.useRef)(0),E=(0,q.useCallback)(e=>{r.current=e,T.current++,n(e),i.current?.(e)},[]),D=(0,q.useCallback)(async()=>{if(!y.current)return;b.current?.abort();let e=new AbortController;b.current=e;let t=T.current;o(!0),c(``);try{let n=await ya.load({signal:e.signal});y.current&&!e.signal.aborted&&t===T.current&&E(n)}catch(t){y.current&&!e.signal.aborted&&c(ba(t))}finally{y.current&&!e.signal.aborted&&o(!1)}},[E]);(0,q.useEffect)(()=>{y.current=!0,D();let e=x.current,t=S.current;return()=>{y.current=!1,b.current?.abort();for(let t of e.values())t.abort();e.clear(),t.clear()}},[D]);let O=async(e,t)=>{if(!y.current||!r.current)return;let n=Sa(e),i={target:e,value:t,revision:++w.current};if(S.current.set(n,i),u(r=>({...r,[n]:{target:e,value:t,pending:!0,error:``}})),x.current.has(n))return;let a=new AbortController;x.current.set(n,a);try{for(;S.current.has(n)&&y.current&&!a.signal.aborted;){let t=S.current.get(n);S.current.delete(n);try{if(Ca(r.current,e)!==t.value||C.current.has(n)){let i={signal:a.signal},o=e.kind===`browser`?await ya.setBrowserEnabled(t.value,i):e.kind===`event`?await ya.setEventEnabled(e.event,t.value,i):await ya.setChannelEnabled(e.event,e.platform,t.value,i);if(!y.current||a.signal.aborted)return;E(wa(r.current,e,Ca(o,e))),C.current.delete(n)}S.current.has(n)||u(r=>({...r,[n]:{target:e,value:t.value,pending:!1,error:``}}))}catch(r){if(!y.current||a.signal.aborted)return;C.current.add(n),S.current.has(n)||u(i=>({...i,[n]:{target:e,value:t.value,pending:!1,error:ba(r)}}))}}}finally{x.current.get(n)===a&&x.current.delete(n)}},k=t;if(k)for(let e of Object.values(l))e.pending&&(k=wa(k,e.target,e.value));let A=(e,t,n)=>{let r=xa(e,t),i={...m.current,[r]:{event:e,platform:t,content:n,revision:++w.current}};m.current=i,p(i)},j=(e,n)=>{let r=xa(e,n),i=t?.templates.find(t=>t.id===e)?.channels[n]?.content||``,a=f[r]?.content??i;return{content:a,dirty:a!==i,save:h[r]||{pending:!1,error:``},test:_[r]||{pending:!1,error:``}}};return{dirty:Object.values(f).some(e=>e.content!==(t?.templates.find(t=>t.id===e.event)?.channels[e.platform]?.content||``)),saving:Object.values(l).some(e=>e.pending)||Object.values(h).some(e=>e.pending),discard:()=>{m.current={},p({})},data:k,confirmed:t,loading:a,loadError:s,load:D,mutations:l,supportsChannels:t?ga(t):!1,setBrowserEnabled:e=>O({kind:`browser`},e),setEventEnabled:(e,t)=>O({kind:`event`,event:e},t),setChannelEnabled:(e,t,n)=>O({kind:`channel`,event:e,platform:t},n),retryMutation:e=>O(e.target,e.value),draft:j,editDraft:A,saveTemplate:async(e,t)=>{let n=xa(e,t),i=`content:${n}`,a=m.current[n];if(!y.current||!a||!a.content.trim()||x.current.has(i))return!1;let o=new AbortController;x.current.set(i,o),g(e=>({...e,[n]:{pending:!0,error:``}}));try{let i=await ya.saveTemplate(e,t,a.content,{signal:o.signal});if(!y.current||o.signal.aborted)return!1;let s=i.templates.find(t=>t.id===e)?.channels[t]?.content;if(s===void 0)throw d();E({...r.current,templates:r.current.templates.map(n=>n.id===e?{...n,channels:{...n.channels,[t]:{...n.channels[t],content:s}}}:n)});let c=m.current[n]?.revision===a.revision;return c&&(m.current={...m.current,[n]:{...a,content:s}},p(m.current)),g(e=>({...e,[n]:{pending:!1,error:``}})),c}catch(e){return y.current&&!o.signal.aborted&&g(t=>({...t,[n]:{pending:!1,error:ba(e)}})),!1}finally{x.current.get(i)===o&&x.current.delete(i)}},testTemplate:async(e,t)=>{let n=xa(e,t),r=`test:${n}`;if(!y.current||x.current.has(r)||j(e,t).dirty)return;let i=new AbortController;x.current.set(r,i),v(e=>({...e,[n]:{pending:!0,error:``}}));try{let r=await ya.testSavedTemplate(e,t,{signal:i.signal});return!y.current||i.signal.aborted?void 0:(v(e=>({...e,[n]:{pending:!1,error:``}})),r)}catch(e){y.current&&!i.signal.aborted&&v(t=>({...t,[n]:{pending:!1,error:ba(e)}}))}finally{x.current.get(r)===i&&x.current.delete(r)}}}}function Ea(e,t){let n={"chat.title":t(`config:notificationSettings.fixChannelNotification`),"chat.summary":t(`config:notificationSettings.implementationIsCompleteTestsAndBuildHavePassed`),"chat.tool":`bash`,"chat.reason":t(`config:notificationSettings.confirmationIsRequired`),"chat.model":`openai/gpt-5.4`,"task.name":t(`config:notificationSettings.dailyCodeReview`),"task.summary":t(`config:notificationSettings.found2IssuesToAddressTheReportHasBeenArchived`),"task.duration":t(`config:notificationSettings.message2Min18Sec`),"task.nextRun":t(`config:notificationSettings.tomorrow0900`),"task.error":t(`config:notificationSettings.testProcessTimedOut`),"workflow.name":t(`config:notificationSettings.preReleaseChecks`),"workflow.summary":t(`config:notificationSettings.testsBuildAndSecurityChecksHaveAllPassed`),"workflow.duration":t(`config:notificationSettings.message6Min42Sec`),"workflow.runId":`run_20260718_001`,"workflow.node":t(`config:notificationSettings.endToEndTests`),"workflow.error":t(`config:notificationSettings.browserFailedToStart`)};return String(e||``).replace(/\{\{\s*([\w.]+)\s*\}\}/g,(e,t)=>n[t]||`{{${t}}}`)}function Da({settings:e,templates:t,eventId:n,platform:r,onSelectionChange:i,platformLabel:a,permissionGranted:o,onBrowserTest:s,notify:c}){let{t:u}=l(),d=(0,q.useRef)(!0),[f,p]=(0,q.useState)(``);(0,q.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let m=t.find(e=>e.id===n)||t[0];if(!m||!e.data)return(0,J.jsx)(`p`,{role:`status`,children:u(`config:notificationSettings.noNotificationEvents`)});let h=e.draft(m.id,r),g=r===`browser`?null:e.data.connections[r],_=r===`browser`?e.confirmed?.browser.enabled===!0&&!e.mutations.browser?.pending&&o:g?.enabled===!0&&e.data.scopes.some(e=>e.platform===r),v=async()=>{p(``);let t=await e.testTemplate(m.id,r);if(!(!t||!d.current))try{r===`browser`&&await s(t.title||m.name,t.body||t.preview||``,`pisper-template-${m.id}`),d.current&&c(r===`browser`?u(`config:notificationSettings.theTestNotificationWasSentCheckYourSystemNotificationCenter`):u(`config:notificationSettings.testNotificationSentToCountChats`,{count:t.sent}))}catch(e){d.current&&p(e instanceof Error?e.message:String(e))}};return(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(`h2`,{className:`text-[15px] leading-6 font-medium text-content`,children:u(`config:notificationSettings.notificationTemplates`)}),(0,J.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[u(`config:notificationSettings.notificationEvent`),(0,J.jsx)(K,{"aria-label":u(`config:notificationSettings.notificationEvent`),value:m.id,onChange:e=>i(e.target.value,r),children:t.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[u(`config:notificationSettings.notificationChannel`),(0,J.jsx)(K,{"aria-label":u(`config:notificationSettings.notificationChannel`),value:r,onChange:e=>{let t=da.find(t=>t===e.target.value);t&&i(m.id,t)},children:da.map(e=>(0,J.jsx)(`option`,{value:e,children:a(e)},e))})]})]}),(0,J.jsx)(`p`,{className:`text-xs text-content-muted`,children:m.description}),(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[u(`config:notificationSettings.messageContent`),(0,J.jsx)(Et,{"aria-label":u(`config:notificationSettings.messageContent`),value:h.content,onChange:t=>e.editDraft(m.id,r,t.target.value),className:`min-h-36 p-3 font-mono text-[12.5px] leading-[1.65] font-normal`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-content-muted`,children:[(0,J.jsx)(`span`,{children:u(`config:notificationSettings.availableVariables`)}),m.variables.map(e=>(0,J.jsx)(`code`,{className:`rounded-xs bg-inline-code px-1.5 py-0.5 font-mono text-content-secondary`,children:`{{${e}}}`},e))]}),(0,J.jsxs)(`div`,{className:`rounded-md border border-stroke bg-code p-3`,children:[(0,J.jsx)(`p`,{className:`text-xs font-medium text-content-muted`,children:u(`config:notificationSettings.preview`)}),(0,J.jsx)(`pre`,{className:`mt-2 font-sans text-sm break-words whitespace-pre-wrap text-content`,children:Ea(h.content,u)})]}),(0,J.jsx)(`p`,{className:`text-xs text-content-muted`,children:h.dirty?u(`config:notificationSettings.saveBeforeTest`):u(`config:notificationSettings.testUsesSavedTemplate`)}),!_&&(0,J.jsx)(`p`,{role:`status`,className:`text-xs text-content-muted`,children:u(`config:notificationSettings.channelTestUnavailable`)}),(h.save.error||h.test.error||f)&&(0,J.jsx)(Rt,{children:h.save.error||h.test.error||f}),(0,J.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,J.jsx)(z,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:h.dirty||h.save.pending||!_,loading:h.test.pending,onClick:()=>void v(),children:u(`config:notificationSettings.sendTest`)}),(0,J.jsx)(z,{"data-template-save":!0,className:`max-[650px]:h-11`,loading:h.save.pending,disabled:!h.dirty||!h.content.trim(),onClick:async()=>{await e.saveTemplate(m.id,r)&&c(u(`config:notificationSettings.notificationTemplateSaved`))},children:u(`config:notificationSettings.saveTemplate`)})]})]})}function Oa(e,t){switch(t){case`chime`:return e(`config:notificationSounds.soundChime`);case`marimba`:return e(`config:notificationSounds.soundMarimba`);case`drop`:return e(`config:notificationSounds.soundDrop`);case`bell`:return e(`config:notificationSounds.soundBell`);default:return e(`config:notificationSounds.soundLow`)}}function ka(e,t){return e(t===`waiting`?`config:notificationSounds.eventWaiting`:t===`finished`?`config:notificationSounds.eventFinished`:`config:notificationSounds.eventFailed`)}function Aa(e,t){return e(t===`waiting`?`config:notificationSounds.eventWaitingHint`:t===`finished`?`config:notificationSounds.eventFinishedHint`:`config:notificationSounds.eventFailedHint`)}function ja(){let{t:e}=l(),t=Qt(),[n,r]=(0,q.useState)(null),i=n??t.volume,a=e=>{e!==`none`&&$t(e,t.volume)};return(0,J.jsxs)($r,{"data-config-card":`notifications-sounds`,title:e(`config:notificationSounds.title`),description:e(`config:notificationSounds.description`),children:[(0,J.jsx)(Q,{title:e(`config:notificationSounds.enabled`),control:(0,J.jsx)(tt,{checked:t.enabled,"aria-label":e(`config:notificationSounds.enabled`),onCheckedChange:e=>t.update({enabled:e})})}),sn.map(n=>{let r=t.sounds[n];return(0,J.jsx)(Q,{"data-sound-event":n,title:ka(e,n),description:Aa(e,n),control:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(K,{value:r,className:`w-32`,"aria-label":ka(e,n),disabled:!t.enabled,onChange:e=>{let r=e.target.value;t.setSound(n,r),a(r)},children:[(0,J.jsx)(`option`,{value:`none`,children:e(`config:notificationSounds.soundNone`)}),nn.map(t=>(0,J.jsx)(`option`,{value:t,children:Oa(e,t)},t))]}),(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,className:`pointer-coarse:size-11`,disabled:!t.enabled||r===`none`,"aria-label":e(`config:notificationSounds.preview`,{event:ka(e,n)}),title:e(`config:notificationSounds.preview`,{event:ka(e,n)}),onClick:()=>a(r),children:(0,J.jsx)(ue,{"aria-hidden":`true`})})]})},n)}),(0,J.jsx)(Q,{title:e(`config:notificationSounds.volume`),control:(0,J.jsxs)(`div`,{className:`flex w-48 items-center gap-3`,children:[(0,J.jsx)(et,{min:0,max:100,step:5,value:[i],disabled:!t.enabled,"aria-label":e(`config:notificationSounds.volume`),valueText:`${i}%`,onValueChange:([e])=>r(e),onValueCommit:([e])=>{r(null),t.update({volume:e});let n=t.sounds.waiting;n!==`none`&&$t(n,e)}}),(0,J.jsxs)(`span`,{className:`w-9 text-right text-xs text-content-muted tabular-nums`,children:[i,`%`]})]})}),(0,J.jsx)(Q,{title:e(`config:notificationSounds.whileFocused`),description:e(`config:notificationSounds.whileFocusedHint`),control:(0,J.jsx)(tt,{checked:t.whileFocused,disabled:!t.enabled,"aria-label":e(`config:notificationSounds.whileFocused`),onCheckedChange:e=>t.update({whileFocused:e})})})]})}function Ma(e,t){return t(e===`feishu`?`config:notificationSettings.feishu`:e===`weixin`?`config:notificationSettings.weChat`:e===`qq`?`config:notificationSettings.qq`:e===`telegram`?`config:notificationSettings.telegram`:`config:notificationSettings.systemNotificationChannel`)}function Na(e,t,n){return e===`chat.completed`?n(`config:notificationSettings.chatCompleted`):e===`chat.waiting`?n(`config:notificationSettings.chatWaiting`):e===`schedule.completed`?n(`config:notificationSettings.scheduleCompleted`):e===`schedule.failed`?n(`config:notificationSettings.scheduleFailed`):e===`workflow.completed`?n(`config:notificationSettings.workflowCompleted`):e===`workflow.failed`?n(`config:notificationSettings.workflowFailed`):t}function Pa(e,t,n){return e===`chat.completed`?n(`config:notificationSettings.chatCompletedDescription`):e===`chat.waiting`?n(`config:notificationSettings.chatWaitingDescription`):e===`schedule.completed`?n(`config:notificationSettings.scheduleCompletedDescription`):e===`schedule.failed`?n(`config:notificationSettings.scheduleFailedDescription`):e===`workflow.completed`?n(`config:notificationSettings.workflowCompletedDescription`):e===`workflow.failed`?n(`config:notificationSettings.workflowFailedDescription`):t}function Fa(){return typeof window<`u`&&window.pisperDesktop?.showNotification?window.pisperDesktop.getNotificationStatus?`checking`:`granted`:typeof window<`u`&&on()?`checking`:vn()}function Ia(e,t){return t(e===`system-disabled`||e===`app-disabled`?`config:notificationSettings.systemNotificationsAreOffAllowPisperToSendNotificationsInYourOperatingSystemSettings`:e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.theOperatingSystemDidNotAcceptTheNotificationCheckYourSystemNotificationSettings`)}function La(e){return e instanceof Error?e.message:String(e)}function Ra({notify:e,onBrowserNotificationChange:t}){let{t:r,language:i}=l(),a=(0,q.useRef)(!1);(0,q.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let o=Ta(t),{data:s,loading:c,loadError:u}=o,[d,f]=n(),p=!!window.pisperDesktop?.showNotification,m=on(),[h,g]=(0,q.useState)(Fa),_=o.mutations.browser?.pending===!0,v=(0,q.useCallback)(async()=>{if(!p)return;let e=window.pisperDesktop?.getNotificationStatus;if(!e){g(`granted`);return}try{let t=await e();if(!a.current)return;let n=t?.permission;g(n==="default"||n===`denied`||n===`granted`||n===`checking`||n===`unsupported`?n:t?.supported===!1?`unsupported`:`granted`)}catch{a.current&&g(`unsupported`)}},[p]);(0,q.useEffect)(()=>{if(!p)return;v();let e=()=>{v()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[p,v]);let y=(0,q.useCallback)(async()=>{if(!(p||!m))try{let e=await tn();if(!a.current)return;g(e===!0?`granted`:e===!1?`denied`:`default`)}catch{a.current&&g(`unsupported`)}},[p,m]);(0,q.useEffect)(()=>{if(p||!m)return;y();let e=()=>void y();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[p,m,y]);let b=async t=>{let n=``;if(t){if(p&&h!==`granted`)n=Ia(`system-disabled`,r);else if(!p&&m){let e=`denied`;try{let t=await tn()===!0?`granted`:await rn();e=t===`granted`?`granted`:t===`denied`?`denied`:`default`}catch{e=`unsupported`}if(!a.current)return;g(e),e!==`granted`&&(n=r(`config:notificationSettings.systemNotificationsAreOffAllowPisperToSendNotificationsInYourOperatingSystemSettings`))}else if(!p){let e=await _n();if(!a.current)return;if(g(e),e!==`granted`)n=r(e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`);else try{await gn()}catch{n=r(`config:notificationSettings.theBrowserBackgroundNotificationServiceCouldNotBeRegistered`)}}}a.current&&(await o.setBrowserEnabled(t),n&&a.current&&e(n,`info`))},x=(0,q.useCallback)(async(e,t,n=`pisper-browser-test`)=>{if(p){let n=window.pisperDesktop?.showNotification;if(!n)throw Error(r(`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`));let i=await n({title:e,body:t});if(i&&typeof i==`object`&&i.shown===!1)throw g(i.permission??`denied`),Error(Ia(i.reason,r));return i}return m?(await Zt(e,t),{shown:!0,transport:`tauri`}):hn({title:e,body:t,tag:n,url:window.location.href})},[p,m,r]),S=async()=>{if(!(!o.confirmed?.browser.enabled||_)){if(h!==`granted`){e(h===`unsupported`?Ia(`unsupported`,r):p?Ia(`system-disabled`,r):r(`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`),`error`);return}try{await x(r(`config:notificationSettings.appNotificationTest`,{app:we}),r(`config:notificationSettings.notificationsAreWorking`)),e(r(`config:notificationSettings.theTestNotificationWasSentCheckYourSystemNotificationCenter`),`info`)}catch(t){e(La(t)||r(`config:notificationSettings.theOperatingSystemDidNotAcceptTheNotificationCheckYourSystemNotificationSettings`),`error`)}}},w=async()=>{try{await window.pisperDesktop?.openNotificationSettings?.()||e(r(`config:notificationSettings.openNotificationPermissionsInYourOperatingSystemSettings`),`info`)}catch{e(r(`config:notificationSettings.openNotificationPermissionsInYourOperatingSystemSettings`),`info`)}};if(c)return(0,J.jsxs)(Ht,{children:[(0,J.jsx)(R,{className:`size-6`}),(0,J.jsx)(`h2`,{children:r(`config:notificationSettings.loadingNotificationSettings`)})]});if(!s)return(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(Rt,{children:u}),(0,J.jsx)(z,{variant:`outline`,onClick:()=>void o.load(),children:r(`common:pageTemplate.retry`)})]});let T=(e=s.templates[0]?.id||``,t=`browser`)=>{f(n=>{let r=new URLSearchParams(n);return r.set(`view`,`templates`),e&&r.set(`event`,e),r.set(`channel`,t),r})},E=d.get(`view`)===`templates`,D=s.templates.map(e=>({...e,name:Na(e.id,e.name,r),description:Pa(e.id,e.description,r)}));if(E)return(0,J.jsxs)(`div`,{"data-config-card":`notifications-templates`,className:`space-y-4`,children:[(0,J.jsxs)(z,{variant:`ghost`,className:`-ml-2.5 pointer-coarse:h-11`,onClick:()=>f(e=>{let t=new URLSearchParams(e);return t.delete(`view`),t.delete(`event`),t.delete(`channel`),t}),children:[(0,J.jsx)(O,{size:16,"aria-hidden":`true`}),r(`config:notificationSettings.backToCategories`)]}),(0,J.jsx)(Da,{settings:o,templates:D,eventId:d.get(`event`)||``,platform:da.find(e=>e===d.get(`channel`))||`browser`,onSelectionChange:T,platformLabel:e=>Ma(e,r),permissionGranted:h===`granted`,onBrowserTest:x,notify:e})]});let k=r(h===`granted`?`config:notificationSettings.permissionGranted`:h===`denied`?p?`config:notificationSettings.systemNotificationsAreOff`:`config:notificationSettings.browserNotificationsAreBlocked`:h===`unsupported`?`config:notificationSettings.notSupported`:h===`checking`?`config:notificationSettings.checking`:`config:notificationSettings.waitingForPermission`),A=h===`granted`?`green`:h==="default"?`amber`:`gray`;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[u&&(0,J.jsx)(Rt,{children:u}),Object.entries(o.mutations).filter(([,e])=>e.error).map(([e,t])=>(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(Rt,{children:t.error}),(0,J.jsx)(z,{variant:`outline`,size:`sm`,onClick:()=>void o.retryMutation(t),children:r(`common:pageTemplate.retry`)})]},e)),(0,J.jsxs)(_r,{className:`browser-notification-card py-4`,"data-config-card":`notifications-browser`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:L(`grid size-9.5 shrink-0 place-items-center rounded-lg border border-key-border bg-key shadow-key`,s.browser.enabled?`text-accent-fg`:`text-content-muted`),children:s.browser.enabled?(0,J.jsx)(C,{size:18}):(0,J.jsx)(yn,{size:18})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-content`,children:r(`config:notificationSettings.systemNotificationChannel`)}),(0,J.jsx)(`p`,{className:`mt-0.5 text-xs leading-[1.45] text-content-muted`,children:r(`config:notificationSettings.pisperUsesTheCurrentPlatformNotificationSystemWhenAnAgentCompletesOrFails`)})]}),(0,J.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[(0,J.jsx)(yr,{tone:A,children:k}),(0,J.jsx)(br,{ariaLabel:r(`config:notificationSettings.systemNotificationChannel`),value:s.browser.enabled,disabled:_||h===`checking`,onChange:b})]})]}),(0,J.jsxs)(Lt,{children:[(0,J.jsx)(_e,{size:15}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`strong`,{children:r(p?`config:notificationSettings.controlledByOperatingSystemNotificationSettings`:`config:notificationSettings.controlledByBrowserSitePermissions`)}),(0,J.jsx)(`small`,{children:r(p?`config:notificationSettings.theDesktopAppUsesOperatingSystemNotificationsTurningThisOffDoesNotChangeTheOperatingSystemPermis`:`config:notificationSettings.theWebAppUsesBrowserSiteNotificationsTurningThisOffDoesNotChangeTheBrowserPermissionItself`)})]})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex gap-2 max-[650px]:flex-wrap`,children:[p&&h===`denied`&&(0,J.jsxs)(z,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:w,children:[(0,J.jsx)(_e,{size:14}),r(`config:notificationSettings.openSystemNotificationSettings`)]}),(0,J.jsxs)(z,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:!s.browser.enabled||_||h!==`granted`,onClick:S,children:[(0,J.jsx)(C,{size:14}),r(`config:notificationSettings.sendTestNotification`)]})]})]}),(0,J.jsx)(ja,{}),(0,J.jsxs)($r,{title:r(`config:notificationSettings.notificationCategories`),description:r(`config:notificationSettings.channelPreferenceHint`),action:(0,J.jsx)(z,{variant:`ghost`,size:`sm`,className:`pointer-coarse:h-11`,onClick:()=>T(),children:r(`config:notificationSettings.editNotificationTemplates`)}),children:[!o.supportsChannels&&(0,J.jsx)(`p`,{role:`status`,className:`py-2 text-sm text-content-muted`,children:r(`config:notificationSettings.channelPreferencesUnsupported`)}),D.length>0&&(0,J.jsx)(xr,{children:D.map(e=>{let t=e.enabled?da.filter(t=>e.channels[t]?.enabled!==!1):[],n=Object.entries(o.mutations).some(([t,n])=>n.pending&&(t===`event:${e.id}`||t.startsWith(`channel:${e.id}:`)));return(0,J.jsx)(Q,{"data-notification-event":e.id,title:e.name,description:e.description,control:(0,J.jsxs)(We,{children:[(0,J.jsx)(He,{asChild:!0,children:(0,J.jsx)(z,{variant:`outline`,size:`sm`,className:`max-w-full font-normal text-content-secondary pointer-coarse:h-11`,"aria-label":r(`config:notificationSettings.eventChannels`,{event:e.name}),"aria-busy":n,children:(0,J.jsx)(`span`,{className:`max-w-64 truncate`,children:t.length?t.map(e=>Ma(e,r)).join(i===`zh-CN`?`、`:`, `):r(`config:notificationSettings.channelsOff`)})})}),(0,J.jsxs)(Ue,{align:`end`,className:`max-w-[calc(100vw-40px)] min-w-56`,children:[(0,J.jsx)(Ve,{checked:e.enabled,onCheckedChange:t=>void o.setEventEnabled(e.id,t===!0),children:r(`config:notificationSettings.enableEvent`)}),(0,J.jsx)(ze,{}),da.map(t=>{let n=t===`browser`?s.browser.enabled:s.connections[t]?.enabled===!0&&s.scopes.some(e=>e.platform===t);return(0,J.jsxs)(Ve,{checked:e.channels[t]?.enabled!==!1,disabled:!o.supportsChannels,onCheckedChange:n=>void o.setChannelEnabled(e.id,t,n===!0),children:[(0,J.jsx)(`span`,{children:Ma(t,r)}),!n&&(0,J.jsx)(`small`,{className:`ml-2 text-muted-foreground`,children:r(`config:notificationSettings.channelNeedsSetup`)})]},t)}),(0,J.jsx)(ze,{}),(0,J.jsx)(Be,{onSelect:()=>T(e.id),children:r(`config:notificationSettings.editNotificationTemplates`)})]})]})},e.id)})}),!D.length&&(0,J.jsx)(`p`,{role:`status`,className:`py-3 text-sm text-content-muted`,children:r(`config:notificationSettings.noNotificationEvents`)})]})]})}function za({notify:e}){let{t}=l(),n=window.pisperDesktop,[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(``);(0,q.useEffect)(()=>{if(!n?.getCliStatus)return;let e=!0;return n.getCliStatus().then(t=>e&&i(t)).catch(t=>e&&c(t instanceof Error?t.message:String(t))),()=>{e=!1}},[n]);let u=!!(n?.getCliStatus&&n.installCli&&n.uninstallCli),d=async()=>{if(n?.installCli){o(`install`),c(``);try{let r=await n.installCli();i(r),e(t(`config:cliSettings.installedNotification`))}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(``)}}},f=async()=>{if(n?.uninstallCli){o(`uninstall`),c(``);try{let r=await n.uninstallCli();i(r),e(t(`config:cliSettings.uninstalledNotification`))}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(``)}}},p=u&&!r,m=u?p?t(`config:cliSettings.checking`):r?.supported?r.needsRepair?t(`config:cliSettings.needsRepair`):r.installed?t(`config:cliSettings.installed`):t(`config:cliSettings.notInstalled`):t(`config:cliSettings.unavailable`):t(`config:cliSettings.unavailable`);return(0,J.jsxs)(U,{"data-config-card":`updates-cli`,title:t(`config:cliSettings.title`),description:t(`config:cliSettings.description`),actions:(0,J.jsx)(`span`,{className:`text-xs text-content-secondary`,children:m}),children:[r&&(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3 border-t border-stroke py-3`,children:[r.installed&&!r.needsRepair?(0,J.jsx)(A,{className:`mt-0.5 shrink-0 text-content-muted`,size:16,"aria-hidden":`true`}):(0,J.jsx)(Fn,{className:`mt-0.5 shrink-0 text-content-muted`,size:16,"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`grid min-w-0 gap-0.5`,children:[(0,J.jsx)(`strong`,{className:`text-sm font-medium text-content`,children:r.installed?t(`config:cliSettings.commandReady`,{command:r.command}):t(`config:cliSettings.commandNotInstalled`,{command:r.command})}),(0,J.jsx)(`small`,{className:`font-mono text-xs [overflow-wrap:anywhere] text-content-muted`,children:r.installPath}),r.installed&&(0,J.jsx)(`small`,{className:`text-xs text-content-muted`,children:r.pathConfigured?t(`config:cliSettings.pathConfigured`):t(`config:cliSettings.pathNeedsRepair`)})]})]}),s&&(0,J.jsx)(W,{children:s}),u&&(0,J.jsxs)(`div`,{className:`mt-3 flex gap-2 max-[650px]:flex-wrap`,children:[r?.installed&&(0,J.jsxs)(z,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:!!a,onClick:()=>void f(),children:[a===`uninstall`?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(be,{size:14}),t(`config:cliSettings.uninstall`)]}),(!r?.installed||r.needsRepair)&&(0,J.jsxs)(z,{type:`button`,className:`max-[650px]:h-11`,disabled:!!a||p||r?.supported===!1,onClick:()=>void d(),children:[a===`install`?(0,J.jsx)(R,{className:`text-current`}):r?.needsRepair?(0,J.jsx)(Se,{size:14}):(0,J.jsx)(ee,{size:14}),r?.needsRepair?t(`config:cliSettings.repair`):t(`config:cliSettings.install`)]})]}),u&&(0,J.jsx)(`small`,{className:`mt-2 block text-xs text-content-muted`,children:t(`config:cliSettings.restartTerminal`)})]})}var Ba=`0.6.18`;function Va(e,t){return!e.desktop&&!e.mobile?t(`config:updateSettings.browserMode`):`${{win32:`Windows`,darwin:`macOS`,linux:`Linux`,android:`Android`,ios:`iOS`}[e.platform]||e.platform} · ${e.arch}`}function Ha(e,t){let n=Number(e)||0;if(!n)return`0 B`;let r=[`B`,`KB`,`MB`,`GB`],i=Math.min(r.length-1,Math.floor(Math.log(n)/Math.log(1024)));return`${(n/1024**i).toLocaleString(t,{maximumFractionDigits:1})} ${r[i]}`}function Ua({notify:e,update:t}){let{t:n,language:r}=l(),i=t?.info||{desktop:!1,packaged:!1,version:Ba,platform:`browser`,arch:``},a=t?.status||{state:`idle`},o=!!i.desktop,s=!!i.mobile,c=o||s,[u,d]=(0,q.useState)({version:Ba,date:``,notes:``}),[f,p]=(0,q.useState)(``);(0,q.useEffect)(()=>{let e=!0;return fetch(`/release-notes.json`,{cache:`no-store`}).then(e=>e.ok?e.json():null).then(t=>{e&&t&&d(t)}).catch(()=>{}),()=>{e=!1}},[]);let m=async()=>{if(t){p(`check`);try{await t.check()}finally{p(``)}}},h=()=>t?.openReleases(),g=()=>t?.openUpdateLog?.(),_=async()=>{p(o?`install`:``);try{o?await t?.installComponents():await t?.download()}catch(t){e(t instanceof Error?t.message:String(t),`error`)}finally{p(``)}},v=()=>t?.install(),y=u.version===i.version?u:null,b=a.notes||(c?y?.notes||n(`config:updateSettings.noReleaseNotesAreAvailableForThisVersion`):a.state===`current`?n(`config:updateSettings.theCurrentWebSourceIsSyncedWithBranch`,{branch:a.branch||`release`}):n(`config:updateSettings.commitsThatHaveNotBeenSyncedWillAppearHereAfterTheCheck`)),S=a.state===`available`,C=a.state===`error`&&a.canResume&&a.canDownload,w=a.state===`downloaded`,T=a.state===`checking`||f===`check`,E=a.state===`downloading`||f===`install`,D=T?`checking`:E?`downloading`:a.state,O=c?`v${i.version}`:`v${i.version}${a.currentCommit?` · ${a.currentCommit.slice(0,7)}`:``}`,k=c?`v${a.availableVersion||y?.version||i.version}`:a.availableCommit?.slice(0,7)||a.currentCommit?.slice(0,7)||u.version||i.version,j=(0,q.useMemo)(()=>{let e=new Map(t.components.map(e=>[e.component,e]));return[`desktop`,`tui`,`runtime`].map(t=>e.get(t)||{component:t,state:`idle`,currentVersion:t===`desktop`?i.version:`--`,availableVersion:``,message:``,releaseUrl:``,notes:``,size:0,transferred:0,canInstall:!1,restartRequired:!1})},[i.version,t.components]),M={idle:n(`config:updateSettings.notChecked`),checking:n(`config:updateSettings.checking`),current:n(`config:updateSettings.upToDate`),available:n(c?`config:updateSettings.updateAvailable`:`config:updateSettings.sourceUpdatesAvailable`),downloading:n(`config:updateSettings.downloading`),downloaded:n(`config:updateSettings.readyToRestart`),installed:n(`config:updateSettings.upToDate`),error:n(C?`config:updateSettings.downloadPaused`:`config:updateSettings.checkFailed`)}[D]||n(`config:updateSettings.notChecked`);return(0,J.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col`,children:[(0,J.jsxs)(U,{"data-config-card":`updates-main`,className:`mt-6`,title:n(`config:updateSettings.pisperAppUpdates`),actions:(0,J.jsx)(`span`,{"data-update-status":D,className:`text-xs text-content-secondary tabular-nums`,children:M}),children:[(0,J.jsxs)(`dl`,{className:`grid border-y border-stroke max-sm:divide-y max-sm:divide-stroke-soft sm:grid-cols-3`,children:[(0,J.jsxs)(`div`,{className:`py-3 sm:pr-4`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(c?`config:updateSettings.currentVersion`:`config:updateSettings.currentSource`)}),(0,J.jsx)(`dd`,{className:`mt-1 font-mono text-[12.5px] font-medium text-content`,children:O})]}),(0,J.jsxs)(`div`,{className:`py-3 sm:border-l sm:border-stroke-soft sm:px-4`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(`config:updateSettings.platform`)}),(0,J.jsx)(`dd`,{className:`mt-1 text-sm font-medium text-content`,children:Va(i,n)})]}),(0,J.jsxs)(`div`,{className:`py-3 sm:border-l sm:border-stroke-soft sm:pl-4`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(`config:updateSettings.updateChannel`)}),(0,J.jsx)(`dd`,{className:`mt-1 font-mono text-[12.5px] font-medium text-content`,children:c?`Stable`:a.branch||`release`})]})]}),a.message&&(a.state===`error`?(0,J.jsx)(W,{children:a.message}):(0,J.jsxs)(`p`,{className:`mt-4 flex items-start gap-2 text-sm text-content-secondary`,children:[(0,J.jsx)(wn,{className:`mt-0.5 shrink-0 text-content-muted`,size:15,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`min-w-0`,children:a.message})]})),C&&(0,J.jsx)(`small`,{className:`mt-2 block text-xs text-content-muted`,children:n(`config:updateSettings.downloadedDataWasPreservedAndCanResumeFromTheInterruptionPoint`)}),E&&(0,J.jsxs)(`div`,{className:`mt-4`,children:[(0,J.jsxs)(`div`,{className:`flex justify-between text-xs text-content-muted`,children:[(0,J.jsx)(`span`,{children:n(`config:updateSettings.downloadProgress`)}),(0,J.jsxs)(`span`,{className:`tabular-nums`,children:[Math.round(a.percent||0),`% · `,Ha(a.transferred,r),` /`,` `,Ha(a.total,r)]})]}),(0,J.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-surface-active`,children:(0,J.jsx)(`i`,{className:`block h-full bg-star transition-[width]`,style:{width:`${a.percent||0}%`}})})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,J.jsxs)(z,{className:`max-[650px]:h-11`,disabled:T||E||!!f,onClick:w?v:S||C?_:m,children:[T||E?(0,J.jsx)(R,{className:`text-current`}):w?(0,J.jsx)(pe,{size:14}):S||C?a.canDownload?(0,J.jsx)(ee,{size:14}):(0,J.jsx)(P,{size:14}):(0,J.jsx)(fe,{size:14}),T||E?n(E&&o?`config:updateSettings.installingUpdates`:`config:updateSettings.checking2`):w?n(`config:updateSettings.restartAndInstall`):C?n(`config:updateSettings.resumeDownload`):S?a.canDownload?n(o?`config:updateSettings.downloadAndInstallUpdates`:`config:updateSettings.downloadUpdate`):n(c?`config:updateSettings.viewRelease`:`config:updateSettings.viewSourceUpdates`):n(`config:updateSettings.checkForUpdates`)]}),(0,J.jsxs)(z,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:h,children:[(0,J.jsx)(P,{size:14}),c?`GitHub Releases`:`GitHub Compare`]}),o&&(0,J.jsxs)(z,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:g,children:[(0,J.jsx)(P,{size:14}),n(`config:updateSettings.viewUpdateDiagnosticLog`)]})]})]}),!s&&(0,J.jsx)(U,{"data-config-card":`updates-components`,title:n(`config:updateSettings.appComponents`),children:(0,J.jsx)(H,{children:j.map(e=>{let t=e.component===`desktop`?wn:e.component===`tui`?ye:Sn,i=e.component===`desktop`?n(`config:updateSettings.desktopFrontend`):e.component===`tui`?n(`config:updateSettings.tuiClient`):n(`config:updateSettings.runtime`),a=e.state===`checking`?n(`config:updateSettings.checking`):e.state===`downloading`?n(`config:updateSettings.downloading`):e.state===`available`?n(`config:updateSettings.updateAvailable`):e.state===`installed`?n(`config:updateSettings.installed`):e.state===`error`?n(`config:updateSettings.checkFailed`):e.state===`current`?n(`config:updateSettings.upToDate`):n(`config:updateSettings.notChecked`);return(0,J.jsx)(V,{icon:(0,J.jsx)(t,{}),name:i,description:e.message||void 0,meta:(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono tabular-nums`,children:[(0,J.jsxs)(`span`,{children:[`v`,e.currentVersion]}),e.availableVersion&&e.availableVersion!==e.currentVersion&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(x,{size:12,"aria-hidden":`true`}),(0,J.jsxs)(`span`,{children:[`v`,e.availableVersion]})]}),e.size>0&&e.state===`available`&&(0,J.jsx)(`span`,{className:`font-sans`,children:Ha(e.size,r)})]}),status:a},e.component)})})}),!s&&(0,J.jsx)(za,{notify:e}),(0,J.jsx)(U,{title:n(c?S||C||w||E?`config:updateSettings.newVersionReleaseNotes`:`config:updateSettings.currentReleaseNotes`:S?`config:updateSettings.commitsToSync`:`config:updateSettings.currentSourceStatus`),meta:(a.releaseDate||c&&y?.date)&&new Intl.DateTimeFormat(r,{dateStyle:`long`}).format(new Date(a.releaseDate||y?.date||``)),actions:(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-xs text-content-muted`,children:[(0,J.jsx)(A,{size:13,"aria-hidden":`true`}),S||C||w||E?k:c?`v${y?.version||i.version}`:a.currentCommit?.slice(0,7)||n(`config:updateSettings.notChecked`)]}),children:(0,J.jsx)(`div`,{className:`border-t border-stroke pt-3`,children:(0,J.jsx)(Pt,{children:b})})})]})}function Wa(e,t){switch(t){case`interface`:return e(`config:settingsShell.lede.interface`);case`notifications`:return e(`config:settingsShell.lede.notifications`);case`shortcuts`:return e(`config:settingsShell.lede.shortcuts`);case`updates`:return e(`config:settingsShell.lede.updates`);case`labs`:return e(`config:settingsShell.lede.labs`);case`about`:return e(`config:settingsShell.lede.about`);default:return e(`config:settingsShell.lede.models`)}}function Ga({notify:e,registerPrimaryAction:t,invokePrimaryAction:n,section:r,onBackToFeatures:i,onBrowserNotificationChange:a,requestConfirm:o,update:s,renderInterfaceSettings:c}){let{t:u}=l(),d=at(r);if(r===`remote-access`||r===`mobile-server`||r===`desktop-pet`)return(0,J.jsx)(Zr,{section:r,notify:e,requestConfirm:o,onBack:i});let f=te(r)?r:`models`,p;if(f===`notifications`)p=(0,J.jsx)(Ra,{notify:e,onBrowserNotificationChange:a});else if(f===`interface`){let t=(0,J.jsx)(ui,{notify:e,defaultAdvancedExpanded:d?.expandGroup===`interface-advanced`,navigationKey:d?.navigationKey});p=c?c(t):t}else p=f===`shortcuts`?(0,J.jsx)(di,{requestConfirm:o}):f===`updates`?(0,J.jsx)(Ua,{notify:e,update:s}):f===`labs`?(0,J.jsx)(gr,{notify:e}):f===`about`?(0,J.jsx)(Dr,{update:s,notify:e}):(0,J.jsx)(ua,{defaultAdvancedExpanded:d?.expandGroup===`models-advanced`,navigationKey:d?.navigationKey,notify:e,registerPrimaryAction:t,requestConfirm:o});let m=u(`navigation:pageHeader.quickSetup`);return(0,J.jsx)(Mt,{"data-settings-page":f,title:ne(u,f),description:Wa(u,f),toolbar:f===`models`?(0,J.jsx)(Nt,{actions:(0,J.jsxs)(z,{variant:`outline`,"data-settings-quick-setup":!0,onClick:n,children:[(0,J.jsx)(de,{className:`size-4`,"aria-hidden":`true`}),m]})}):void 0,children:(0,J.jsx)(`div`,{"data-config-card":ot,className:`mt-6 min-w-0 max-[650px]:mt-3`,children:p})})}export{Ga as ConfigPage};
5
+ `);b(Object.fromEntries(Xi.map((t,n)=>[t,e[n]]).filter(([,e])=>e)))},[v]),(0,q.useEffect)(()=>{let e=!0;return Zi.listProfiles().then(t=>e&&m(t)).catch(t=>{e&&(m({profiles:[],errors:[]}),g(t instanceof Error?t.message:String(t)))}),()=>{e=!1}},[]);let x=e.providers.filter(e=>e.type===`chat`&&e.configured&&e.enabled).flatMap(e=>e.models.filter(e=>e.kind===`chat`).map(t=>({provider:e,name:t.name||t.id,id:t.id}))),S=x.map(({provider:e,name:t,id:n})=>({value:`${e.id}/${n}`,label:`${Dt(t,x.map(e=>e.name))} · ${e.name}`})),C=async(e,n)=>{let a=y,o={...y,[e]:n};n||delete o[e],b(o),u(!0),f(``);try{r(await Zi.saveModelTiers(o)),t(i(`config:subagents.tiersSaved`))}catch(e){b(a),f(e instanceof Error?e.message:String(e))}finally{u(!1)}},w=Xi.filter(e=>y[e]).length,T=p?.profiles||[],E=p?.errors||[];return(0,J.jsx)(`section`,{"aria-labelledby":`${s}-heading`,"aria-busy":c||void 0,"data-config-card":`models-subagents`,"data-config-target":`models-subagents`,className:`min-w-0 border-t border-stroke`,children:(0,J.jsx)(Pe,{type:`single`,collapsible:!0,children:(0,J.jsxs)(Ne,{value:`subagents`,children:[(0,J.jsx)(je,{children:(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,J.jsx)(`span`,{id:`${s}-heading`,children:i(`config:subagents.title`)}),(0,J.jsx)(`span`,{className:`truncate text-xs font-normal text-content-muted`,children:w?i(`config:subagents.configuredSummary`,{count:w}):i(`config:subagents.followSession`)})]})}),(0,J.jsxs)(Me,{className:`h-auto`,children:[(0,J.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`config:subagents.hint`)}),(0,J.jsx)(`div`,{className:`mt-3 border-t border-stroke`,children:Xi.map(e=>{let t=y[e]||``;return(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-6 gap-y-2 border-b border-stroke py-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-[min(240px,100%)] flex-1`,children:[(0,J.jsxs)(`div`,{id:`${s}-${e}`,className:`text-sm text-content`,children:[a(e),(0,J.jsx)(`code`,{className:`ml-2 font-mono text-xs text-content-muted`,children:e})]}),(0,J.jsx)(`p`,{id:`${s}-${e}-hint`,className:`mt-0.5 text-xs text-content-muted`,children:o(e)})]}),(0,J.jsx)(`div`,{className:`w-[min(280px,100%)] min-w-0 max-[650px]:w-full`,children:(0,J.jsxs)(K,{"aria-labelledby":`${s}-${e}`,"aria-describedby":`${s}-${e}-hint`,className:`w-full`,disabled:!S.length||n||c,value:t,onChange:t=>void C(e,t.target.value),children:[(0,J.jsx)(`option`,{value:``,children:i(`config:subagents.followSession`)}),t&&!S.some(e=>e.value===t)&&(0,J.jsx)(`option`,{value:t,children:t}),S.map(e=>(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value))]})})]},e)})}),d&&(0,J.jsx)(W,{children:d}),(0,J.jsx)(`h3`,{className:`mt-5 text-[13px] font-medium text-content`,children:i(`config:subagents.globalDefinitions`)}),(0,J.jsx)(`p`,{className:`mt-0.5 text-xs text-content-muted`,children:i(`config:subagents.definitionsHint`)}),p===null?(0,J.jsxs)(`p`,{role:`status`,className:`mt-3 flex items-center gap-2 text-xs text-content-muted`,children:[(0,J.jsx)(R,{className:`size-3`}),i(`config:subagents.loading`)]}):T.length===0&&E.length===0?(0,J.jsx)(`p`,{className:`mt-3 text-xs text-content-muted`,children:i(`config:subagents.empty`)}):(0,J.jsxs)(`ul`,{className:`mt-3 flex min-w-0 flex-col border-t border-stroke`,children:[T.map(e=>(0,J.jsxs)(`li`,{className:`min-w-0 border-b border-stroke py-2 text-[13px]`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`code`,{className:`shrink-0 font-mono text-content`,children:e.name}),(0,J.jsxs)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:[e.modelRef||e.tier||i(`config:subagents.inheritModel`),e.thinkingLevel?` · ${e.thinkingLevel}`:``,e.tools?` · ${i(`config:subagents.toolCount`,{count:e.tools.length})}`:``]})]}),(0,J.jsx)(`p`,{className:`mt-0.5 text-xs text-content-secondary`,children:e.description})]},e.name)),E.map(e=>(0,J.jsxs)(`li`,{className:`min-w-0 border-b border-stroke py-2 text-[13px]`,children:[(0,J.jsx)(`code`,{className:`font-mono text-danger`,children:e.file||e.scope}),(0,J.jsx)(`p`,{className:`mt-0.5 text-xs text-danger`,children:e.message})]},`${e.scope}:${e.file}`))]}),h&&(0,J.jsx)(W,{children:h})]})]})})})}function $i(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)||e}function ea({notify:e}){let{t}=l(),n=(0,q.useId)(),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(!1),[u,d]=(0,q.useState)(`allow`),[f,p]=(0,q.useState)(`bash`),[m,h]=(0,q.useState)(``);(0,q.useEffect)(()=>{let e=!0;return y.list().then(t=>e&&i(t.rules)).catch(t=>{e&&(i([]),o(t instanceof Error?t.message:String(t)))}),()=>{e=!1}},[]);let g=async(t,n)=>{c(!0),o(``);try{return i((await t()).rules),e(n),!0}catch(e){return o(e instanceof Error?e.message:String(e)),!1}finally{c(!1)}},_=async()=>{let e=m.trim();e&&await g(()=>y.add({effect:u,tool:f,pattern:e}),t(`config:permissionRules.added`))&&h(``)};return(0,J.jsx)(`section`,{"aria-labelledby":`${n}-heading`,"data-config-card":`models-permission-rules`,"data-config-target":`models-permission-rules`,className:`min-w-0 border-b border-stroke`,children:(0,J.jsx)(Pe,{type:`single`,collapsible:!0,children:(0,J.jsxs)(Ne,{value:`rules`,children:[(0,J.jsx)(je,{children:(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,J.jsx)(`span`,{id:`${n}-heading`,children:t(`config:permissionRules.title`)}),(0,J.jsx)(`span`,{className:`truncate text-xs font-normal text-content-muted`,children:r===null?``:r.length?t(`config:permissionRules.countSummary`,{count:r.length}):t(`config:permissionRules.noneSummary`)})]})}),(0,J.jsxs)(Me,{className:`h-auto`,children:[(0,J.jsx)(`p`,{className:`text-xs text-content-muted`,children:t(`config:permissionRules.hint`)}),r===null?(0,J.jsxs)(`p`,{role:`status`,className:`mt-3 flex items-center gap-2 text-xs text-content-muted`,children:[(0,J.jsx)(R,{className:`size-3`}),t(`config:permissionRules.loading`)]}):r.length===0?(0,J.jsx)(`p`,{className:`mt-3 text-xs text-content-muted`,children:t(`config:permissionRules.empty`)}):(0,J.jsx)(`ul`,{className:`mt-3 flex min-w-0 flex-col border-t border-stroke`,children:r.map(e=>(0,J.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 border-b border-stroke py-2 text-[13px]`,children:[(0,J.jsx)(`span`,{className:e.effect===`deny`?`shrink-0 rounded-sm bg-danger-soft px-1.5 text-xs text-danger`:`shrink-0 rounded-sm bg-surface-hover px-1.5 text-xs text-content-secondary`,children:e.effect===`deny`?t(`config:permissionRules.deny`):t(`config:permissionRules.allow`)}),(0,J.jsx)(`span`,{className:`shrink-0 text-xs text-content-muted`,children:e.tool===`files`?t(`config:permissionRules.files`):t(`config:permissionRules.command`)}),(0,J.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-content`,title:e.pattern,children:e.pattern}),(0,J.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate text-xs text-content-muted`,title:e.cwd||void 0,children:e.cwd?$i(e.cwd):t(`config:permissionRules.global`)}),(0,J.jsx)(z,{variant:`ghost`,size:`icon-xs`,className:`shrink-0 pointer-coarse:size-11`,disabled:s,"aria-label":t(`config:permissionRules.remove`,{pattern:e.pattern}),title:t(`config:permissionRules.remove`,{pattern:e.pattern}),onClick:()=>void g(()=>y.remove(e.id),t(`config:permissionRules.removed`)),children:(0,J.jsx)(be,{})})]},e.id))}),(0,J.jsxs)(`form`,{className:`mt-3 flex min-w-0 flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,J.jsxs)(K,{"aria-label":t(`config:permissionRules.effectLabel`),className:`w-28`,disabled:s,value:u,onChange:e=>{let t=e.target.value===`deny`?`deny`:`allow`;d(t),t===`deny`&&p(`bash`)},children:[(0,J.jsx)(`option`,{value:`allow`,children:t(`config:permissionRules.allow`)}),(0,J.jsx)(`option`,{value:`deny`,children:t(`config:permissionRules.deny`)})]}),(0,J.jsxs)(K,{"aria-label":t(`config:permissionRules.toolLabel`),className:`w-32`,disabled:s||u===`deny`,value:f,onChange:e=>p(e.target.value===`files`?`files`:`bash`),children:[(0,J.jsx)(`option`,{value:`bash`,children:t(`config:permissionRules.command`)}),(0,J.jsx)(`option`,{value:`files`,children:t(`config:permissionRules.files`)})]}),(0,J.jsx)(B,{"aria-label":t(`config:permissionRules.patternLabel`),className:`h-[34px] min-w-[12rem] flex-1 font-mono text-[13px] max-[650px]:h-11`,disabled:s,maxLength:200,placeholder:t(f===`files`?`config:permissionRules.filesPlaceholder`:`config:permissionRules.commandPlaceholder`),value:m,onChange:e=>h(e.target.value)}),(0,J.jsxs)(z,{type:`submit`,variant:`secondary`,disabled:s||!m.trim(),className:`max-[650px]:min-h-11`,children:[s&&(0,J.jsx)(R,{className:`size-3`}),t(`config:permissionRules.add`)]})]}),a&&(0,J.jsx)(W,{children:a})]})]})})})}function ta(e){return e instanceof Error?e.message:String(e)}function na({notify:e,requestConfirm:t,t:n}){let[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(!0),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(``),[d,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(``),[g,_]=(0,q.useState)(``),v=(0,q.useRef)(0),y=(0,q.useRef)(!1);(0,q.useEffect)(()=>{let e=!0;y.current=!0;let t=v.current;return f(`/api/config`).then(n=>{if(e)return v.current===t&&i(n),o(!1),f(`/api/providers/models/refresh`,{method:`POST`,body:`{}`})}).then(n=>{!e||v.current!==t||!n?.config||i(n.config)}).catch(n=>{!e||v.current!==t||(c(ta(n)),o(!1))}),()=>{e=!1,y.current=!1,v.current+=1}},[]);let b=(0,q.useCallback)(e=>{v.current+=1,i(e),o(!1),c(``)},[]),x=(0,q.useCallback)(async()=>{let e=v.current,t=await f(`/api/config`);y.current&&v.current===e&&b(t)},[b]),S=(0,q.useCallback)(async(t,r)=>{u(t.id),c(``);try{let i=await f(`/api/providers/${encodeURIComponent(t.id)}/enabled`,{method:`PUT`,body:JSON.stringify({enabled:r})});b(i),e(n(`config:configPage.nameState`,{name:t.name,state:n(r?`config:configPage.enabled`:`config:configPage.disabled`)}))}catch(e){c(ta(e))}finally{u(``)}},[b,e,n]),C=(0,q.useCallback)(async t=>{p(t.id),c(``);try{let r=await f(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:t.id,setAsDefault:!0})});b(r),e(n(`config:configPage.defaultProviderUpdated`,{name:t.name}))}catch(e){c(ta(e))}finally{p(``)}},[b,e,n]),w=(0,q.useCallback)(async(t,r)=>{h(t.id),c(``);try{let i=await f(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:t.id,model:r,setAsDefault:!1})});b(i),e(n(`config:configPage.providerConnectionUpdated`))}catch(e){c(ta(e))}finally{h(``)}},[b,e,n]),T=(0,q.useCallback)(async(t,r)=>{p(t.id),c(``);try{let i=await f(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:t.id,model:r,setAsDefault:!1})});(i.defaultProvider||i.provider)!==t.id&&(i=await f(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:t.id,setAsDefault:!0})})),b(i),e(n(`config:configPage.defaultProviderUpdated`,{name:t.name}))}catch(e){c(ta(e))}finally{p(``)}},[b,e,n]),E=(0,q.useCallback)(async()=>{o(!0),c(``);let e=v.current;try{let t=await f(`/api/config`);y.current&&v.current===e&&b(t)}catch(e){y.current&&c(ta(e))}finally{y.current&&o(!1)}},[b]),D=(0,q.useCallback)(async(r,i)=>{if(await t({title:n(`providers:modelEditor.delete`),message:n(`providers:modelEditor.deleteConfirmation`,{name:i.name||i.id}),confirmLabel:n(`config:configPage.delete`)})){_(`${r.id}/${i.id}`),c(``);try{b(await vi.deleteModel(r.id,i.id)),e(n(`providers:modelEditor.deleted`))}catch(e){c(ta(e))}finally{_(``)}}},[b,e,t,n]);return{config:r,loading:a,error:s,toggling:l,settingDefault:d,settingModel:m,deletingModel:g,applyConfig:b,refreshConfig:x,setDefaultProvider:C,setDefaultChatModel:T,setProviderDefaultModel:w,reload:E,toggleProvider:S,deleteProvider:(0,q.useCallback)(async r=>{if(await t({title:n(`config:configPage.deleteProviderConnection`),message:n(`config:configPage.deleteNameItsModelSettingsAndAuthenticationDetailsWillAlsoBeRemoved`,{name:r.name}),confirmLabel:n(`config:configPage.delete`)})){c(``);try{let t=await f(`/api/providers/${encodeURIComponent(r.id)}`,{method:`DELETE`});b(t),e(n(`config:configPage.providerConnectionDeleted`))}catch(e){c(ta(e))}}},[b,e,t,n]),deleteModel:D}}function ra({requestConfirm:e,onImported:t,onAutoImported:n,t:r}){let[i,a]=(0,q.useState)({providers:[],errors:[]}),[o,s]=(0,q.useState)(!0),[c,l]=(0,q.useState)(``),[u,d]=(0,q.useState)(``),[p,m]=(0,q.useState)(``),[h,g]=(0,q.useState)({imported:0,skipped:0}),_=(0,q.useRef)(0),v=(0,q.useRef)(n);v.current=n;let y=(0,q.useCallback)(async()=>{let e=++_.current;s(!0),l(``);try{let t=await vi.importLocal();if(e!==_.current)return;a(t.discovery),g({imported:t.imported.length,skipped:t.skipped.length}),t.imported.length&&await v.current()}catch(t){e===_.current&&l(ta(t))}finally{e===_.current&&s(!1)}},[]);return(0,q.useEffect)(()=>(y(),()=>{_.current+=1}),[y]),{discovery:i,autoImport:h,discovering:o,error:c,operationError:u,importing:p,refresh:y,importProvider:(0,q.useCallback)(async n=>{let i=n.source===`codex-config`?`Codex config.toml`:n.source===`claude-config`?`Claude settings.json`:n.source===`codex-auth`?`Codex login`:`Claude login`,o=n.kind===`authentication`;if(await e({title:r(o?`config:configPage.loadLoginState`:`config:configPage.loadProviderConfiguration`),message:r(o?`config:configPage.loadOfficialProviderLoginStateFromSource`:`config:configPage.loadThisProviderConfigurationFromSource`,{source:i}),confirmLabel:r(o?`config:configPage.loadLoginState`:`config:configPage.loadConfiguration`)})){m(n.id),d(``);try{let e=await f(`/api/providers/${encodeURIComponent(n.id)}/import`,{method:`POST`,body:`{}`});a(e.discovery),t(e)}catch(e){d(ta(e))}finally{m(``)}}},[t,e,r])}}function ia({providers:e,defaultProviderId:t=``,toggling:n,settingDefault:r=``,settingModel:i=``,onConfigure:a,onClone:o,onSetDefault:s,onSetDefaultModel:c,onToggle:u,onDelete:d}){let{t:f}=l(),p=e.filter(e=>e.configured||e.custom);return(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:p.map(e=>{let l=_i[e.id]||ge,p=e.id===t,m=e.configured?e.enabled?f(`config:configPage.authenticationReady`):f(`config:configPage.disabled2`):e.id===`openai-codex`?f(`config:configPage.codexCLILoginRequired`):f(`config:configPage.apiKeyRequired`);return(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 rounded-md border border-stroke bg-panel px-3 py-2.5`,children:[(0,J.jsxs)(`button`,{type:`button`,title:f(`config:configPage.configure`),className:`flex min-h-9 min-w-0 cursor-pointer items-center gap-2.5 rounded-sm border-0 bg-transparent p-0 text-left text-content hover:text-accent-fg`,onClick:()=>a(e),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-7.5 flex-none place-items-center rounded-md border border-key-border bg-key text-content-muted shadow-key`,children:(0,J.jsx)(l,{size:15})}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),p&&(0,J.jsx)(It,{variant:`accent`,children:f(`config:configPage.defaultBadge`)})]}),c&&e.models.some(e=>e.kind===`chat`)?(0,J.jsxs)(`label`,{className:`grid min-w-0 gap-1 text-xs text-content-muted`,children:[f(`config:configPage.providerDefaultModel`),(0,J.jsxs)(K,{"aria-label":`${f(`config:configPage.providerDefaultModel`)}: ${e.name}`,value:e.defaultModel||``,disabled:!!(i||r),onChange:t=>void c(e,t.target.value),children:[!e.models.some(t=>t.kind===`chat`&&t.id===e.defaultModel)&&(0,J.jsx)(`option`,{value:e.defaultModel||``,disabled:!0,children:e.defaultModel||f(`config:configPage.selectModel`)}),e.models.filter(e=>e.kind===`chat`).map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}):e.defaultModel?(0,J.jsxs)(`small`,{className:`truncate font-mono text-xs text-content-muted`,title:e.defaultModel,children:[f(`config:configPage.providerDefaultModel`),`: `,e.defaultModel]}):null,(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`small`,{className:`text-xs text-content-muted`,children:m}),(0,J.jsxs)(`div`,{className:`flex flex-none items-center gap-1.5`,children:[s&&(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 pointer-coarse:size-11`,title:f(`config:configPage.setAsDefaultProvider`),"aria-label":f(`config:configPage.setAsDefaultProvider`),"aria-pressed":p,disabled:p||!e.configured||!e.enabled||!e.defaultModel||!!(r||i),onClick:()=>void s(e),children:(0,J.jsx)(Nn,{size:13})}),(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 pointer-coarse:size-11`,title:f(`config:configPage.cloneProvider`),"aria-label":f(`config:configPage.cloneProvider`),onClick:()=>o(e),children:(0,J.jsx)(M,{size:13})}),(0,J.jsx)(br,{ariaLabel:f(`config:configPage.providerEnabled`,{name:e.name}),value:e.configured&&e.enabled,disabled:!e.configured||n===e.id,onChange:t=>u(e,t)}),e.custom&&(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 hover:bg-danger-soft hover:text-danger pointer-coarse:size-11`,title:f(`config:configPage.deleteProvider`),"aria-label":f(`config:configPage.deleteProvider`),onClick:()=>void d(e),children:(0,J.jsx)(be,{size:13})})]})]})]},e.id)})})}var aa=`pisper.config.visualConnectionsOpen`,$={running:null,result:null,error:``};function oa(){return r.getItem(aa)===`1`}function sa({config:e,notify:t,toggling:n,onToggleProvider:i,onDeleteProvider:a,onCloneProvider:o,onQuickSetup:s,onEditVisualProvider:c}){let{t:u}=l(),[d,p]=(0,q.useState)(null),[m,h]=(0,q.useState)(!0),[g,_]=(0,q.useState)(``),[v,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(``),[w,T]=(0,q.useState)(oa),O=(0,q.useCallback)(async()=>{try{p(await f(`/api/visual/models`)),C(``)}catch(e){C(e instanceof Error?e.message:String(e))}finally{h(!1)}},[]);(0,q.useEffect)(()=>{O()},[O,e]),(0,q.useEffect)(()=>{$.result&&x($.result),$.error&&C($.error);let e=$.running;if(!e)return;y(!0);let t=!0;return e.then(e=>{t&&x(e)}).catch(()=>{t&&C($.error)}).finally(()=>{t&&y(!1)}),()=>{t=!1}},[]);let j=async(e,n)=>{_(e),C(``);try{p(await f(`/api/visual/models/${e}`,{method:`PUT`,body:JSON.stringify({model:n})})),t(u(`config:configPage.visualModelUpdated`))}catch(e){C(e instanceof Error?e.message:String(e))}finally{_(``)}},M=async()=>{if($.running)return;y(!0),C(``),x(null),$.result=null,$.error=``;let e=f(`/api/visual/test`,{method:`POST`,body:`{}`,timeout:21e4});$.running=e;try{let n=await e;$.result=n,x(n),t(u(`config:configPage.testSucceeded`))}catch(e){let n=e instanceof Error?e.message:String(e);$.error=n,C(n),t(n)}finally{$.running=null,y(!1)}},ee=e=>{T(e),r.setItem(aa,e?`1`:`0`)},N=e.providers.filter(e=>e.type===`visual`),P=N.filter(e=>e.configured||e.custom),te=d?.imageModels||[],ne=d?.videoModels||[];return(0,J.jsxs)(`section`,{className:`mt-3`,children:[(0,J.jsxs)(_r,{className:`mb-3 py-3.5`,"data-config-card":`models-visual`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:L(`grid size-9.5 flex-none place-items-center rounded-lg border border-key-border bg-key shadow-key`,d?.image?`text-accent-fg`:`text-content-muted`),children:(0,J.jsx)(ve,{size:18})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-content-muted`,children:u(`config:configPage.currentVisualModel`)}),m?(0,J.jsxs)(`span`,{role:`status`,className:`flex items-center gap-2 text-xs text-content-muted`,children:[(0,J.jsx)(R,{className:`size-3.5`}),u(`config:configPage.loadingVisualStatus`)]}):d?.image?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`span`,{className:`truncate text-sm font-medium text-content`,children:[d.image.providerName,` / `,d.image.name]}),(0,J.jsxs)(yr,{tone:`green`,children:[(0,J.jsx)(A,{size:11,className:`mr-[3px] inline`}),u(`config:configPage.authenticationReady`)]})]}),d.video&&(0,J.jsxs)(`small`,{className:`text-xs text-content-muted [overflow-wrap:anywhere]`,children:[u(`config:configPage.visualVideoModel`),`:`,d.video.providerName,` /`,` `,d.video.name]})]}):(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-warning-strong`,children:[(0,J.jsx)(k,{size:14,"aria-hidden":`true`}),u(`config:configPage.visualNoneConfigured`)]}),(0,J.jsx)(`small`,{className:`text-xs text-content-muted`,children:u(`config:configPage.visualEmptyHint`)})]})]}),(0,J.jsxs)(`div`,{className:`flex w-full max-w-full min-w-0 flex-none flex-wrap items-center gap-2 sm:w-auto`,children:[d?.image&&(0,J.jsxs)(z,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:v,onClick:()=>void M(),children:[v?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(re,{size:13}),u(v?`config:configPage.testingGeneration`:`config:configPage.testGeneration`)]}),(0,J.jsxs)(z,{className:`max-[650px]:h-11`,onClick:s,children:[(0,J.jsx)(Ln,{size:13}),u(`config:configPage.visualQuickSetup`)]})]})]}),b&&(0,J.jsxs)(`div`,{className:`mt-3 flex items-center gap-2.5 rounded-sm border border-stroke-soft bg-surface-subtle px-2.5 py-2`,children:[b.previewDataUrl?(0,J.jsx)(`img`,{src:b.previewDataUrl,alt:b.modelName,className:`size-11 flex-none rounded-xs object-cover`}):(0,J.jsx)(E,{size:16,className:`flex-none text-success`}),(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-px text-xs`,children:[(0,J.jsx)(`span`,{className:`font-medium text-success-strong`,children:u(`config:configPage.testSucceeded`)}),(0,J.jsxs)(`span`,{className:`truncate font-mono text-content-muted`,children:[b.providerName,` / `,b.modelName,` · `,b.path]})]})]})]}),(0,J.jsxs)(Jt,{open:w,onOpenChange:ee,children:[(0,J.jsx)(qt,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`group flex min-h-9 w-full cursor-pointer items-center gap-2 rounded-sm border-0 bg-transparent px-0.5 text-left max-[650px]:min-h-11`,children:[(0,J.jsx)(D,{size:16,"aria-hidden":`true`,className:`flex-none text-content-muted transition-transform group-data-[state=closed]:-rotate-90`}),(0,J.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-content`,children:u(`config:configPage.visualConnections`)}),(0,J.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:u(`config:configPage.visualConnectionsHint`)})]})}),(0,J.jsx)(Kt,{children:(0,J.jsxs)(_r,{className:`mt-2 py-4`,children:[(0,J.jsx)(ia,{providers:N,toggling:n,onClone:o,onConfigure:e=>c(e.id),onToggle:i,onDelete:a}),P.length===0&&(0,J.jsx)(`p`,{className:`text-xs text-content-muted`,children:u(`config:configPage.visualEmptyHint`)}),(te.length>0||ne.length>0)&&(0,J.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 border-t border-stroke-soft pt-3`,children:[te.length>0&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`w-16 flex-none text-xs text-content-muted`,children:u(`config:configPage.visualImageModel`)}),(0,J.jsxs)(K,{className:`min-w-0 flex-1`,value:d?.imageSelection||``,disabled:g===`image`,"aria-label":u(`config:configPage.visualImageModel`),onChange:e=>void j(`image`,e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:u(`config:configPage.visualAutoSelected`)}),te.map(e=>(0,J.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),ne.length>0&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`w-16 flex-none text-xs text-content-muted`,children:u(`config:configPage.visualVideoModel`)}),(0,J.jsxs)(K,{className:`min-w-0 flex-1`,value:d?.videoSelection||``,disabled:g===`video`,"aria-label":u(`config:configPage.visualVideoModel`),onChange:e=>void j(`video`,e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:u(`config:configPage.visualAutoSelected`)}),ne.map(e=>(0,J.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),(0,J.jsx)(`small`,{className:`text-xs text-content-muted`,children:u(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]})]})})]}),S&&(0,J.jsx)(`div`,{className:`mt-2.5`,children:(0,J.jsxs)(Rt,{children:[(0,J.jsx)(xe,{size:13}),S]})})]})}var ca=`pisper.config.manageConnectionsOpen`;function la(){let e=r.getItem(ca);return e===`1`||e!==`0`&&null}function ua({defaultAdvancedExpanded:e=!1,navigationKey:n,notify:i,registerPrimaryAction:a,requestConfirm:o}){let{t:s}=l(),c=t(),u=new URLSearchParams(c.search).get(`import`)===`1`,[d,f]=(0,q.useState)(``),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(null),[_,v]=(0,q.useState)(()=>u||e?!0:la());(0,q.useEffect)(()=>{u&&v(!0)},[u]),(0,q.useEffect)(()=>{e&&v(!0)},[e,n]);let y=na({notify:i,requestConfirm:o,t:s}),{config:b}=y,x=ra({requestConfirm:o,onAutoImported:y.refreshConfig,onImported:e=>{y.applyConfig(e.config);let t=e.config.providers.find(t=>t.id===e.providerId);i(e.kind===`authentication`?s(`config:configPage.nameLoginStateHasBeenLoadedIntoPisper`,{name:t?.name||e.providerId}):s(`config:configPage.nameConfigurationHasBeenLoadedIntoPisper`,{name:t?.name||e.providerId}))},t:s});if(fi(a,()=>m({providerType:`chat`})),!b)return y.error&&!y.loading?(0,J.jsx)(Ot,{kind:`error`,title:s(`config:providerWorkbench.loadFailed`),description:y.error,action:(0,J.jsx)(z,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void y.reload(),children:s(`common:pageTemplate.retry`)})}):(0,J.jsx)(Ot,{kind:`loading`,title:s(`config:configPage.loadingModelCatalog`),description:s(`config:configPage.readingProvidersAndAuthenticationStatus`)});let S=_??!1,C=Fi(x.discovery),w=e=>{v(e),r.setItem(ca,e?`1`:`0`)},T=e=>g(e);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Yi,{config:b,notify:i,busy:!!(y.settingDefault||y.toggling),onConfigChanged:y.applyConfig,onSetDefaultModel:y.setDefaultChatModel}),(0,J.jsx)(ki,{config:b,selectedProviderId:d,onSelectProvider:f,toggling:y.toggling,settingDefault:y.settingDefault,settingModel:y.settingModel,onSave:e=>{y.applyConfig(e),i(s(`config:configPage.providerConnectionUpdated`))},onClone:T,onDelete:y.deleteProvider,deletingModel:y.deletingModel,onDeleteModel:y.deleteModel,onToggle:y.toggleProvider,onSetDefault:y.setDefaultProvider,onSetDefaultModel:y.setProviderDefaultModel,onAddConnection:()=>m({providerType:`chat`}),meta:(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,role:`status`,children:[x.discovering&&(0,J.jsx)(R,{className:`size-3`}),x.discovering?s(`config:providerWorkbench.scanningLocal`):s(`config:providerWorkbench.localImportStatus`,{imported:x.autoImport.imported,skipped:x.autoImport.skipped})]})}),y.error&&(0,J.jsx)(W,{children:y.error}),(0,J.jsxs)(`div`,{className:`mt-8`,"data-config-advanced":!0,children:[(0,J.jsx)(Qi,{config:b,notify:i,busy:!!(y.settingDefault||y.toggling),onConfigChanged:y.applyConfig}),(0,J.jsx)(ea,{notify:i})]}),C>0&&(0,J.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-2 gap-y-0 text-xs text-content-muted`,children:[(0,J.jsx)(`span`,{children:s(`config:configPage.localProviderImportHint`,{count:C})}),(0,J.jsx)(z,{type:`button`,variant:`link`,size:`sm`,className:`h-auto min-h-11 shrink-0 px-1 py-0 font-medium sm:min-h-8`,"aria-expanded":S,"aria-controls":`model-connection-management`,onClick:()=>w(!0),children:s(`config:configPage.reviewLocalProviders`)})]}),(0,J.jsxs)(Jt,{open:S,onOpenChange:w,"data-config-card":`models-advanced`,children:[(0,J.jsx)(qt,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`group mt-6 mb-3 flex min-h-9 w-full cursor-pointer items-center gap-2 rounded-sm border-0 bg-transparent px-0.5 text-left max-[650px]:min-h-11`,children:[(0,J.jsx)(D,{size:16,"aria-hidden":`true`,className:`shrink-0 text-content-muted transition-transform group-data-[state=closed]:-rotate-90`}),(0,J.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-content`,children:s(`config:providerWorkbench.advanced`)}),(0,J.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:s(`config:providerWorkbench.advancedHint`)})]})}),(0,J.jsxs)(Kt,{id:`model-connection-management`,children:[(0,J.jsx)(Hi,{discovery:x.discovery,discovering:x.discovering,error:x.error||x.operationError,importing:x.importing,forceVisible:u,onRefresh:x.refresh,onImport:x.importProvider}),(0,J.jsx)(sa,{config:b,notify:i,toggling:y.toggling,onToggleProvider:y.toggleProvider,onCloneProvider:T,onDeleteProvider:y.deleteProvider,onQuickSetup:()=>m({providerType:`visual`}),onEditVisualProvider:e=>{let t=b.providers.find(t=>t.id===e);t&&(f(t.id),requestAnimationFrame(()=>document.querySelector(`[data-provider-row="${CSS.escape(t.id)}"]`)?.scrollIntoView({block:`start`,behavior:`smooth`})))}})]})]}),p&&(0,J.jsx)(Wi,{config:b,providerType:p.providerType||`chat`,initialProviderId:p.providerId,onConfigChanged:e=>{y.applyConfig(e),e.createdProviderId&&f(e.createdProviderId)},onClose:()=>m(null),onCompleted:e=>{y.applyConfig(e),e.createdProviderId&&f(e.createdProviderId),i(s(`config:configPage.setupComplete`)),m(null)}}),h&&(0,J.jsx)(Pi,{initialProviderType:h.type,cloneProvider:h,onClose:()=>g(null),onCreated:e=>{y.applyConfig(e),e.createdProviderId&&f(e.createdProviderId),i(s(`config:configPage.providerConnectionCreated`)),g(null)}})]})}var da=[`browser`,`feishu`,`weixin`,`qq`,`telegram`];function fa(e){if(!e||typeof e!=`object`||Array.isArray(e))throw d();return e}function pa(e,t){if(typeof e!=`string`||e.length>t)throw d();return e}function ma(e){let t=fa(e),n=fa(t.browser);if(typeof n.enabled!=`boolean`||!Array.isArray(t.templates)||!Array.isArray(t.scopes))throw d();let r={},i=fa(t.connections);for(let e of da){if(e===`browser`||i[e]===void 0)continue;let t=i[e];if(t===null){r[e]=null;continue}let n=fa(t);if(n.enabled!==void 0&&typeof n.enabled!=`boolean`||n.status!==void 0&&typeof n.status!=`string`)throw d();r[e]={...n,enabled:n.enabled,status:n.status}}let a=new Set,o=t.templates.map(e=>{let t=fa(e),n=pa(t.id,200);if(!n||a.has(n)||typeof t.enabled!=`boolean`||!Array.isArray(t.variables))throw d();a.add(n);let r={},i=fa(t.channels);for(let e of da){if(i[e]===void 0)continue;let t=fa(i[e]);if(t.enabled!==void 0&&typeof t.enabled!=`boolean`)throw d();r[e]={content:pa(t.content,12e3),...t.enabled===void 0?{}:{enabled:t.enabled}}}return{id:n,name:pa(t.name,500),description:pa(t.description,2e3),enabled:t.enabled,variables:t.variables.map(e=>pa(e,200)),channels:r}}),s=t.scopes.map(e=>{let t=fa(e);if(!da.includes(t.platform))throw d();return{...t,platform:t.platform}});return{browser:{enabled:n.enabled},connections:r,scopes:s,templates:o}}function ha(e){let t=fa(e);if(typeof t.sent!=`number`||!Number.isInteger(t.sent)||t.sent<0)throw d();return{sent:t.sent,...t.title===void 0?{}:{title:pa(t.title,2e3)},...t.body===void 0?{}:{body:pa(t.body,12e3)},...t.preview===void 0?{}:{preview:pa(t.preview,12e3)}}}function ga(e){return e.templates.length>0&&e.templates.every(e=>da.every(t=>typeof e.channels[t]?.enabled==`boolean`))}var _a=(e,t)=>`/api/settings/notifications/templates/${encodeURIComponent(e)}/${t}`,va=(e,t,n,r)=>u(_a(e,t),{method:`PUT`,body:n,...r,parse:ma}),ya={load:(e={})=>u(`/api/settings/notifications`,{...e,parse:ma}),setBrowserEnabled:(e,t={})=>u(`/api/settings/notifications/browser`,{method:`PATCH`,body:{enabled:e},...t,parse:ma}),setEventEnabled:(e,t,n={})=>va(e,`browser`,{enabled:t},n),setChannelEnabled:async(e,t,n,r={})=>{let i=await va(e,t,{channelEnabled:n},r);if(i.templates.find(t=>t.id===e)?.channels[t]?.enabled!==n)throw d();return i},saveTemplate:(e,t,n,r={})=>va(e,t,{content:n},r),testSavedTemplate:(e,t,n={})=>u(`${_a(e,t)}/test`,{method:`POST`,body:{},...n,parse:ha})},ba=e=>e instanceof Error?e.message:String(e),xa=(e,t)=>`${e}\0${t}`,Sa=e=>e.kind===`browser`?`browser`:e.kind===`event`?`event:${e.event}`:`channel:${e.event}:${e.platform}`;function Ca(e,t){if(t.kind===`browser`)return e.browser.enabled;let n=e.templates.find(e=>e.id===t.event);return t.kind===`event`?n?.enabled===!0:n?.channels[t.platform]?.enabled!==!1}function wa(e,t,n){return t.kind===`browser`?{...e,browser:{enabled:n}}:{...e,templates:e.templates.map(e=>e.id===t.event?t.kind===`event`?{...e,enabled:n}:{...e,channels:{...e.channels,[t.platform]:{...e.channels[t.platform],enabled:n}}}:e)}}function Ta(e){let[t,n]=(0,q.useState)(null),r=(0,q.useRef)(null),i=(0,q.useRef)(e);i.current=e;let[a,o]=(0,q.useState)(!0),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)({}),[f,p]=(0,q.useState)({}),m=(0,q.useRef)({}),[h,g]=(0,q.useState)({}),[_,v]=(0,q.useState)({}),y=(0,q.useRef)(!1),b=(0,q.useRef)(null),x=(0,q.useRef)(new Map),S=(0,q.useRef)(new Map),C=(0,q.useRef)(new Set),w=(0,q.useRef)(0),T=(0,q.useRef)(0),E=(0,q.useCallback)(e=>{r.current=e,T.current++,n(e),i.current?.(e)},[]),D=(0,q.useCallback)(async()=>{if(!y.current)return;b.current?.abort();let e=new AbortController;b.current=e;let t=T.current;o(!0),c(``);try{let n=await ya.load({signal:e.signal});y.current&&!e.signal.aborted&&t===T.current&&E(n)}catch(t){y.current&&!e.signal.aborted&&c(ba(t))}finally{y.current&&!e.signal.aborted&&o(!1)}},[E]);(0,q.useEffect)(()=>{y.current=!0,D();let e=x.current,t=S.current;return()=>{y.current=!1,b.current?.abort();for(let t of e.values())t.abort();e.clear(),t.clear()}},[D]);let O=async(e,t)=>{if(!y.current||!r.current)return;let n=Sa(e),i={target:e,value:t,revision:++w.current};if(S.current.set(n,i),u(r=>({...r,[n]:{target:e,value:t,pending:!0,error:``}})),x.current.has(n))return;let a=new AbortController;x.current.set(n,a);try{for(;S.current.has(n)&&y.current&&!a.signal.aborted;){let t=S.current.get(n);S.current.delete(n);try{if(Ca(r.current,e)!==t.value||C.current.has(n)){let i={signal:a.signal},o=e.kind===`browser`?await ya.setBrowserEnabled(t.value,i):e.kind===`event`?await ya.setEventEnabled(e.event,t.value,i):await ya.setChannelEnabled(e.event,e.platform,t.value,i);if(!y.current||a.signal.aborted)return;E(wa(r.current,e,Ca(o,e))),C.current.delete(n)}S.current.has(n)||u(r=>({...r,[n]:{target:e,value:t.value,pending:!1,error:``}}))}catch(r){if(!y.current||a.signal.aborted)return;C.current.add(n),S.current.has(n)||u(i=>({...i,[n]:{target:e,value:t.value,pending:!1,error:ba(r)}}))}}}finally{x.current.get(n)===a&&x.current.delete(n)}},k=t;if(k)for(let e of Object.values(l))e.pending&&(k=wa(k,e.target,e.value));let A=(e,t,n)=>{let r=xa(e,t),i={...m.current,[r]:{event:e,platform:t,content:n,revision:++w.current}};m.current=i,p(i)},j=(e,n)=>{let r=xa(e,n),i=t?.templates.find(t=>t.id===e)?.channels[n]?.content||``,a=f[r]?.content??i;return{content:a,dirty:a!==i,save:h[r]||{pending:!1,error:``},test:_[r]||{pending:!1,error:``}}};return{dirty:Object.values(f).some(e=>e.content!==(t?.templates.find(t=>t.id===e.event)?.channels[e.platform]?.content||``)),saving:Object.values(l).some(e=>e.pending)||Object.values(h).some(e=>e.pending),discard:()=>{m.current={},p({})},data:k,confirmed:t,loading:a,loadError:s,load:D,mutations:l,supportsChannels:t?ga(t):!1,setBrowserEnabled:e=>O({kind:`browser`},e),setEventEnabled:(e,t)=>O({kind:`event`,event:e},t),setChannelEnabled:(e,t,n)=>O({kind:`channel`,event:e,platform:t},n),retryMutation:e=>O(e.target,e.value),draft:j,editDraft:A,saveTemplate:async(e,t)=>{let n=xa(e,t),i=`content:${n}`,a=m.current[n];if(!y.current||!a||!a.content.trim()||x.current.has(i))return!1;let o=new AbortController;x.current.set(i,o),g(e=>({...e,[n]:{pending:!0,error:``}}));try{let i=await ya.saveTemplate(e,t,a.content,{signal:o.signal});if(!y.current||o.signal.aborted)return!1;let s=i.templates.find(t=>t.id===e)?.channels[t]?.content;if(s===void 0)throw d();E({...r.current,templates:r.current.templates.map(n=>n.id===e?{...n,channels:{...n.channels,[t]:{...n.channels[t],content:s}}}:n)});let c=m.current[n]?.revision===a.revision;return c&&(m.current={...m.current,[n]:{...a,content:s}},p(m.current)),g(e=>({...e,[n]:{pending:!1,error:``}})),c}catch(e){return y.current&&!o.signal.aborted&&g(t=>({...t,[n]:{pending:!1,error:ba(e)}})),!1}finally{x.current.get(i)===o&&x.current.delete(i)}},testTemplate:async(e,t)=>{let n=xa(e,t),r=`test:${n}`;if(!y.current||x.current.has(r)||j(e,t).dirty)return;let i=new AbortController;x.current.set(r,i),v(e=>({...e,[n]:{pending:!0,error:``}}));try{let r=await ya.testSavedTemplate(e,t,{signal:i.signal});return!y.current||i.signal.aborted?void 0:(v(e=>({...e,[n]:{pending:!1,error:``}})),r)}catch(e){y.current&&!i.signal.aborted&&v(t=>({...t,[n]:{pending:!1,error:ba(e)}}))}finally{x.current.get(r)===i&&x.current.delete(r)}}}}function Ea(e,t){let n={"chat.title":t(`config:notificationSettings.fixChannelNotification`),"chat.summary":t(`config:notificationSettings.implementationIsCompleteTestsAndBuildHavePassed`),"chat.tool":`bash`,"chat.reason":t(`config:notificationSettings.confirmationIsRequired`),"chat.model":`openai/gpt-5.4`,"task.name":t(`config:notificationSettings.dailyCodeReview`),"task.summary":t(`config:notificationSettings.found2IssuesToAddressTheReportHasBeenArchived`),"task.duration":t(`config:notificationSettings.message2Min18Sec`),"task.nextRun":t(`config:notificationSettings.tomorrow0900`),"task.error":t(`config:notificationSettings.testProcessTimedOut`),"workflow.name":t(`config:notificationSettings.preReleaseChecks`),"workflow.summary":t(`config:notificationSettings.testsBuildAndSecurityChecksHaveAllPassed`),"workflow.duration":t(`config:notificationSettings.message6Min42Sec`),"workflow.runId":`run_20260718_001`,"workflow.node":t(`config:notificationSettings.endToEndTests`),"workflow.error":t(`config:notificationSettings.browserFailedToStart`)};return String(e||``).replace(/\{\{\s*([\w.]+)\s*\}\}/g,(e,t)=>n[t]||`{{${t}}}`)}function Da({settings:e,templates:t,eventId:n,platform:r,onSelectionChange:i,platformLabel:a,permissionGranted:o,onBrowserTest:s,notify:c}){let{t:u}=l(),d=(0,q.useRef)(!0),[f,p]=(0,q.useState)(``);(0,q.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let m=t.find(e=>e.id===n)||t[0];if(!m||!e.data)return(0,J.jsx)(`p`,{role:`status`,children:u(`config:notificationSettings.noNotificationEvents`)});let h=e.draft(m.id,r),g=r===`browser`?null:e.data.connections[r],_=r===`browser`?e.confirmed?.browser.enabled===!0&&!e.mutations.browser?.pending&&o:g?.enabled===!0&&e.data.scopes.some(e=>e.platform===r),v=async()=>{p(``);let t=await e.testTemplate(m.id,r);if(!(!t||!d.current))try{r===`browser`&&await s(t.title||m.name,t.body||t.preview||``,`pisper-template-${m.id}`),d.current&&c(r===`browser`?u(`config:notificationSettings.theTestNotificationWasSentCheckYourSystemNotificationCenter`):u(`config:notificationSettings.testNotificationSentToCountChats`,{count:t.sent}))}catch(e){d.current&&p(e instanceof Error?e.message:String(e))}};return(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(`h2`,{className:`text-[15px] leading-6 font-medium text-content`,children:u(`config:notificationSettings.notificationTemplates`)}),(0,J.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[u(`config:notificationSettings.notificationEvent`),(0,J.jsx)(K,{"aria-label":u(`config:notificationSettings.notificationEvent`),value:m.id,onChange:e=>i(e.target.value,r),children:t.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[u(`config:notificationSettings.notificationChannel`),(0,J.jsx)(K,{"aria-label":u(`config:notificationSettings.notificationChannel`),value:r,onChange:e=>{let t=da.find(t=>t===e.target.value);t&&i(m.id,t)},children:da.map(e=>(0,J.jsx)(`option`,{value:e,children:a(e)},e))})]})]}),(0,J.jsx)(`p`,{className:`text-xs text-content-muted`,children:m.description}),(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[u(`config:notificationSettings.messageContent`),(0,J.jsx)(Et,{"aria-label":u(`config:notificationSettings.messageContent`),value:h.content,onChange:t=>e.editDraft(m.id,r,t.target.value),className:`min-h-36 p-3 font-mono text-[12.5px] leading-[1.65] font-normal`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-content-muted`,children:[(0,J.jsx)(`span`,{children:u(`config:notificationSettings.availableVariables`)}),m.variables.map(e=>(0,J.jsx)(`code`,{className:`rounded-xs bg-inline-code px-1.5 py-0.5 font-mono text-content-secondary`,children:`{{${e}}}`},e))]}),(0,J.jsxs)(`div`,{className:`rounded-md border border-stroke bg-code p-3`,children:[(0,J.jsx)(`p`,{className:`text-xs font-medium text-content-muted`,children:u(`config:notificationSettings.preview`)}),(0,J.jsx)(`pre`,{className:`mt-2 font-sans text-sm break-words whitespace-pre-wrap text-content`,children:Ea(h.content,u)})]}),(0,J.jsx)(`p`,{className:`text-xs text-content-muted`,children:h.dirty?u(`config:notificationSettings.saveBeforeTest`):u(`config:notificationSettings.testUsesSavedTemplate`)}),!_&&(0,J.jsx)(`p`,{role:`status`,className:`text-xs text-content-muted`,children:u(`config:notificationSettings.channelTestUnavailable`)}),(h.save.error||h.test.error||f)&&(0,J.jsx)(Rt,{children:h.save.error||h.test.error||f}),(0,J.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,J.jsx)(z,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:h.dirty||h.save.pending||!_,loading:h.test.pending,onClick:()=>void v(),children:u(`config:notificationSettings.sendTest`)}),(0,J.jsx)(z,{"data-template-save":!0,className:`max-[650px]:h-11`,loading:h.save.pending,disabled:!h.dirty||!h.content.trim(),onClick:async()=>{await e.saveTemplate(m.id,r)&&c(u(`config:notificationSettings.notificationTemplateSaved`))},children:u(`config:notificationSettings.saveTemplate`)})]})]})}function Oa(e,t){switch(t){case`chime`:return e(`config:notificationSounds.soundChime`);case`marimba`:return e(`config:notificationSounds.soundMarimba`);case`drop`:return e(`config:notificationSounds.soundDrop`);case`bell`:return e(`config:notificationSounds.soundBell`);default:return e(`config:notificationSounds.soundLow`)}}function ka(e,t){return e(t===`waiting`?`config:notificationSounds.eventWaiting`:t===`finished`?`config:notificationSounds.eventFinished`:`config:notificationSounds.eventFailed`)}function Aa(e,t){return e(t===`waiting`?`config:notificationSounds.eventWaitingHint`:t===`finished`?`config:notificationSounds.eventFinishedHint`:`config:notificationSounds.eventFailedHint`)}function ja(){let{t:e}=l(),t=Qt(),[n,r]=(0,q.useState)(null),i=n??t.volume,a=e=>{e!==`none`&&$t(e,t.volume)};return(0,J.jsxs)($r,{"data-config-card":`notifications-sounds`,title:e(`config:notificationSounds.title`),description:e(`config:notificationSounds.description`),children:[(0,J.jsx)(Q,{title:e(`config:notificationSounds.enabled`),control:(0,J.jsx)(tt,{checked:t.enabled,"aria-label":e(`config:notificationSounds.enabled`),onCheckedChange:e=>t.update({enabled:e})})}),sn.map(n=>{let r=t.sounds[n];return(0,J.jsx)(Q,{"data-sound-event":n,title:ka(e,n),description:Aa(e,n),control:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(K,{value:r,className:`w-32`,"aria-label":ka(e,n),disabled:!t.enabled,onChange:e=>{let r=e.target.value;t.setSound(n,r),a(r)},children:[(0,J.jsx)(`option`,{value:`none`,children:e(`config:notificationSounds.soundNone`)}),nn.map(t=>(0,J.jsx)(`option`,{value:t,children:Oa(e,t)},t))]}),(0,J.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,className:`pointer-coarse:size-11`,disabled:!t.enabled||r===`none`,"aria-label":e(`config:notificationSounds.preview`,{event:ka(e,n)}),title:e(`config:notificationSounds.preview`,{event:ka(e,n)}),onClick:()=>a(r),children:(0,J.jsx)(ue,{"aria-hidden":`true`})})]})},n)}),(0,J.jsx)(Q,{title:e(`config:notificationSounds.volume`),control:(0,J.jsxs)(`div`,{className:`flex w-48 items-center gap-3`,children:[(0,J.jsx)(et,{min:0,max:100,step:5,value:[i],disabled:!t.enabled,"aria-label":e(`config:notificationSounds.volume`),valueText:`${i}%`,onValueChange:([e])=>r(e),onValueCommit:([e])=>{r(null),t.update({volume:e});let n=t.sounds.waiting;n!==`none`&&$t(n,e)}}),(0,J.jsxs)(`span`,{className:`w-9 text-right text-xs text-content-muted tabular-nums`,children:[i,`%`]})]})}),(0,J.jsx)(Q,{title:e(`config:notificationSounds.whileFocused`),description:e(`config:notificationSounds.whileFocusedHint`),control:(0,J.jsx)(tt,{checked:t.whileFocused,disabled:!t.enabled,"aria-label":e(`config:notificationSounds.whileFocused`),onCheckedChange:e=>t.update({whileFocused:e})})})]})}function Ma(e,t){return t(e===`feishu`?`config:notificationSettings.feishu`:e===`weixin`?`config:notificationSettings.weChat`:e===`qq`?`config:notificationSettings.qq`:e===`telegram`?`config:notificationSettings.telegram`:`config:notificationSettings.systemNotificationChannel`)}function Na(e,t,n){return e===`chat.completed`?n(`config:notificationSettings.chatCompleted`):e===`chat.waiting`?n(`config:notificationSettings.chatWaiting`):e===`schedule.completed`?n(`config:notificationSettings.scheduleCompleted`):e===`schedule.failed`?n(`config:notificationSettings.scheduleFailed`):e===`workflow.completed`?n(`config:notificationSettings.workflowCompleted`):e===`workflow.failed`?n(`config:notificationSettings.workflowFailed`):t}function Pa(e,t,n){return e===`chat.completed`?n(`config:notificationSettings.chatCompletedDescription`):e===`chat.waiting`?n(`config:notificationSettings.chatWaitingDescription`):e===`schedule.completed`?n(`config:notificationSettings.scheduleCompletedDescription`):e===`schedule.failed`?n(`config:notificationSettings.scheduleFailedDescription`):e===`workflow.completed`?n(`config:notificationSettings.workflowCompletedDescription`):e===`workflow.failed`?n(`config:notificationSettings.workflowFailedDescription`):t}function Fa(){return typeof window<`u`&&window.pisperDesktop?.showNotification?window.pisperDesktop.getNotificationStatus?`checking`:`granted`:typeof window<`u`&&on()?`checking`:vn()}function Ia(e,t){return t(e===`system-disabled`||e===`app-disabled`?`config:notificationSettings.systemNotificationsAreOffAllowPisperToSendNotificationsInYourOperatingSystemSettings`:e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.theOperatingSystemDidNotAcceptTheNotificationCheckYourSystemNotificationSettings`)}function La(e){return e instanceof Error?e.message:String(e)}function Ra({notify:e,onBrowserNotificationChange:t}){let{t:r,language:i}=l(),a=(0,q.useRef)(!1);(0,q.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let o=Ta(t),{data:s,loading:c,loadError:u}=o,[d,f]=n(),p=!!window.pisperDesktop?.showNotification,m=on(),[h,g]=(0,q.useState)(Fa),_=o.mutations.browser?.pending===!0,v=(0,q.useCallback)(async()=>{if(!p)return;let e=window.pisperDesktop?.getNotificationStatus;if(!e){g(`granted`);return}try{let t=await e();if(!a.current)return;let n=t?.permission;g(n==="default"||n===`denied`||n===`granted`||n===`checking`||n===`unsupported`?n:t?.supported===!1?`unsupported`:`granted`)}catch{a.current&&g(`unsupported`)}},[p]);(0,q.useEffect)(()=>{if(!p)return;v();let e=()=>{v()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[p,v]);let y=(0,q.useCallback)(async()=>{if(!(p||!m))try{let e=await tn();if(!a.current)return;g(e===!0?`granted`:e===!1?`denied`:`default`)}catch{a.current&&g(`unsupported`)}},[p,m]);(0,q.useEffect)(()=>{if(p||!m)return;y();let e=()=>void y();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[p,m,y]);let b=async t=>{let n=``;if(t){if(p&&h!==`granted`)n=Ia(`system-disabled`,r);else if(!p&&m){let e=`denied`;try{let t=await tn()===!0?`granted`:await rn();e=t===`granted`?`granted`:t===`denied`?`denied`:`default`}catch{e=`unsupported`}if(!a.current)return;g(e),e!==`granted`&&(n=r(`config:notificationSettings.systemNotificationsAreOffAllowPisperToSendNotificationsInYourOperatingSystemSettings`))}else if(!p){let e=await _n();if(!a.current)return;if(g(e),e!==`granted`)n=r(e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`);else try{await gn()}catch{n=r(`config:notificationSettings.theBrowserBackgroundNotificationServiceCouldNotBeRegistered`)}}}a.current&&(await o.setBrowserEnabled(t),n&&a.current&&e(n,`info`))},x=(0,q.useCallback)(async(e,t,n=`pisper-browser-test`)=>{if(p){let n=window.pisperDesktop?.showNotification;if(!n)throw Error(r(`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`));let i=await n({title:e,body:t});if(i&&typeof i==`object`&&i.shown===!1)throw g(i.permission??`denied`),Error(Ia(i.reason,r));return i}return m?(await Zt(e,t),{shown:!0,transport:`tauri`}):hn({title:e,body:t,tag:n,url:window.location.href})},[p,m,r]),S=async()=>{if(!(!o.confirmed?.browser.enabled||_)){if(h!==`granted`){e(h===`unsupported`?Ia(`unsupported`,r):p?Ia(`system-disabled`,r):r(`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`),`error`);return}try{await x(r(`config:notificationSettings.appNotificationTest`,{app:we}),r(`config:notificationSettings.notificationsAreWorking`)),e(r(`config:notificationSettings.theTestNotificationWasSentCheckYourSystemNotificationCenter`),`info`)}catch(t){e(La(t)||r(`config:notificationSettings.theOperatingSystemDidNotAcceptTheNotificationCheckYourSystemNotificationSettings`),`error`)}}},w=async()=>{try{await window.pisperDesktop?.openNotificationSettings?.()||e(r(`config:notificationSettings.openNotificationPermissionsInYourOperatingSystemSettings`),`info`)}catch{e(r(`config:notificationSettings.openNotificationPermissionsInYourOperatingSystemSettings`),`info`)}};if(c)return(0,J.jsxs)(Ht,{children:[(0,J.jsx)(R,{className:`size-6`}),(0,J.jsx)(`h2`,{children:r(`config:notificationSettings.loadingNotificationSettings`)})]});if(!s)return(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(Rt,{children:u}),(0,J.jsx)(z,{variant:`outline`,onClick:()=>void o.load(),children:r(`common:pageTemplate.retry`)})]});let T=(e=s.templates[0]?.id||``,t=`browser`)=>{f(n=>{let r=new URLSearchParams(n);return r.set(`view`,`templates`),e&&r.set(`event`,e),r.set(`channel`,t),r})},E=d.get(`view`)===`templates`,D=s.templates.map(e=>({...e,name:Na(e.id,e.name,r),description:Pa(e.id,e.description,r)}));if(E)return(0,J.jsxs)(`div`,{"data-config-card":`notifications-templates`,className:`space-y-4`,children:[(0,J.jsxs)(z,{variant:`ghost`,className:`-ml-2.5 pointer-coarse:h-11`,onClick:()=>f(e=>{let t=new URLSearchParams(e);return t.delete(`view`),t.delete(`event`),t.delete(`channel`),t}),children:[(0,J.jsx)(O,{size:16,"aria-hidden":`true`}),r(`config:notificationSettings.backToCategories`)]}),(0,J.jsx)(Da,{settings:o,templates:D,eventId:d.get(`event`)||``,platform:da.find(e=>e===d.get(`channel`))||`browser`,onSelectionChange:T,platformLabel:e=>Ma(e,r),permissionGranted:h===`granted`,onBrowserTest:x,notify:e})]});let k=r(h===`granted`?`config:notificationSettings.permissionGranted`:h===`denied`?p?`config:notificationSettings.systemNotificationsAreOff`:`config:notificationSettings.browserNotificationsAreBlocked`:h===`unsupported`?`config:notificationSettings.notSupported`:h===`checking`?`config:notificationSettings.checking`:`config:notificationSettings.waitingForPermission`),A=h===`granted`?`green`:h==="default"?`amber`:`gray`;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[u&&(0,J.jsx)(Rt,{children:u}),Object.entries(o.mutations).filter(([,e])=>e.error).map(([e,t])=>(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(Rt,{children:t.error}),(0,J.jsx)(z,{variant:`outline`,size:`sm`,onClick:()=>void o.retryMutation(t),children:r(`common:pageTemplate.retry`)})]},e)),(0,J.jsxs)(_r,{className:`browser-notification-card py-4`,"data-config-card":`notifications-browser`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:L(`grid size-9.5 shrink-0 place-items-center rounded-lg border border-key-border bg-key shadow-key`,s.browser.enabled?`text-accent-fg`:`text-content-muted`),children:s.browser.enabled?(0,J.jsx)(C,{size:18}):(0,J.jsx)(yn,{size:18})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-content`,children:r(`config:notificationSettings.systemNotificationChannel`)}),(0,J.jsx)(`p`,{className:`mt-0.5 text-xs leading-[1.45] text-content-muted`,children:r(`config:notificationSettings.pisperUsesTheCurrentPlatformNotificationSystemWhenAnAgentCompletesOrFails`)})]}),(0,J.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[(0,J.jsx)(yr,{tone:A,children:k}),(0,J.jsx)(br,{ariaLabel:r(`config:notificationSettings.systemNotificationChannel`),value:s.browser.enabled,disabled:_||h===`checking`,onChange:b})]})]}),(0,J.jsxs)(Lt,{children:[(0,J.jsx)(_e,{size:15}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`strong`,{children:r(p?`config:notificationSettings.controlledByOperatingSystemNotificationSettings`:`config:notificationSettings.controlledByBrowserSitePermissions`)}),(0,J.jsx)(`small`,{children:r(p?`config:notificationSettings.theDesktopAppUsesOperatingSystemNotificationsTurningThisOffDoesNotChangeTheOperatingSystemPermis`:`config:notificationSettings.theWebAppUsesBrowserSiteNotificationsTurningThisOffDoesNotChangeTheBrowserPermissionItself`)})]})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex gap-2 max-[650px]:flex-wrap`,children:[p&&h===`denied`&&(0,J.jsxs)(z,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:w,children:[(0,J.jsx)(_e,{size:14}),r(`config:notificationSettings.openSystemNotificationSettings`)]}),(0,J.jsxs)(z,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:!s.browser.enabled||_||h!==`granted`,onClick:S,children:[(0,J.jsx)(C,{size:14}),r(`config:notificationSettings.sendTestNotification`)]})]})]}),(0,J.jsx)(ja,{}),(0,J.jsxs)($r,{title:r(`config:notificationSettings.notificationCategories`),description:r(`config:notificationSettings.channelPreferenceHint`),action:(0,J.jsx)(z,{variant:`ghost`,size:`sm`,className:`pointer-coarse:h-11`,onClick:()=>T(),children:r(`config:notificationSettings.editNotificationTemplates`)}),children:[!o.supportsChannels&&(0,J.jsx)(`p`,{role:`status`,className:`py-2 text-sm text-content-muted`,children:r(`config:notificationSettings.channelPreferencesUnsupported`)}),D.length>0&&(0,J.jsx)(xr,{children:D.map(e=>{let t=e.enabled?da.filter(t=>e.channels[t]?.enabled!==!1):[],n=Object.entries(o.mutations).some(([t,n])=>n.pending&&(t===`event:${e.id}`||t.startsWith(`channel:${e.id}:`)));return(0,J.jsx)(Q,{"data-notification-event":e.id,title:e.name,description:e.description,control:(0,J.jsxs)(We,{children:[(0,J.jsx)(He,{asChild:!0,children:(0,J.jsx)(z,{variant:`outline`,size:`sm`,className:`max-w-full font-normal text-content-secondary pointer-coarse:h-11`,"aria-label":r(`config:notificationSettings.eventChannels`,{event:e.name}),"aria-busy":n,children:(0,J.jsx)(`span`,{className:`max-w-64 truncate`,children:t.length?t.map(e=>Ma(e,r)).join(i===`zh-CN`?`、`:`, `):r(`config:notificationSettings.channelsOff`)})})}),(0,J.jsxs)(Ue,{align:`end`,className:`max-w-[calc(100vw-40px)] min-w-56`,children:[(0,J.jsx)(Ve,{checked:e.enabled,onCheckedChange:t=>void o.setEventEnabled(e.id,t===!0),children:r(`config:notificationSettings.enableEvent`)}),(0,J.jsx)(ze,{}),da.map(t=>{let n=t===`browser`?s.browser.enabled:s.connections[t]?.enabled===!0&&s.scopes.some(e=>e.platform===t);return(0,J.jsxs)(Ve,{checked:e.channels[t]?.enabled!==!1,disabled:!o.supportsChannels,onCheckedChange:n=>void o.setChannelEnabled(e.id,t,n===!0),children:[(0,J.jsx)(`span`,{children:Ma(t,r)}),!n&&(0,J.jsx)(`small`,{className:`ml-2 text-muted-foreground`,children:r(`config:notificationSettings.channelNeedsSetup`)})]},t)}),(0,J.jsx)(ze,{}),(0,J.jsx)(Be,{onSelect:()=>T(e.id),children:r(`config:notificationSettings.editNotificationTemplates`)})]})]})},e.id)})}),!D.length&&(0,J.jsx)(`p`,{role:`status`,className:`py-3 text-sm text-content-muted`,children:r(`config:notificationSettings.noNotificationEvents`)})]})]})}function za({notify:e}){let{t}=l(),n=window.pisperDesktop,[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(``);(0,q.useEffect)(()=>{if(!n?.getCliStatus)return;let e=!0;return n.getCliStatus().then(t=>e&&i(t)).catch(t=>e&&c(t instanceof Error?t.message:String(t))),()=>{e=!1}},[n]);let u=!!(n?.getCliStatus&&n.installCli&&n.uninstallCli),d=async()=>{if(n?.installCli){o(`install`),c(``);try{let r=await n.installCli();i(r),e(t(`config:cliSettings.installedNotification`))}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(``)}}},f=async()=>{if(n?.uninstallCli){o(`uninstall`),c(``);try{let r=await n.uninstallCli();i(r),e(t(`config:cliSettings.uninstalledNotification`))}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(``)}}},p=u&&!r,m=u?p?t(`config:cliSettings.checking`):r?.supported?r.needsRepair?t(`config:cliSettings.needsRepair`):r.installed?t(`config:cliSettings.installed`):t(`config:cliSettings.notInstalled`):t(`config:cliSettings.unavailable`):t(`config:cliSettings.unavailable`);return(0,J.jsxs)(U,{"data-config-card":`updates-cli`,title:t(`config:cliSettings.title`),description:t(`config:cliSettings.description`),actions:(0,J.jsx)(`span`,{className:`text-xs text-content-secondary`,children:m}),children:[r&&(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3 border-t border-stroke py-3`,children:[r.installed&&!r.needsRepair?(0,J.jsx)(A,{className:`mt-0.5 shrink-0 text-content-muted`,size:16,"aria-hidden":`true`}):(0,J.jsx)(Fn,{className:`mt-0.5 shrink-0 text-content-muted`,size:16,"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`grid min-w-0 gap-0.5`,children:[(0,J.jsx)(`strong`,{className:`text-sm font-medium text-content`,children:r.installed?t(`config:cliSettings.commandReady`,{command:r.command}):t(`config:cliSettings.commandNotInstalled`,{command:r.command})}),(0,J.jsx)(`small`,{className:`font-mono text-xs [overflow-wrap:anywhere] text-content-muted`,children:r.installPath}),r.installed&&(0,J.jsx)(`small`,{className:`text-xs text-content-muted`,children:r.pathConfigured?t(`config:cliSettings.pathConfigured`):t(`config:cliSettings.pathNeedsRepair`)})]})]}),s&&(0,J.jsx)(W,{children:s}),u&&(0,J.jsxs)(`div`,{className:`mt-3 flex gap-2 max-[650px]:flex-wrap`,children:[r?.installed&&(0,J.jsxs)(z,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:!!a,onClick:()=>void f(),children:[a===`uninstall`?(0,J.jsx)(R,{className:`text-current`}):(0,J.jsx)(be,{size:14}),t(`config:cliSettings.uninstall`)]}),(!r?.installed||r.needsRepair)&&(0,J.jsxs)(z,{type:`button`,className:`max-[650px]:h-11`,disabled:!!a||p||r?.supported===!1,onClick:()=>void d(),children:[a===`install`?(0,J.jsx)(R,{className:`text-current`}):r?.needsRepair?(0,J.jsx)(Se,{size:14}):(0,J.jsx)(ee,{size:14}),r?.needsRepair?t(`config:cliSettings.repair`):t(`config:cliSettings.install`)]})]}),u&&(0,J.jsx)(`small`,{className:`mt-2 block text-xs text-content-muted`,children:t(`config:cliSettings.restartTerminal`)})]})}var Ba=`0.6.19`;function Va(e,t){return!e.desktop&&!e.mobile?t(`config:updateSettings.browserMode`):`${{win32:`Windows`,darwin:`macOS`,linux:`Linux`,android:`Android`,ios:`iOS`}[e.platform]||e.platform} · ${e.arch}`}function Ha(e,t){let n=Number(e)||0;if(!n)return`0 B`;let r=[`B`,`KB`,`MB`,`GB`],i=Math.min(r.length-1,Math.floor(Math.log(n)/Math.log(1024)));return`${(n/1024**i).toLocaleString(t,{maximumFractionDigits:1})} ${r[i]}`}function Ua({notify:e,update:t}){let{t:n,language:r}=l(),i=t?.info||{desktop:!1,packaged:!1,version:Ba,platform:`browser`,arch:``},a=t?.status||{state:`idle`},o=!!i.desktop,s=!!i.mobile,c=o||s,[u,d]=(0,q.useState)({version:Ba,date:``,notes:``}),[f,p]=(0,q.useState)(``);(0,q.useEffect)(()=>{let e=!0;return fetch(`/release-notes.json`,{cache:`no-store`}).then(e=>e.ok?e.json():null).then(t=>{e&&t&&d(t)}).catch(()=>{}),()=>{e=!1}},[]);let m=async()=>{if(t){p(`check`);try{await t.check()}finally{p(``)}}},h=()=>t?.openReleases(),g=()=>t?.openUpdateLog?.(),_=async()=>{p(o?`install`:``);try{o?await t?.installComponents():await t?.download()}catch(t){e(t instanceof Error?t.message:String(t),`error`)}finally{p(``)}},v=()=>t?.install(),y=u.version===i.version?u:null,b=a.notes||(c?y?.notes||n(`config:updateSettings.noReleaseNotesAreAvailableForThisVersion`):a.state===`current`?n(`config:updateSettings.theCurrentWebSourceIsSyncedWithBranch`,{branch:a.branch||`release`}):n(`config:updateSettings.commitsThatHaveNotBeenSyncedWillAppearHereAfterTheCheck`)),S=a.state===`available`,C=a.state===`error`&&a.canResume&&a.canDownload,w=a.state===`downloaded`,T=a.state===`checking`||f===`check`,E=a.state===`downloading`||f===`install`,D=T?`checking`:E?`downloading`:a.state,O=c?`v${i.version}`:`v${i.version}${a.currentCommit?` · ${a.currentCommit.slice(0,7)}`:``}`,k=c?`v${a.availableVersion||y?.version||i.version}`:a.availableCommit?.slice(0,7)||a.currentCommit?.slice(0,7)||u.version||i.version,j=(0,q.useMemo)(()=>{let e=new Map(t.components.map(e=>[e.component,e]));return[`desktop`,`tui`,`runtime`].map(t=>e.get(t)||{component:t,state:`idle`,currentVersion:t===`desktop`?i.version:`--`,availableVersion:``,message:``,releaseUrl:``,notes:``,size:0,transferred:0,canInstall:!1,restartRequired:!1})},[i.version,t.components]),M={idle:n(`config:updateSettings.notChecked`),checking:n(`config:updateSettings.checking`),current:n(`config:updateSettings.upToDate`),available:n(c?`config:updateSettings.updateAvailable`:`config:updateSettings.sourceUpdatesAvailable`),downloading:n(`config:updateSettings.downloading`),downloaded:n(`config:updateSettings.readyToRestart`),installed:n(`config:updateSettings.upToDate`),error:n(C?`config:updateSettings.downloadPaused`:`config:updateSettings.checkFailed`)}[D]||n(`config:updateSettings.notChecked`);return(0,J.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col`,children:[(0,J.jsxs)(U,{"data-config-card":`updates-main`,className:`mt-6`,title:n(`config:updateSettings.pisperAppUpdates`),actions:(0,J.jsx)(`span`,{"data-update-status":D,className:`text-xs text-content-secondary tabular-nums`,children:M}),children:[(0,J.jsxs)(`dl`,{className:`grid border-y border-stroke max-sm:divide-y max-sm:divide-stroke-soft sm:grid-cols-3`,children:[(0,J.jsxs)(`div`,{className:`py-3 sm:pr-4`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(c?`config:updateSettings.currentVersion`:`config:updateSettings.currentSource`)}),(0,J.jsx)(`dd`,{className:`mt-1 font-mono text-[12.5px] font-medium text-content`,children:O})]}),(0,J.jsxs)(`div`,{className:`py-3 sm:border-l sm:border-stroke-soft sm:px-4`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(`config:updateSettings.platform`)}),(0,J.jsx)(`dd`,{className:`mt-1 text-sm font-medium text-content`,children:Va(i,n)})]}),(0,J.jsxs)(`div`,{className:`py-3 sm:border-l sm:border-stroke-soft sm:pl-4`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(`config:updateSettings.updateChannel`)}),(0,J.jsx)(`dd`,{className:`mt-1 font-mono text-[12.5px] font-medium text-content`,children:c?`Stable`:a.branch||`release`})]})]}),a.message&&(a.state===`error`?(0,J.jsx)(W,{children:a.message}):(0,J.jsxs)(`p`,{className:`mt-4 flex items-start gap-2 text-sm text-content-secondary`,children:[(0,J.jsx)(wn,{className:`mt-0.5 shrink-0 text-content-muted`,size:15,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`min-w-0`,children:a.message})]})),C&&(0,J.jsx)(`small`,{className:`mt-2 block text-xs text-content-muted`,children:n(`config:updateSettings.downloadedDataWasPreservedAndCanResumeFromTheInterruptionPoint`)}),E&&(0,J.jsxs)(`div`,{className:`mt-4`,children:[(0,J.jsxs)(`div`,{className:`flex justify-between text-xs text-content-muted`,children:[(0,J.jsx)(`span`,{children:n(`config:updateSettings.downloadProgress`)}),(0,J.jsxs)(`span`,{className:`tabular-nums`,children:[Math.round(a.percent||0),`% · `,Ha(a.transferred,r),` /`,` `,Ha(a.total,r)]})]}),(0,J.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-surface-active`,children:(0,J.jsx)(`i`,{className:`block h-full bg-star transition-[width]`,style:{width:`${a.percent||0}%`}})})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,J.jsxs)(z,{className:`max-[650px]:h-11`,disabled:T||E||!!f,onClick:w?v:S||C?_:m,children:[T||E?(0,J.jsx)(R,{className:`text-current`}):w?(0,J.jsx)(pe,{size:14}):S||C?a.canDownload?(0,J.jsx)(ee,{size:14}):(0,J.jsx)(P,{size:14}):(0,J.jsx)(fe,{size:14}),T||E?n(E&&o?`config:updateSettings.installingUpdates`:`config:updateSettings.checking2`):w?n(`config:updateSettings.restartAndInstall`):C?n(`config:updateSettings.resumeDownload`):S?a.canDownload?n(o?`config:updateSettings.downloadAndInstallUpdates`:`config:updateSettings.downloadUpdate`):n(c?`config:updateSettings.viewRelease`:`config:updateSettings.viewSourceUpdates`):n(`config:updateSettings.checkForUpdates`)]}),(0,J.jsxs)(z,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:h,children:[(0,J.jsx)(P,{size:14}),c?`GitHub Releases`:`GitHub Compare`]}),o&&(0,J.jsxs)(z,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:g,children:[(0,J.jsx)(P,{size:14}),n(`config:updateSettings.viewUpdateDiagnosticLog`)]})]})]}),!s&&(0,J.jsx)(U,{"data-config-card":`updates-components`,title:n(`config:updateSettings.appComponents`),children:(0,J.jsx)(H,{children:j.map(e=>{let t=e.component===`desktop`?wn:e.component===`tui`?ye:Sn,i=e.component===`desktop`?n(`config:updateSettings.desktopFrontend`):e.component===`tui`?n(`config:updateSettings.tuiClient`):n(`config:updateSettings.runtime`),a=e.state===`checking`?n(`config:updateSettings.checking`):e.state===`downloading`?n(`config:updateSettings.downloading`):e.state===`available`?n(`config:updateSettings.updateAvailable`):e.state===`installed`?n(`config:updateSettings.installed`):e.state===`error`?n(`config:updateSettings.checkFailed`):e.state===`current`?n(`config:updateSettings.upToDate`):n(`config:updateSettings.notChecked`);return(0,J.jsx)(V,{icon:(0,J.jsx)(t,{}),name:i,description:e.message||void 0,meta:(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono tabular-nums`,children:[(0,J.jsxs)(`span`,{children:[`v`,e.currentVersion]}),e.availableVersion&&e.availableVersion!==e.currentVersion&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(x,{size:12,"aria-hidden":`true`}),(0,J.jsxs)(`span`,{children:[`v`,e.availableVersion]})]}),e.size>0&&e.state===`available`&&(0,J.jsx)(`span`,{className:`font-sans`,children:Ha(e.size,r)})]}),status:a},e.component)})})}),!s&&(0,J.jsx)(za,{notify:e}),(0,J.jsx)(U,{title:n(c?S||C||w||E?`config:updateSettings.newVersionReleaseNotes`:`config:updateSettings.currentReleaseNotes`:S?`config:updateSettings.commitsToSync`:`config:updateSettings.currentSourceStatus`),meta:(a.releaseDate||c&&y?.date)&&new Intl.DateTimeFormat(r,{dateStyle:`long`}).format(new Date(a.releaseDate||y?.date||``)),actions:(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-xs text-content-muted`,children:[(0,J.jsx)(A,{size:13,"aria-hidden":`true`}),S||C||w||E?k:c?`v${y?.version||i.version}`:a.currentCommit?.slice(0,7)||n(`config:updateSettings.notChecked`)]}),children:(0,J.jsx)(`div`,{className:`border-t border-stroke pt-3`,children:(0,J.jsx)(Pt,{children:b})})})]})}function Wa(e,t){switch(t){case`interface`:return e(`config:settingsShell.lede.interface`);case`notifications`:return e(`config:settingsShell.lede.notifications`);case`shortcuts`:return e(`config:settingsShell.lede.shortcuts`);case`updates`:return e(`config:settingsShell.lede.updates`);case`labs`:return e(`config:settingsShell.lede.labs`);case`about`:return e(`config:settingsShell.lede.about`);default:return e(`config:settingsShell.lede.models`)}}function Ga({notify:e,registerPrimaryAction:t,invokePrimaryAction:n,section:r,onBackToFeatures:i,onBrowserNotificationChange:a,requestConfirm:o,update:s,renderInterfaceSettings:c}){let{t:u}=l(),d=at(r);if(r===`remote-access`||r===`mobile-server`||r===`desktop-pet`)return(0,J.jsx)(Zr,{section:r,notify:e,requestConfirm:o,onBack:i});let f=te(r)?r:`models`,p;if(f===`notifications`)p=(0,J.jsx)(Ra,{notify:e,onBrowserNotificationChange:a});else if(f===`interface`){let t=(0,J.jsx)(ui,{notify:e,defaultAdvancedExpanded:d?.expandGroup===`interface-advanced`,navigationKey:d?.navigationKey});p=c?c(t):t}else p=f===`shortcuts`?(0,J.jsx)(di,{requestConfirm:o}):f===`updates`?(0,J.jsx)(Ua,{notify:e,update:s}):f===`labs`?(0,J.jsx)(gr,{notify:e}):f===`about`?(0,J.jsx)(Dr,{update:s,notify:e}):(0,J.jsx)(ua,{defaultAdvancedExpanded:d?.expandGroup===`models-advanced`,navigationKey:d?.navigationKey,notify:e,registerPrimaryAction:t,requestConfirm:o});let m=u(`navigation:pageHeader.quickSetup`);return(0,J.jsx)(Mt,{"data-settings-page":f,title:ne(u,f),description:Wa(u,f),toolbar:f===`models`?(0,J.jsx)(Nt,{actions:(0,J.jsxs)(z,{variant:`outline`,"data-settings-quick-setup":!0,onClick:n,children:[(0,J.jsx)(de,{className:`size-4`,"aria-hidden":`true`}),m]})}):void 0,children:(0,J.jsx)(`div`,{"data-config-card":ot,className:`mt-6 min-w-0 max-[650px]:mt-3`,children:p})})}export{Ga as ConfigPage};