pisper 0.6.13 → 0.6.14

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 (108) hide show
  1. package/package.json +5 -5
  2. package/web/.vite/manifest.json +541 -541
  3. package/web/assets/{AppDialog-ChuOV69R.js → AppDialog-DrhCZm1r.js} +1 -1
  4. package/web/assets/{AppOverlays-BNxogCpM.js → AppOverlays-CxgReqGn.js} +1 -1
  5. package/web/assets/{AssetsPage-C_zULo41.js → AssetsPage-CKK-byQY.js} +1 -1
  6. package/web/assets/{BoardPage-Wu9X-Zur.js → BoardPage-vwv5vTDm.js} +3 -3
  7. package/web/assets/{ChannelsPage-DvQYEsZx.js → ChannelsPage-L-wcVDSN.js} +1 -1
  8. package/web/assets/{ChatAppearancePage-Dc1hcGO1.js → ChatAppearancePage-BhqRLf-2.js} +1 -1
  9. package/web/assets/{ChatHistoryPage-DOldhuBG.js → ChatHistoryPage-DBsNyGYj.js} +1 -1
  10. package/web/assets/{ChatPage-Bt1N3-Dd.js → ChatPage-DS0euFxR.js} +4 -4
  11. package/web/assets/{ConfigPage-Dx_9BXUH.js → ConfigPage-pOzONr8e.js} +2 -2
  12. package/web/assets/{DesktopWindowControls-DhzSLGsL.js → DesktopWindowControls-DCtIkpTs.js} +1 -1
  13. package/web/assets/{DispatchOverlay-LNd_knJl.js → DispatchOverlay-n-qbkOP-.js} +1 -1
  14. package/web/assets/{FeaturePage-BV7-6mzm.js → FeaturePage-Bkt1wWVg.js} +1 -1
  15. package/web/assets/{FileAttachmentPreview-cYRvzbsf.js → FileAttachmentPreview-Cnmi_2U-.js} +1 -1
  16. package/web/assets/{FloatingWidgets-CZvEZBfc.js → FloatingWidgets-BIJSFz34.js} +1 -1
  17. package/web/assets/{FocusRuntimeControls-B0yEDKMN.js → FocusRuntimeControls-C7NIdpV4.js} +1 -1
  18. package/web/assets/{GitDiffViewer-4ea3jm5E.js → GitDiffViewer-rjt5_KOt.js} +1 -1
  19. package/web/assets/{LaunchConsole-Bu-NLmrh.js → LaunchConsole-DtxzpXJo.js} +2 -2
  20. package/web/assets/{ManageProjectsDialog-Qi8yMzuy.js → ManageProjectsDialog-RiFg3h1p.js} +1 -1
  21. package/web/assets/{MarkdownMessage-BSTx0KMg.js → MarkdownMessage-yl-PSRAz.js} +1 -1
  22. package/web/assets/{McpPage-DpT7NbHF.js → McpPage-D6GyZCpt.js} +1 -1
  23. package/web/assets/{MemoryPage-2BMB0tcU.js → MemoryPage-Dsx_6JpI.js} +1 -1
  24. package/web/assets/{MobileNavigation-BChENth3.js → MobileNavigation-DcBH2I9Y.js} +1 -1
  25. package/web/assets/{MorePage-D_E85kDw.js → MorePage-BBfiQbiP.js} +1 -1
  26. package/web/assets/{NewFolderDialog-B56_BjoW.js → NewFolderDialog-BinpbTs8.js} +1 -1
  27. package/web/assets/{PageHeader-BXQdmR1x.js → PageHeader-D_J-19ni.js} +1 -1
  28. package/web/assets/{PhoneDrawer-CapiWnwy.js → PhoneDrawer-CwxDkWZQ.js} +1 -1
  29. package/web/assets/{PhoneMenuButton-D1TPwX-1.js → PhoneMenuButton-B0AwvqEo.js} +1 -1
  30. package/web/assets/{PhoneTopBar-1qxMJEZn.js → PhoneTopBar-Dw0mIaWC.js} +1 -1
  31. package/web/assets/{PluginsPage-CPyf2iFu.js → PluginsPage-BzxPAX26.js} +1 -1
  32. package/web/assets/{QuickPromptIdeas-Cy_t1L7E.js → QuickPromptIdeas-Cd3SwBqS.js} +1 -1
  33. package/web/assets/{SafeModePrompt-BUIzMwem.js → SafeModePrompt-CLyt-z14.js} +1 -1
  34. package/web/assets/{SchedulesPage-DKTAxE95.js → SchedulesPage-Cbgl5v_8.js} +1 -1
  35. package/web/assets/{SessionBrowserPane-nAItO1A5.js → SessionBrowserPane-CB7jn-MS.js} +2 -2
  36. package/web/assets/{SessionContextPanel-9Bg4j5Vv.js → SessionContextPanel-CNmAp0ed.js} +2 -2
  37. package/web/assets/{SessionHome-BV3eA6FP.js → SessionHome-Ck_daJT0.js} +1 -1
  38. package/web/assets/{SessionInspector-nGAiGnrh.js → SessionInspector-cSzwsc4b.js} +1 -1
  39. package/web/assets/{SessionShell-DJAnktW8.js → SessionShell-BOZ7h0yz.js} +1 -1
  40. package/web/assets/{SettingsSidebar-fuUmdnZp.js → SettingsSidebar-IqsOv5h1.js} +1 -1
  41. package/web/assets/{ShortcutHelpDialog-Gqrlr6Mi.js → ShortcutHelpDialog-DKDAF94g.js} +1 -1
  42. package/web/assets/{ShortcutKeys-hvm91EiI.js → ShortcutKeys-DQFnMnX1.js} +1 -1
  43. package/web/assets/{SidebarUpdateStatus-AEvqSFVz.js → SidebarUpdateStatus-Cbwy5ii9.js} +1 -1
  44. package/web/assets/{SkillsPage-B4qPIWNT.js → SkillsPage-DTOzYSaS.js} +1 -1
  45. package/web/assets/{TaskProcessesPane-Dpxwl38Z.js → TaskProcessesPane-DRFmGkE3.js} +1 -1
  46. package/web/assets/{TaskTerminalView-DZkPrfzt.js → TaskTerminalView-DWNACXyI.js} +1 -1
  47. package/web/assets/{TerminalPanel-BLWGdiOM.js → TerminalPanel-QEt-SRiM.js} +1 -1
  48. package/web/assets/{WebDesktopPet-w5vrcLDr.js → WebDesktopPet-4CDch3gC.js} +1 -1
  49. package/web/assets/{WorkflowsPage-BIEGwArz.js → WorkflowsPage-AMKQBlPo.js} +1 -1
  50. package/web/assets/{WorkspacePicker-BiJHY52J.js → WorkspacePicker-B9vYtfab.js} +1 -1
  51. package/web/assets/{api-PMkeVoki.js → api-BO7LAPSQ.js} +1 -1
  52. package/web/assets/{app-update-BAixtUfS.js → app-update-DKWPHTUY.js} +1 -1
  53. package/web/assets/{approval-confirm-Dpfx2sMg.js → approval-confirm-ByiI22Wo.js} +1 -1
  54. package/web/assets/{board-launch-C_nXqI77.js → board-launch-BmmPYZe8.js} +1 -1
  55. package/web/assets/{board-projects-CBCU-Sgb.js → board-projects-BU9fZB1q.js} +1 -1
  56. package/web/assets/{chat-api-Kcrk_K91.js → chat-api-DkdyVQY9.js} +1 -1
  57. package/web/assets/{client-store-CrFIB91q.js → client-store-6GNC8uyK.js} +1 -1
  58. package/web/assets/{config-search-DXrAFHzB.js → config-search-HBKDuym0.js} +1 -1
  59. package/web/assets/{dialog-DdbSm1ZL.js → dialog-CUhFgsVd.js} +1 -1
  60. package/web/assets/{events-CsDpIEpa.js → events-DrAPv0se.js} +1 -1
  61. package/web/assets/{folder-paths-tMQQIavs.js → folder-paths-DQTpuGh9.js} +1 -1
  62. package/web/assets/{hosts-LdyGIyL3.js → hosts-1yQREdMi.js} +1 -1
  63. package/web/assets/i18n-CHmr7GzM.js +1 -0
  64. package/web/assets/{index-Ciq5zG6s.js → index-CsE52ydO.js} +2 -2
  65. package/web/assets/{mount-app-BNdeN2kJ.js → mount-app-DfSFF0xv.js} +3 -3
  66. package/web/assets/{permission-rules-api-DJZQfffF.js → permission-rules-api-BoJ_1W-m.js} +1 -1
  67. package/web/assets/{pick-system-directory-Dzxt6gno.js → pick-system-directory-B_RJmP26.js} +1 -1
  68. package/web/assets/{placements-CvOgP1_I.js → placements-CqwqXPTp.js} +2 -2
  69. package/web/assets/{popover-Cl-XiAIN.js → popover--UmYQ9yB.js} +1 -1
  70. package/web/assets/{public-components-BRkqqQBZ.js → public-components-DYGekkA7.js} +1 -1
  71. package/web/assets/public-diff-DK-VNIar.js +1 -0
  72. package/web/assets/{public-CJ34MvMA.js → public-fqyTjQ0F.js} +2 -2
  73. package/web/assets/public-jQjEc6OO.js +1 -0
  74. package/web/assets/public-launch-CT_m9KWo.js +1 -0
  75. package/web/assets/{runtime-capabilities-store-BrQ24OXo.js → runtime-capabilities-store-C2Qv7uDP.js} +1 -1
  76. package/web/assets/{safe-mode-instance-C8KjWD3O.js → safe-mode-instance-BiAPYJ2-.js} +1 -1
  77. package/web/assets/safe-mode-sentinel-Ccu3Vmta.js +1 -0
  78. package/web/assets/{session-change-summary-api-p0LGuByB.js → session-change-summary-api-DgRT32uh.js} +1 -1
  79. package/web/assets/{session-home-Bhs5A925.js → session-home-BktP6sGF.js} +1 -1
  80. package/web/assets/{session-organization-api-8UQMpctG.js → session-organization-api-DFu3Chto.js} +1 -1
  81. package/web/assets/{session-scope-8PMKriev.js → session-scope-DQPNgQMm.js} +1 -1
  82. package/web/assets/{session-tree-actions-Ee9kzU3S.js → session-tree-actions-DfO8QHBO.js} +1 -1
  83. package/web/assets/{session-tree-summary-DEQsXexZ.js → session-tree-summary-BwYRdui2.js} +1 -1
  84. package/web/assets/{shortcuts-CD4vslwQ.js → shortcuts-Cvp9WD9O.js} +1 -1
  85. package/web/assets/{side-chat-context-DaUmbt1Y.js → side-chat-context-BfOm4dFp.js} +4 -4
  86. package/web/assets/{sidebar-D-yI-nEo.js → sidebar-BLeRyb55.js} +2 -2
  87. package/web/assets/{sidebar-store-UyvCdgAm.js → sidebar-store-1-aNPlDu.js} +1 -1
  88. package/web/assets/{speech-session-BohM2ygu.js → speech-session-DK_09Wky.js} +1 -1
  89. package/web/assets/{startup-queries-BhNivg8E.js → startup-queries-6Oztqpto.js} +1 -1
  90. package/web/assets/{use-i18n-DUgHBsG5.js → use-i18n-B5p-Kzvz.js} +1 -1
  91. package/web/assets/{use-studio-actions-7VwKPaCN.js → use-studio-actions-D6c_pSJK.js} +1 -1
  92. package/web/assets/{useBoardItems-BeR9GqTq.js → useBoardItems-CzEbgTLJ.js} +1 -1
  93. package/web/assets/{useFleetSystemInfo-BHhLHGdq.js → useFleetSystemInfo-Bd8zJIFa.js} +1 -1
  94. package/web/assets/{useNewProjectPicker-Dvn0ZJTJ.js → useNewProjectPicker-DQY1X_ua.js} +1 -1
  95. package/web/assets/{useNow-CRkZskBs.js → useNow-Bxn4_OW9.js} +1 -1
  96. package/web/assets/{usePhoneShell-DloLJ6Tq.js → usePhoneShell-Bvb7m-m4.js} +1 -1
  97. package/web/assets/{useSessionListQuery-hEpWGZ_H.js → useSessionListQuery-D44XZfGr.js} +1 -1
  98. package/web/assets/{useSessionRowActions-DzNqYyGB.js → useSessionRowActions-Cr6SUAeE.js} +1 -1
  99. package/web/assets/{useSidebarModel-C8_Gpayk.js → useSidebarModel-CWED0rsw.js} +1 -1
  100. package/web/assets/{web-preview-LghC_QcR.js → web-preview-CqwSe9Zn.js} +1 -1
  101. package/web/assets/{web-preview-events-B-rXgMLy.js → web-preview-events-DQchQHt3.js} +1 -1
  102. package/web/assets/{workspace-order-store-BGGH-aRI.js → workspace-order-store-RYWvGOeR.js} +1 -1
  103. package/web/index.html +1 -1
  104. package/web/assets/i18n-BMMXA_dY.js +0 -1
  105. package/web/assets/public-CRj3oDys.js +0 -1
  106. package/web/assets/public-diff-B_YCisY7.js +0 -1
  107. package/web/assets/public-launch-DJ9UFO06.js +0 -1
  108. package/web/assets/safe-mode-sentinel-mAPFazv4.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-Ciq5zG6s.js";import{i,r as a}from"./vendor-react-DwNgTV1j.js";import{c as o,d as s,n as c}from"./i18n-BMMXA_dY.js";import{t as l}from"./use-i18n-DUgHBsG5.js";import{a as u,l as d,t as f}from"./api-PMkeVoki.js";import{n as p}from"./runtime-capabilities-4_ZwLBqF.js";import{t as m}from"./runtime-capabilities-store-BrQ24OXo.js";import{n as h}from"./client-store-CrFIB91q.js";import{t as g}from"./createLucideIcon-Cd-3GVxJ.js";import{a as _,i as v,t as y}from"./permission-rules-api-DJZQfffF.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 N}from"./download-BCfIiuaL.js";import{t as P}from"./ellipsis-CfGKfbq6.js";import{t as F}from"./external-link-CEQqPcqc.js";import{n as ee,t as te}from"./wand-sparkles-CvEBNUFz.js";import{t as ne}from"./image-BY_c3FYU.js";import{i as re,o as ie}from"./settings-navigation-_yUm71Uk.js";import{t as I}from"./loader-circle-BOwQzHB-.js";import{t as ae}from"./message-square-SKjZyY3v.js";import{t as oe}from"./monitor-smartphone-B1gIjItA.js";import{n as L,r as se,t as ce}from"./zap-DZHw5afO.js";import{t as le}from"./plus-fQbSqB1n.js";import{t as ue}from"./refresh-cw-TbWxTY4K.js";import{t as de}from"./rocket-BgLSjoHY.js";import{t as fe}from"./rotate-ccw-C0v8V77_.js";import{t as pe}from"./search-D0mqDaf_.js";import{t as me}from"./server-BgNvmqwJ.js";import{t as he}from"./shield-check-Gvek4RJ7.js";import{t as ge}from"./sparkles-S_eeuqn9.js";import{t as _e}from"./square-terminal-BVG6cUT1.js";import{t as ve}from"./trash-2-CNrPOoPR.js";import{t as ye}from"./triangle-alert-CE1q54ci.js";import{t as be}from"./wrench-6pg6_bqI.js";import{t as xe}from"./x-07u4-129.js";import{t as Se}from"./brand-DIEc3fK8.js";import{a as Ce}from"./dist-41X0pdUs.js";import{c as we,i as Te,o as Ee,s as De}from"./dist-BsRXXcSL.js";import{t as Oe}from"./dist-DzGQ7sLi.js";import{n as ke,r as Ae,t as je}from"./collapsible-DMaUQRX4.js";import{t as Me}from"./dist-OB2r6Xsr.js";import{n as Ne,r as Pe,t as Fe}from"./dist-BaBySQmo.js";import{c as Ie,i as Le,n as Re,p as ze,r as Be,t as Ve}from"./dropdown-menu-CFIFNaKO.js";import{i as He,n as Ue,t as We}from"./popover-Cl-XiAIN.js";import{a as Ge,i as Ke,n as qe,r as Je,t as Ye}from"./select-DD_WO-gs.js";import{t as Xe}from"./separator-BPh_qxvc.js";import{t as Ze}from"./slider-DTmAZl-R.js";import{t as Qe}from"./switch-D_G8wFhs.js";import{t as R}from"./utils-C8uzG5AZ.js";import{n as z,t as B}from"./button-CCcCN8tE.js";import{n as $e,t as et}from"./kbd-CAufZTkl.js";import{i as tt,t as nt}from"./config-search-DXrAFHzB.js";import{_ as rt,c as it,d as at,f as ot,h as st,l as ct,m as lt,o as ut,p as dt,t as ft,u as pt}from"./shortcuts-CD4vslwQ.js";import{a as mt}from"./format-DMJQzoZ7.js";import{n as ht,r as gt,t as _t}from"./PageState-Cz6vFMXv.js";import{a as vt,i as yt,l as bt,o as xt,s as St,t as Ct}from"./dialog-DdbSm1ZL.js";import{t as V}from"./input-CPw-zkYh.js";import{t as wt}from"./textarea-DmATpOqT.js";import{t as Tt}from"./model-display-kDwvtxrW.js";import{t as Et}from"./useOverlayFocusReturn-NkxBSSjb.js";import{i as H,n as U,o as W,r as Dt,s as Ot,t as G}from"./FeaturePage-BV7-6mzm.js";import{n as K}from"./field-DoLEb0np.js";import{t as kt}from"./MarkdownMessage-BSTx0KMg.js";import{t as At}from"./StatusGlyph-1KgitlUg.js";import{t as jt}from"./badge-CWB3lj2H.js";import{a as Mt,i as Nt,l as Pt,n as Ft,o as It,r as Lt,s as Rt,t as zt}from"./app-primitives-Drz_SjnR.js";import{t as q}from"./AppSelect-BGVBQRP1.js";import{t as Bt}from"./usePagePrimaryAction-CWPC0C_f.js";import{t as Vt}from"./BrandLogo-k3CvJjd4.js";import{a as Ht,c as Ut,d as Wt,f as Gt,g as Kt,i as qt,m as Jt,o as Yt,p as Xt,r as Zt,v as Qt}from"./app-update-BAixtUfS.js";import{a as $t,n as en,r as tn,t as nn}from"./ShortcutKeys-hvm91EiI.js";import{i as rn,n as an,r as on,t as sn}from"./browser-notifications-DBS0oXqN.js";var cn=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`}]]),ln=g(`blend`,[[`circle`,{cx:`9`,cy:`9`,r:`7`,key:`p2h5vp`}],[`circle`,{cx:`15`,cy:`15`,r:`7`,key:`19ennj`}]]),un=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`}]]),dn=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`}]]),fn=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`}]]),pn=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`}]]),mn=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`}]]),hn=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`}]]),gn=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`}]]),_n=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`}]]),vn=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`}]]),yn=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`}]]),bn=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`}]]),xn=g(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Sn=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`}]]),Cn=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`}]]),wn=g(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Tn=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`}]]),J=e(i(),1),Y=a(),En=Object.defineProperty,X=(e,t)=>En(e,`name`,{value:t,configurable:!0}),Dn=`Radio`,[On,kn]=De(Dn),[An,jn]=On(Dn);function Mn(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]=J.useState(null),[p,m]=J.useState(null),h=J.useRef(!1),[g,_]=J.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:X(()=>s?.(),`onCheck`)};return(0,Y.jsx)(An,{scope:t,...v,children:Ln(u)?u(v):r})}X(Mn,`RadioProvider`);var Nn=`RadioTrigger`,Pn=J.forwardRef(X(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}=jn(Nn,e),p=Ce(r,s);return(0,Y.jsx)(we.button,{type:`button`,role:`radio`,"aria-checked":i,"data-state":Rn(i),"data-disabled":a?``:void 0,disabled:a,value:o,...n,ref:p,onClick:Ee(t,e=>{i||(u(),c()),f&&d&&(l.current=e.isPropagationStopped(),l.current||e.stopPropagation())})})},`RadioTrigger`)),Fn=`RadioBubbleInput`,In=J.forwardRef(X(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}=jn(Fn,e),h=Ce(r,f),g=Me(i),_=J.useRef(!1),v=J.useRef(a),y=J.useRef(m);J.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=J.useRef(a);return(0,Y.jsx)(we.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:Ee(t,e=>{_.current&&e.stopPropagation()}),style:{...n.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`RadioBubbleInput`));function Ln(e){return typeof e==`function`}X(Ln,`isFunction`);function Rn(e){return e?`checked`:`unchecked`}X(Rn,`getState`);var zn=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`],Bn=`RadioGroup`,[Vn,Hn]=De(Bn,[Pe,kn]),Un=Pe(),Wn=kn(),[Gn,Kn]=Vn(Bn),qn=J.forwardRef(X(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=Un(n),h=Oe(u),[g,_]=Te({prop:o,defaultProp:a??null,onChange:f,caller:Bn}),[v,y]=J.useState(null),b=Ce(t,y),x=J.useRef(g);return J.useEffect(()=>{let e=i?v?.ownerDocument.getElementById(i):v?.closest(`form`);if(e instanceof HTMLFormElement){let t=X(()=>_(x.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[v,i,_]),(0,Y.jsx)(Gn,{scope:n,name:r,form:i,required:s,disabled:c,value:g,onValueChange:_,children:(0,Y.jsx)(Ne,{asChild:!0,...m,orientation:l,dir:h,loop:d,children:(0,Y.jsx)(we.div,{role:`radiogroup`,"aria-required":s,"aria-orientation":l,"data-disabled":c?``:void 0,dir:h,...p,ref:b})})})},`RadioGroup`)),Jn=`RadioGroupItemProvider`,Yn=`RadioGroupItemTrigger`;function Xn(e){let{__scopeRadioGroup:t,value:n,disabled:r,children:i,internal_do_not_use_render:a}=e,o=Kn(Jn,t),s=Wn(t),c=o.disabled||r;return(0,Y.jsx)(Mn,{...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})}X(Xn,`RadioGroupItemProvider`);var Zn=J.forwardRef(X(function(e,t){let{__scopeRadioGroup:n,...r}=e,i=Un(n),a=Wn(n),{checked:o,disabled:s}=jn(Yn,a.__scopeRadio),c=J.useRef(null),l=Ce(t,c),u=J.useRef(!1);return J.useEffect(()=>{let e=X(e=>{zn.includes(e.key)&&(u.current=!0)},`handleKeyDown`),t=X(()=>u.current=!1,`handleKeyUp`);return document.addEventListener(`keydown`,e),document.addEventListener(`keyup`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`keyup`,t)}},[]),(0,Y.jsx)(Fe,{asChild:!0,...i,focusable:!s,active:o,children:(0,Y.jsx)(Pn,{...a,...r,ref:l,onKeyDown:Ee(r.onKeyDown,e=>{e.key===`Enter`&&e.preventDefault()}),onFocus:Ee(r.onFocus,()=>{u.current&&c.current?.click()})})})},`RadioGroupItemTrigger`)),Qn=J.forwardRef(X(function(e,t){let{__scopeRadioGroup:n,value:r,disabled:i,...a}=e;return(0,Y.jsx)(Xn,{__scopeRadioGroup:n,value:r,disabled:i,internal_do_not_use_render:({isFormControl:e})=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Zn,{...a,ref:t,__scopeRadioGroup:n}),e&&(0,Y.jsx)($n,{__scopeRadioGroup:n})]})})},`RadioGroupItem`)),$n=J.forwardRef(X(function(e,t){let{__scopeRadioGroup:n,...r}=e,i=Wn(n);return(0,Y.jsx)(In,{...i,...r,ref:t})},`RadioGroupItemBubbleInput`));function er(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(`移动端原生桥不可用。`))}function tr({className:e,...t}){return(0,Y.jsx)(zt,{"data-settings-card":!0,className:R(`rounded-none border-x-0 border-t border-b-0 border-stroke-soft bg-transparent px-0`,e),...t})}var nr=It,rr=Pt;function ir(e){return(0,Y.jsx)(Rt,{density:`compact`,...e})}function ar({className:e,...t}){return(0,Y.jsx)(`div`,{"data-settings-group":!0,className:R(`@container/card min-w-0 divide-y divide-stroke-soft border-y border-stroke-soft`,e),...t})}function or({label:e,help:t,htmlFor:n,labelId:r,helpId:i,children:a,className:o}){return(0,Y.jsxs)(`div`,{className:R(`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,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`label`,{id:r,htmlFor:n,className:`text-sm font-medium text-content`,children:e}),t&&(0,Y.jsx)(`p`,{id:i,className:`mt-0.5 text-xs text-content-muted`,children:t})]}),(0,Y.jsx)(`div`,{className:`min-w-0 @min-[480px]/card:max-w-[460px]`,children:a})]})}var sr=`0.6.10`,cr=`https://github.com/ling-kong-ran/pisper`,lr=`${cr}/blob/release/LICENSE`;function ur({href:e,icon:t,label:n,value:r,onClick:i}){return(0,Y.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,Y.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,Y.jsx)(t,{size:16,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block text-sm font-medium text-content`,children:n}),(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate font-mono text-xs text-content-muted`,children:r})]}),(0,Y.jsx)(F,{"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||sr,i=e=>{er(e,e.currentTarget.href)?.catch(()=>t(n(`config:aboutSettings.openLinkFailed`),`error`))};return(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full flex-col gap-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 rounded-[15px] shadow-raise`,children:(0,Y.jsx)(Vt,{size:56})}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`h2`,{className:`text-[length:calc(var(--ui-font-size)*10/7)] leading-[1.3] font-semibold tracking-[-.015em] text-content`,children:`Pisper`}),(0,Y.jsxs)(rr,{tone:`gray`,className:`font-mono`,children:[`v`,r]})]}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-content-muted`,children:n(`config:aboutSettings.description`)})]})]}),(0,Y.jsxs)(`section`,{"data-config-card":`about-project`,children:[(0,Y.jsx)(nr,{title:n(`config:aboutSettings.projectInformation`),className:`mb-3 text-[15px] leading-6 font-medium text-content`}),(0,Y.jsxs)(ar,{children:[(0,Y.jsx)(ur,{href:cr,icon:j,label:n(`config:aboutSettings.sourceCode`),value:`github.com/ling-kong-ran/pisper`,onClick:i}),(0,Y.jsx)(ur,{href:lr,icon:vn,label:n(`config:aboutSettings.license`),value:`MIT License`,onClick:i})]})]}),(0,Y.jsx)(tr,{className:`py-4`,"data-config-card":`about-support`,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 max-[540px]:flex-col max-[540px]:items-stretch`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(nr,{title:n(`config:aboutSettings.supportPisper`)}),(0,Y.jsx)(`p`,{className:`mt-0.5 max-w-[520px] text-xs leading-5 text-content-muted`,children:n(`config:aboutSettings.supportDescription`)})]}),(0,Y.jsx)(B,{asChild:!0,className:`max-[650px]:h-11 max-[540px]:w-full`,children:(0,Y.jsxs)(`a`,{href:cr,target:`_blank`,rel:`noopener noreferrer`,"data-web-preview":`external`,onClick:i,children:[(0,Y.jsx)(Sn,{size:15}),n(`config:aboutSettings.starOnGitHub`)]})})]})}),(0,Y.jsx)(`p`,{className:`text-center text-xs text-content-muted`,children:n(`config:aboutSettings.copyright`)})]})}function fr(e){window.dispatchEvent(new CustomEvent(`pisper:desktop-pet-changed`,{detail:e}))}function pr({notify:e,requestConfirm:t}){let{t:n}=l(),r=window.pisperDesktop,i=(0,J.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,J.useState)(null),[s,c]=(0,J.useState)(``),[u,d]=(0,J.useState)([]),[p,m]=(0,J.useState)(100),[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(``),y=(0,J.useCallback)(e=>{o(e),m(Math.round((e.opacity??1)*100))},[]),b=(0,J.useCallback)(async()=>{try{v(``),y(await i.getStatus())}catch(e){v(e instanceof Error?e.message:String(e))}},[y,i]),x=(0,J.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,J.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),fr(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),fr(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),fr(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),fr(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),fr(t),e(n(`config:desktopPetSettings.petRemoved`,{name:r.name}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(``)}}};return(0,Y.jsxs)(Y.Fragment,{children:[_&&(0,Y.jsx)(G,{children:_}),(0,Y.jsx)(W,{title:n(`config:desktopPetSettings.displayTitle`),"data-config-card":`desktop-pet-settings`,children:a?(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{icon:(0,Y.jsx)(un,{}),name:n(`config:desktopPetSettings.showOnDesktop`),description:a.selectedName?n(`config:desktopPetSettings.currentPet`,{name:a.selectedName}):n(`config:desktopPetSettings.installBeforeEnabling`),status:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[a.running&&(0,Y.jsx)(At,{status:`done`,className:`size-3.5`}),a.running?n(`config:desktopPetSettings.running`):n(`config:desktopPetSettings.stopped`)]}),actions:(0,Y.jsx)(Qe,{checked:a.enabled,disabled:!!h||!a.installed.length,onCheckedChange:e=>void S(e),"aria-label":n(`config:desktopPetSettings.showOnDesktop`)})}),(0,Y.jsx)(H,{icon:(0,Y.jsx)(ln,{}),name:n(`config:desktopPetSettings.opacity`),nameMeta:`${p}%`,actions:(0,Y.jsx)(Ze,{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,Y.jsx)(ht,{kind:`loading`,title:n(`config:desktopPetSettings.loading`)})}),(0,Y.jsxs)(W,{title:n(`config:desktopPetSettings.installTitle`),"data-config-card":`desktop-pet-install`,description:n(`config:desktopPetSettings.installDescription`),actions:(0,Y.jsxs)(B,{variant:`ghost`,size:`sm`,onClick:i.openCatalog,children:[(0,Y.jsx)(F,{}),n(`config:desktopPetSettings.browsePetdex`)]}),children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex gap-2`,children:[(0,Y.jsx)(V,{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,Y.jsxs)(B,{variant:`secondary`,className:`h-9 shrink-0 pointer-coarse:h-11 max-[650px]:h-11`,disabled:h===`search`,onClick:x,children:[h===`search`?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(pe,{}),n(`config:desktopPetSettings.search`)]})]}),u.length>0&&(0,Y.jsx)(U,{children:u.map(e=>{let t=a?.installed.some(t=>t.slug===e.slug);return(0,Y.jsx)(H,{"data-pet-catalog":e.slug,icon:(0,Y.jsx)(un,{}),name:e.displayName,nameMeta:e.slug,status:t?n(`config:desktopPetSettings.installed`):void 0,actions:(0,Y.jsxs)(B,{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,Y.jsx)(E,{}):(0,Y.jsx)(N,{}),n(t?`config:desktopPetSettings.use`:`config:desktopPetSettings.install`)]})},e.slug)})})]}),a&&a.installed.length>0&&(0,Y.jsx)(W,{title:n(`config:desktopPetSettings.installedTitle`),count:a.installed.length,"data-config-card":`desktop-pet-installed`,description:n(`config:desktopPetSettings.installedDescription`),children:(0,Y.jsx)(U,{children:a.installed.map(e=>{let t=e.slug===a.selectedSlug;return(0,Y.jsx)(H,{"data-pet-installed":e.slug,"data-selected":t||void 0,className:R(`relative`,t&&`after:absolute after:inset-y-3 after:-left-3 after:w-[3px] after:rounded-full after:bg-star`),icon:(0,Y.jsx)(un,{}),name:e.name,nameMeta:`${e.slug} · ${e.source===`pisper`?`Pisper`:`Petdex`}`,status:t?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,Y.jsx)(At,{status:`done`,className:`size-3.5`}),n(`config:desktopPetSettings.inUse`)]}):void 0,actions:(0,Y.jsxs)(Y.Fragment,{children:[!t&&(0,Y.jsx)(B,{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,Y.jsx)(B,{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,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(ve,{})})]})},`${e.source}:${e.slug}`)})})})]})}function Z(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 mr(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 hr,Q,gr,_r,vr=`__TAURI_TO_IPC_KEY__`;function yr(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}var br=class{constructor(e){hr.set(this,void 0),Q.set(this,0),gr.set(this,[]),_r.set(this,void 0),mr(this,hr,e||(()=>{}),`f`),this.id=yr(e=>{let t=e.index;if(`end`in e){t==Z(this,Q,`f`)?this.cleanupCallback():mr(this,_r,t,`f`);return}let n=e.message;if(t==Z(this,Q,`f`)){for(Z(this,hr,`f`).call(this,n),mr(this,Q,Z(this,Q,`f`)+1,`f`);Z(this,Q,`f`)in Z(this,gr,`f`);){let e=Z(this,gr,`f`)[Z(this,Q,`f`)];Z(this,hr,`f`).call(this,e),delete Z(this,gr,`f`)[Z(this,Q,`f`)],mr(this,Q,Z(this,Q,`f`)+1,`f`)}Z(this,Q,`f`)===Z(this,_r,`f`)&&this.cleanupCallback()}else Z(this,gr,`f`)[t]=n})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){mr(this,hr,e,`f`)}get onmessage(){return Z(this,hr,`f`)}[(hr=new WeakMap,Q=new WeakMap,gr=new WeakMap,_r=new WeakMap,vr)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[vr]()}};function xr(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function Sr(e,t){return xr(`plugin:barcode-scanner|${e}`,t)}function Cr(e){return e instanceof Error?e.message:String(e)}function wr(e){return/cancel(?:led|ed)/i.test(Cr(e))}function Tr(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function Er(e){return Array.isArray(e)?new TextDecoder().decode(Uint8Array.from(e)):``}function Dr(e){if(!e.isActive||!e.port)return null;let t=Er(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=Er(e.txt.name)||e.name||`Pisper Desktop`,a=`https://${r}:${e.port}`;return{id:`${e.fullName}:${a}`,name:i,url:a,fingerprint:t}}function Or(e){return new Promise(t=>window.setTimeout(t,e))}function kr({open:e,onOpenChange:t}){let{t:n}=l(),r=Et(e),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(!1),[c,u]=(0,J.useState)([]),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(``),[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(``),y=(0,J.useRef)(!1),x=(0,J.useRef)(!1),S=(0,J.useRef)(!1),C=(0,J.useRef)(0),w=(0,J.useRef)(``),T=(0,J.useCallback)(e=>{y.current=e,s(e)},[]),E=(0,J.useCallback)(async()=>{x.current=!0,y.current&&await Sr(`cancel`).catch(()=>void 0),T(!1),a(null)},[T]);(0,J.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,J.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,J.useCallback)(async()=>{let e=++C.current;f(!0),m(``),u([]);let t=new br;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=Dr(t.service);r&&u(e=>[...e.filter(e=>e.fingerprint!==r.fingerprint),r])};let r=null;try{await xr(`mobile_ensure_local_network_permission`),r=(await xr(`plugin:dns-sd|browse_start`,{options:{service:{type:`pisper`,protocol:`tcp`,domain:`local`},timeoutMs:4e3},channel:t})).browseId,await Or(4300)}catch(t){C.current===e&&m(Cr(t).includes(`local_network_permission_denied`)?n(`config:mobileServer.localNetworkDenied`):n(`config:mobileServer.discoveryFailed`))}finally{r!==null&&await xr(`plugin:dns-sd|browse_stop`,{browseId:r}).catch(()=>void 0),C.current===e&&f(!1)}},[n]);(0,J.useEffect)(()=>{if(!(!e||o))return O(),()=>{C.current+=1}},[O,e,o]);let k=(0,J.useCallback)(async()=>{let e=w.current;w.current=``,e&&await xr(`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 xr(`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(Cr(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 Sr(`check_permissions`);if(e.camera!==`granted`&&(e=await Sr(`request_permissions`)),e.camera!==`granted`)throw Error(n(`config:mobileServer.cameraDenied`));if(x.current||(T(!0),await Tr(),x.current))return;let t=await Sr(`scan`,{windowed:!0,formats:[]});if(!t.content)throw Error(n(`config:mobileServer.scanFailed`));S.current=!0,D(await xr(`mobile_pair`,{payloadJson:t.content,deviceName:null}))}catch(e){!x.current&&!wr(e)&&v(Cr(e))}finally{T(!1),a(null),x.current=!1}};return(0,Y.jsx)(Ct,{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,Y.jsx)(yt,{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,Y.jsxs)(`div`,{className:`flex h-dvh w-screen flex-col overflow-hidden`,children:[(0,Y.jsxs)(St,{className:`sr-only`,children:[(0,Y.jsx)(bt,{children:n(`config:mobileServer.scanTitle`)}),(0,Y.jsx)(vt,{children:n(`config:mobileServer.scanHint`)})]}),(0,Y.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,Y.jsxs)(B,{variant:`ghost`,className:`h-10 bg-black/40 px-3 text-white hover:bg-black/70 hover:text-white`,onClick:()=>void E(),children:[(0,Y.jsx)(b,{}),n(`config:mobileServer.cancelScan`)]}),(0,Y.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium`,children:n(`config:mobileServer.scanTitle`)}),(0,Y.jsx)(`div`,{className:`w-[88px]`,"aria-hidden":`true`})]}),(0,Y.jsx)(`main`,{className:`grid min-h-0 flex-1 place-items-center p-6`,children:(0,Y.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,Y.jsx)(yn,{className:`absolute top-1/2 left-1/2 size-10 -translate-x-1/2 -translate-y-1/2 text-white/75`})})}),(0,Y.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,Y.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-white/90`,children:n(`config:mobileServer.scanHint`)}),(0,Y.jsx)(B,{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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(St,{children:[(0,Y.jsx)(bt,{children:n(`config:mobileServer.addServer`)}),(0,Y.jsx)(vt,{children:n(`config:mobileServer.discoverDescription`)})]}),(0,Y.jsxs)(`section`,{className:`grid gap-2`,"aria-live":`polite`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Y.jsx)(_n,{className:`size-4`}),n(`config:mobileServer.nearby`)]}),(0,Y.jsx)(B,{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,Y.jsx)(ue,{className:d?`animate-spin`:void 0})})]}),c.length?(0,Y.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,Y.jsxs)(`li`,{className:`flex min-h-12 items-center justify-between gap-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(me,{className:`size-4 flex-none text-muted-foreground`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`truncate text-sm`,children:e.name}),(0,Y.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.url})]})]}),(0,Y.jsxs)(B,{size:`sm`,className:`pointer-coarse:min-h-11`,disabled:i!==null,onClick:()=>void A(e),children:[t?(0,Y.jsx)(I,{className:`animate-spin`}):null,n(`config:mobileServer.requestConnect`)]})]},e.id)})}):(0,Y.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:n(d?`config:mobileServer.discovering`:`config:mobileServer.noNearby`)}),p?(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs leading-relaxed text-content-secondary`,children:p}):null,h?(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-[var(--r-md)] bg-surface-subtle px-3 py-2`,children:[(0,Y.jsx)(`p`,{role:`status`,className:`text-xs leading-relaxed`,children:h}),(0,Y.jsx)(B,{size:`sm`,variant:`outline`,className:`pointer-coarse:min-h-11`,onClick:()=>void k(),children:n(`config:mobileServer.cancelRequest`)})]}):null]}),(0,Y.jsxs)(`div`,{className:`relative py-1`,children:[(0,Y.jsx)(Xe,{}),(0,Y.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,Y.jsxs)(B,{className:`w-full pointer-coarse:min-h-11`,disabled:i!==null,onClick:()=>void j(),children:[i===`scan`?(0,Y.jsx)(I,{className:`animate-spin`}):(0,Y.jsx)(gn,{}),n(`config:mobileServer.scan`)]}),_?(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs leading-relaxed text-content-secondary`,children:_}):null]})})})}function Ar(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function jr({requestConfirm:e}){let{t}=l(),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)(``),[c,u]=(0,J.useState)(!1),d=(0,J.useCallback)(async()=>{try{r(await Ar(`mobile_state`)),a(``)}catch{a(t(`config:mobileServer.loadFailed`))}},[t]);(0,J.useEffect)(()=>{d()},[d]);let f=async(e,t,n=``)=>{s(n||e);try{r(await Ar(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 Ar(`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,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(At,{status:`done`,className:`size-3.5`}):(0,Y.jsx)(k,{className:`size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:v}),n?.activeTransport?(0,Y.jsx)(`span`,{className:`flex-none font-mono text-xs text-content-muted`,children:y(n.activeTransport)}):null]}),(0,Y.jsx)(kr,{open:c,onOpenChange:u}),i?(0,Y.jsx)(G,{className:`mt-3`,children:i}):null,(0,Y.jsx)(W,{title:t(`config:mobileServer.localTitle`),"data-config-card":`mobile-server-local`,children:(0,Y.jsx)(U,{children:(0,Y.jsx)(H,{icon:(0,Y.jsx)(xn,{}),name:t(`config:mobileServer.localTitle`),description:t(`config:mobileServer.localDescription`),status:h?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,Y.jsx)(At,{status:`done`,className:`size-3.5`}),t(`config:mobileServer.currentLocal`)]}):void 0,actions:h?void 0:(0,Y.jsx)(B,{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 Ar(`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,Y.jsx)(W,{title:t(`config:mobileServer.title`),count:n?.servers?.length??0,"data-config-card":`mobile-server-main`,description:t(`config:mobileServer.description`),actions:(0,Y.jsxs)(B,{size:`sm`,onClick:()=>u(!0),children:[(0,Y.jsx)(le,{}),t(`config:mobileServer.addServer`)]}),children:n?.servers?.length?(0,Y.jsx)(U,{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,Y.jsx)(H,{"data-mobile-server":e.id,icon:(0,Y.jsx)(me,{}),name:e.name,nameMeta:t(i&&a?`config:mobileServer.transportLanP2p`:a?`config:mobileServer.transportP2p`:`config:mobileServer.transportLan`),description:(0,Y.jsx)(`span`,{className:`font-mono`,children:s}),status:r?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,Y.jsx)(At,{status:`done`,className:`size-3.5`}),n.activeTransport?t(`config:mobileServer.activeTransport`,{transport:y(n.activeTransport)}):t(`config:mobileServer.current`)]}):void 0,actions:(0,Y.jsxs)(Y.Fragment,{children:[r?null:(0,Y.jsx)(B,{size:`sm`,variant:`ghost`,disabled:o===e.id,onClick:()=>void m(e.id),children:t(`config:mobileServer.connect`)}),(0,Y.jsx)(B,{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,Y.jsx)(ve,{})})]})},e.id)})}):(0,Y.jsx)(_t,{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 Mr({notify:e}){let{t,language:n}=l(),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)([]),[u,d]=(0,J.useState)([]),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(``),[y,b]=(0,J.useState)(``),[x,S]=(0,J.useState)(!1),[C,w]=(0,J.useState)(``),T=(0,J.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,J.useEffect)(()=>{T()},[T]),(0,J.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(``)}},N=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,Y.jsx)(ht,{kind:`error`,title:t(`config:remoteAccess.loadFailed`),action:(0,Y.jsxs)(B,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void T(),children:[(0,Y.jsx)(ue,{}),t(`config:remoteAccess.refresh`)]})});if(!r)return(0,Y.jsx)(ht,{kind:`loading`,title:t(`config:remoteAccess.loading`)});let P=r.error?`failed`:r.listening?`on`:r.enabled?`starting`:`off`,F=a!==null&&!a.busy&&[`needs_authorization`,`cancelled`,`error`,`cleanup_pending`].includes(a.state);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ct,{open:h&&p!==null,onOpenChange:g,children:(0,Y.jsxs)(yt,{className:`sm:max-w-md`,children:[(0,Y.jsxs)(St,{children:[(0,Y.jsx)(bt,{children:t(`config:remoteAccess.pairingQrTitle`)}),(0,Y.jsx)(vt,{children:t(`config:remoteAccess.scanQrDescription`)})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-2`,"aria-live":`polite`,children:[p?.qrDataUrl?(0,Y.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,Y.jsx)(`p`,{role:`alert`,className:`text-center text-xs leading-relaxed text-content-secondary`,children:_}):null,p?(0,Y.jsxs)(`div`,{className:`text-center`,children:[(0,Y.jsx)(`div`,{className:`font-mono text-[20px] font-medium tracking-[0.2em] text-content`,children:p.code}),(0,Y.jsx)(`div`,{className:`mt-1 text-xs text-content-muted tabular-nums`,children:t(`config:remoteAccess.codeExpiresAt`,{time:mt(p.expiresAt,n)})})]}):null]}),p?.connectionInfo&&(0,Y.jsxs)(`details`,{className:`min-w-0 rounded-md border border-stroke px-3 py-2 text-sm`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer text-content-secondary`,children:t(`remote-workspace:manualConnection`)}),(0,Y.jsxs)(`div`,{className:`mt-2 space-y-2 text-xs text-content-muted`,children:[(0,Y.jsx)(`div`,{children:t(`remote-workspace:serverAddress`)}),p.connectionInfo.endpoints.map(e=>(0,Y.jsx)(`code`,{className:`block font-mono break-all text-content select-all`,children:e.url},e.url)),(0,Y.jsx)(`div`,{children:t(`remote-workspace:fingerprint`)}),(0,Y.jsx)(`code`,{className:`block font-mono break-all text-content select-all`,children:p.connectionInfo.fingerprint})]})]}),(0,Y.jsx)(xt,{children:(0,Y.jsxs)(B,{disabled:x,onClick:()=>void j(),children:[x?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(ue,{}),t(x?`config:remoteAccess.generatingQr`:`config:remoteAccess.regenerate`)]})})]})}),C&&(0,Y.jsx)(G,{children:C}),(0,Y.jsx)(W,{title:t(`config:remoteAccess.thisComputer`),"data-config-card":`remote-access-main`,children:(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{icon:(0,Y.jsx)(oe,{}),name:t(`config:remoteAccess.allowConnections`),description:t(`config:remoteAccess.description`),status:(0,Y.jsx)(Nr,{attention:P===`failed`,glyph:P===`on`?`done`:P===`starting`?`run`:null,children:t(P===`failed`?`config:remoteAccess.stateFailed`:P===`on`?`config:remoteAccess.stateListening`:P===`starting`?`config:remoteAccess.stateStarting`:`config:remoteAccess.stateOff`)}),actions:(0,Y.jsx)(Qe,{checked:r.enabled,disabled:x,onCheckedChange:e=>void D(e),"aria-label":t(`config:remoteAccess.title`)}),detail:r.error?(0,Y.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,Y.jsx)(H,{"aria-live":`polite`,icon:(0,Y.jsx)(he,{}),name:t(`config:remoteAccess.firewallTitle`),description:a.busy?t(`config:remoteAccess.firewallWorking`):k[a.state],status:a.busy?(0,Y.jsx)(Nr,{glyph:`run`,children:t(`config:remoteAccess.firewallChecking`)}):F?(0,Y.jsx)(Nr,{attention:!0,children:t(`config:remoteAccess.firewallNeedsYou`)}):void 0,actions:r.enabled||a.state===`cleanup_pending`?(0,Y.jsxs)(B,{size:`sm`,variant:`secondary`,disabled:x||a.busy,onClick:()=>void O(),children:[x||a.busy?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(ue,{}),r.enabled?t(`config:remoteAccess.firewallRetry`):t(`config:remoteAccess.firewallRetryCleanup`)]}):void 0,detail:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-xs leading-relaxed text-content-muted`,children:[a.reason&&A[a.reason]?(0,Y.jsx)(`p`,{className:`text-content-secondary`,children:A[a.reason]}):null,r.enabled?(0,Y.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,Y.jsx)(`p`,{children:t(`config:remoteAccess.firewallReachability`)}),a.checkedAt?(0,Y.jsx)(`p`,{className:`tabular-nums`,children:t(`config:remoteAccess.firewallCheckedAt`,{time:mt(a.checkedAt,n)})}):null]})}):null]})}),r.listening&&u.length?(0,Y.jsx)(W,{"aria-live":`polite`,title:t(`config:remoteAccess.pendingApprovals`),count:u.length,meta:(0,Y.jsx)(`span`,{className:`font-medium text-st-attn`,children:t(`config:remoteAccess.waitingForYou`)}),description:t(`config:remoteAccess.pendingApprovalsDescription`),children:(0,Y.jsx)(U,{children:u.map(e=>(0,Y.jsx)(H,{"data-pairing-request":e.id,icon:(0,Y.jsx)(xn,{}),name:e.deviceName,description:(0,Y.jsx)(`span`,{className:`font-mono`,children:t(`config:remoteAccess.requestSource`,{ip:e.ip})}),meta:t(`config:remoteAccess.requestedAt`,{time:mt(e.requestedAt,n)}),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(B,{size:`sm`,variant:`ghost`,disabled:y===e.id,onClick:()=>void M(e,!1),children:[(0,Y.jsx)(xe,{}),t(`config:remoteAccess.reject`)]}),(0,Y.jsxs)(B,{size:`sm`,disabled:y===e.id,onClick:()=>void M(e,!0),children:[y===e.id?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(E,{}),t(`config:remoteAccess.approve`)]})]})},e.id))})}):null,r.listening?(0,Y.jsx)(W,{title:t(`config:remoteAccess.pairing`),"data-config-card":`remote-access-pairing`,children:(0,Y.jsx)(U,{children:(0,Y.jsx)(H,{icon:(0,Y.jsx)(gn,{}),name:t(`config:remoteAccess.pairWithPhone`),description:t(`config:remoteAccess.pairingDescription`),actions:(0,Y.jsxs)(B,{size:`sm`,disabled:x,onClick:()=>void j(),children:[x?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(gn,{}),t(x?`config:remoteAccess.generatingQr`:`config:remoteAccess.generateQr`)]}),detail:_&&!h?(0,Y.jsx)(`p`,{className:`text-xs leading-relaxed text-content-secondary`,"aria-live":`polite`,children:_}):void 0})})}):null,(0,Y.jsx)(W,{title:t(`config:remoteAccess.devices`),count:s.length,"data-config-card":`remote-access-devices`,actions:(0,Y.jsx)(B,{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,Y.jsx)(ue,{})}),children:s.length===0?(0,Y.jsx)(_t,{compact:!0,title:t(`config:remoteAccess.noDevices`)}):(0,Y.jsx)(U,{children:s.map(e=>(0,Y.jsx)(H,{icon:(0,Y.jsx)(xn,{}),name:e.name,nameMeta:e.current?t(`config:remoteAccess.currentDevice`):void 0,description:t(`config:remoteAccess.lastSeen`,{time:mt(e.lastSeenAt,n)}),actions:(0,Y.jsx)(B,{size:`sm`,variant:`ghost`,className:`hover:bg-danger-soft hover:text-danger`,"aria-label":`${t(`config:remoteAccess.revoke`)}: ${e.name}`,onClick:()=>void N(e),children:t(`config:remoteAccess.revoke`)})},e.id))})})]})}function Nr({attention:e=!1,glyph:t=null,children:n}){let r=e?`attention`:t;return(0,Y.jsxs)(`span`,{className:R(`inline-flex min-w-0 items-center gap-1.5 whitespace-nowrap`,e?`font-medium text-st-attn`:`text-content-secondary`),children:[r&&(0,Y.jsx)(At,{status:r,className:`size-3.5`}),n]})}function Pr({requestConfirm:e}){let{t}=l(),n=window.pisperDesktop?.remoteWorkspaces,[r,i]=(0,J.useState)([]),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(``),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(``),v=(0,J.useCallback)(async()=>{n&&i(await n.list())},[n]);(0,J.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,Y.jsx)(W,{title:t(`config:remoteWorkspace.title`),"data-config-card":`remote-workspaces`,children:(0,Y.jsx)(U,{children:(0,Y.jsx)(H,{icon:(0,Y.jsx)(me,{}),name:t(`remote-workspace:activeTitle`),description:t(`remote-workspace:activeDescription`),detail:(0,Y.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:t(`remote-workspace:isolation`)})})})}):n?(0,Y.jsxs)(W,{title:t(`config:remoteWorkspace.title`),count:r.length,"data-config-card":`remote-workspaces`,description:t(`remote-workspace:description`),actions:(0,Y.jsx)(B,{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,Y.jsx)(ue,{className:`size-3.5`})}),children:[r.length>0&&(0,Y.jsx)(U,{children:r.map(r=>(0,Y.jsx)(H,{icon:(0,Y.jsx)(me,{}),name:r.name,description:(0,Y.jsx)(`span`,{className:`font-mono`,children:r.address}),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(B,{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,Y.jsx)(S,{className:`size-3.5`})]}),(0,Y.jsx)(B,{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,Y.jsx)(ve,{className:`size-3.5`})})]})},r.id))}),(0,Y.jsxs)(`div`,{className:`@container/card mt-3 rounded-[var(--r-md)] border border-stroke px-3 pt-2 pb-1`,children:[(0,Y.jsx)(`p`,{className:`py-1.5 text-xs leading-relaxed text-content-secondary`,children:t(`remote-workspace:instructions`)}),(0,Y.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,Y.jsx)(or,{label:t(`remote-workspace:name`),htmlFor:`remote-workspace-name`,children:(0,Y.jsx)(V,{id:`remote-workspace-name`,value:a,maxLength:160,disabled:m,placeholder:`Linux`,onChange:e=>o(e.target.value)})}),(0,Y.jsx)(or,{label:t(`remote-workspace:address`),htmlFor:`remote-workspace-address`,children:(0,Y.jsx)(V,{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,Y.jsx)(or,{label:t(`remote-workspace:fingerprint`),htmlFor:`remote-workspace-fingerprint`,children:(0,Y.jsx)(V,{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,Y.jsx)(or,{label:t(`remote-workspace:code`),htmlFor:`remote-workspace-code`,children:(0,Y.jsx)(V,{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,Y.jsx)(`div`,{className:`flex justify-end py-3`,children:(0,Y.jsxs)(B,{type:`submit`,className:`max-[650px]:h-11`,disabled:m,children:[m?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(S,{className:`size-3.5`}),t(`remote-workspace:pair`)]})})]})]}),g&&(0,Y.jsx)(G,{className:`mt-3`,children:g}),(0,Y.jsx)(`p`,{className:`mt-3 text-xs leading-relaxed text-content-muted`,children:t(`remote-workspace:isolation`)})]}):null}function Fr({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,Y.jsx)(pr,{notify:t,requestConfirm:n}):e===`mobile-server`?(0,Y.jsx)(jr,{requestConfirm:n}):(0,Y.jsxs)(Y.Fragment,{children:[!window.__PISPER_REMOTE_WORKSPACE__&&(0,Y.jsx)(Mr,{notify:t}),(0,Y.jsx)(Pr,{requestConfirm:n})]}):(0,Y.jsx)(Ir,{section:e,support:s}),(0,Y.jsx)(Dt,{"data-device-feature":e,title:c,description:u,back:r&&{label:i(`navigation:sidebar.features`),ariaLabel:i(`navigation:shell.backToFeaturesLabel`),onBack:r},children:(0,Y.jsx)(`div`,{"data-config-card":nt,className:`min-w-0`,children:d})})}function Ir({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,Y.jsx)(W,{title:n(`config:deviceFeature.unavailableTitle`),"data-device-unsupported":!0,children:(0,Y.jsx)(U,{children:(0,Y.jsx)(H,{icon:e===`desktop-pet`?(0,Y.jsx)(w,{}):(0,Y.jsx)(oe,{}),name:r,description:i,status:n(`config:deviceFeature.unavailable`),actions:(0,Y.jsx)(Qe,{checked:!1,disabled:!0,"aria-label":r})})})})}function Lr({title:e,description:t,action:n,children:r,className:i,...a}){let o=(0,J.useId)();return(0,Y.jsxs)(`section`,{"aria-labelledby":o,className:R(`min-w-0`,i),...a,children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h2`,{id:o,className:`text-[15px] leading-6 font-medium text-content`,children:e}),t&&(0,Y.jsx)(`p`,{className:`mt-0.5 text-[13px] text-content-muted`,children:t})]}),n]}),(0,Y.jsx)(`div`,{className:`divide-y divide-stroke-soft`,children:r})]})}function Rr({title:e,description:t,control:n,nested:r,children:i,className:a,...o}){return(0,Y.jsxs)(`div`,{className:R(`min-w-0 py-3`,r&&`pl-4`,a),...o,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-6 gap-y-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 basis-40`,children:[(0,Y.jsx)(`div`,{className:`text-[13px] font-medium text-content`,children:e}),t&&(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-content-muted`,children:t})]}),n&&(0,Y.jsx)(`div`,{className:`max-w-full shrink-0`,children:n})]}),i]})}function zr({className:e,...t}){return(0,Y.jsx)(qn,{"data-slot":`radio-group`,className:R(`grid w-full gap-2`,e),...t})}function Br({className:e,...t}){return(0,Y.jsx)(Qn,{"data-slot":`radio-group-option`,className:R(`disabled:pointer-events-none disabled:opacity-50`,e),...t})}function Vr(e,t){return t(e===`en-US`?`config:languageSettings.english`:`config:languageSettings.simplifiedChinese`)}function Hr({notify:e}){let{language:t,setLanguage:n,t:r}=l(),i=(0,J.useId)(),a=(0,J.useId)(),o=r=>{r!==t&&(n(r),e(s(r===`en-US`?`config:languageSettings.displayLanguageChangedToEnglish`:`config:languageSettings.displayLanguageChangedToSimplifiedChinese`,r)))};return(0,Y.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,Y.jsxs)(`div`,{className:`min-w-0 flex-1 basis-40`,children:[(0,Y.jsx)(`h2`,{id:i,className:`text-sm font-medium text-content`,children:r(`config:languageSettings.displayLanguage`)}),(0,Y.jsx)(`p`,{id:a,className:`mt-0.5 text-xs leading-relaxed text-content-muted`,children:r(`config:languageSettings.interfaceOnlyHint`)})]}),(0,Y.jsxs)(Ye,{value:t,onValueChange:e=>{let t=c.find(t=>t.value===e);t&&o(t.value)},children:[(0,Y.jsx)(Ke,{"aria-labelledby":i,"aria-describedby":a,className:`min-w-36 shrink-0`,children:(0,Y.jsx)(Ge,{})}),(0,Y.jsx)(qe,{align:`end`,children:c.map(e=>(0,Y.jsx)(Je,{value:e.value,children:Vr(e.value,r)},e.value))})]})]})}function Ur({role:e,label:t,value:n,onCommit:r}){let{t:i}=l(),a=(0,J.useId)(),[o,s]=(0,J.useState)(String(n)),c=(0,J.useRef)(o),u=(0,J.useRef)(n),d=e===`ui`?Jt:Xt;(0,J.useEffect)(()=>{u.current=n,c.current=String(n),s(String(n))},[n]);let f=o!==String(n)&&Kt(o,e)===null,p=()=>{let t=Kt(c.current,e);t!==null&&t!==u.current&&(r(t),u.current=t)};return(0,Y.jsxs)(`div`,{className:`flex max-w-full flex-col items-end gap-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(V,{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,Y.jsx)(`span`,{className:`text-sm text-content-muted`,children:`px`})]}),f&&(0,Y.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 Wr({label:e,options:t,value:n,onChange:r}){return(0,Y.jsx)(zr,{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,Y.jsx)(Br,{type:`button`,className:R(`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 Gr={neutral:`var(--primary)`,blue:`#3d4bef`,teal:`#0f766e`,violet:`#6d4ad6`,coral:`#c93a48`,custom:`#3d4bef`};function Kr(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 qr({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 Jr({value:e,onCommit:t}){let{t:n}=l(),[r,i]=(0,J.useState)(e),a=(0,J.useRef)(e),[o,s]=(0,J.useState)(()=>Kr(e)),c=(0,J.useId)(),u=e=>{a.current=e,i(e)};(0,J.useEffect)(()=>{a.current=e,i(e),s(Kr(e))},[e]);let d=e=>{s(e),u(qr(e))},f=()=>{let n=Qt(a.current);n&&n!==Qt(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()&&!Qt(r);return(0,Y.jsxs)(We,{onOpenChange:t=>{t||(f(),Qt(a.current)||(u(e),s(Kr(e))))},children:[(0,Y.jsx)(He,{asChild:!0,children:(0,Y.jsxs)(B,{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,Y.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 shrink-0 rounded-full border border-stroke-strong`,style:{backgroundColor:e}}),(0,Y.jsx)(`span`,{className:`font-mono`,children:e})]})}),(0,Y.jsxs)(Ue,{align:`end`,sideOffset:8,className:`w-auto rounded-xl p-3`,children:[(0,Y.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(Kr(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,Y.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,Y.jsx)(Ze,{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,Y.jsx)(V,{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=Qt(e.target.value);t&&s(Kr(t))},onBlur:f,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f())}}),(0,Y.jsx)(`p`,{id:c,className:`max-w-34 text-xs text-muted-foreground`,children:n(m?`config:interfaceSettings.invalidAccentColor`:`config:interfaceSettings.colorSpectrumHint`)})]})]})}function Yr({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}=Gt(),w=v(e=>e.pinned),T=v(e=>e.setPinned),[E,O]=(0,J.useState)(t),k=(0,J.useId)(),A=(0,J.useId)();(0,J.useEffect)(()=>{t&&O(!0)},[t,n]);let j=i!==Wt.theme||a!==Wt.density||o!==Wt.accent||s!==Wt.customAccent||c!==Wt.uiFontSize||u!==Wt.codeFontSize||d!==Wt.radius||f!==Wt.motion,M=t=>n=>{t(n),e(r(`config:interfaceSettings.preferencesUpdated`))},N=[{value:`system`,label:r(`config:interfaceSettings.followSystem`),description:r(`config:interfaceSettings.followSystemDescription`),icon:mn},{value:`light`,label:r(`config:interfaceSettings.light`),description:r(`config:interfaceSettings.lightDescription`),icon:Cn},{value:`dark`,label:r(`config:interfaceSettings.dark`),description:r(`config:interfaceSettings.darkDescription`),icon:hn}],P=[{value:`comfortable`,label:r(`config:interfaceSettings.comfortable`),description:r(`config:interfaceSettings.comfortableDescription`),icon:Tn},{value:`compact`,label:r(`config:interfaceSettings.compact`),description:r(`config:interfaceSettings.compactDescription`),icon:fn}],F=[{value:`system`,label:r(`config:interfaceSettings.motionSystem`),description:r(`config:interfaceSettings.motionSystemDescription`),icon:mn},{value:`full`,label:r(`config:interfaceSettings.motionFull`),description:r(`config:interfaceSettings.motionFullDescription`),icon:ge},{value:`reduced`,label:r(`config:interfaceSettings.motionReduced`),description:r(`config:interfaceSettings.motionReducedDescription`),icon:_}],ee=[{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`)}],te=[{value:`sharp`,label:r(`config:interfaceSettings.sharp`)},{value:`default`,label:r(`config:interfaceSettings.standard`)},{value:`soft`,label:r(`config:interfaceSettings.soft`)}];return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Y.jsx)(Lr,{title:r(`config:interfaceSettings.visualStyle`),description:r(`config:interfaceSettings.appearanceDescription`),"data-config-card":`interface-appearance`,action:(0,Y.jsxs)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`pointer-coarse:h-11`,disabled:!j,onClick:()=>{C(),e(r(`config:interfaceSettings.defaultsRestored`))},children:[(0,Y.jsx)(fe,{size:14}),r(`config:interfaceSettings.restoreDefaults`)]}),children:(0,Y.jsxs)(ar,{children:[(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.colorMode`),control:(0,Y.jsx)(`div`,{role:`radiogroup`,"aria-label":r(`config:interfaceSettings.colorMode`),className:`grid w-68 max-w-full grid-cols-3 gap-4`,children:N.map(e=>(0,Y.jsxs)(`label`,{className:`group flex min-w-0 cursor-pointer flex-col items-center gap-2 text-xs text-content-muted`,children:[(0,Y.jsx)(`input`,{className:`peer sr-only`,type:`radio`,name:A,value:e.value,checked:i===e.value,onChange:()=>M(p)(e.value)}),(0,Y.jsxs)(`span`,{"aria-hidden":`true`,className:R(`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,Y.jsxs)(`span`,{className:`absolute inset-2 rounded border border-(--preview-light-line) bg-(--preview-light-bg)`,children:[(0,Y.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-1/4 border-r border-(--preview-light-line) bg-(--preview-light-side)`}),(0,Y.jsx)(`span`,{className:`absolute top-3 right-1 h-0.5 w-1/2 rounded bg-(--preview-light-line)`}),(0,Y.jsx)(`span`,{className:`absolute top-5 right-2 h-0.5 w-1/3 rounded bg-(--preview-light-line)`})]}),e.value!==`light`&&(0,Y.jsxs)(`span`,{className:R(`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,Y.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-1/4 border-r border-(--preview-dark-line) bg-(--preview-dark-side)`}),(0,Y.jsx)(`span`,{className:`absolute top-3 right-1 h-0.5 w-1/2 rounded bg-(--preview-dark-line)`}),(0,Y.jsx)(`span`,{className:`absolute top-5 right-2 h-0.5 w-1/3 rounded bg-(--preview-dark-line)`})]})]}),(0,Y.jsx)(`span`,{className:R(i===e.value&&`font-medium text-content`),children:e.label})]},e.value))})}),(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.accentColor`),description:r(`config:interfaceSettings.accentDescription`),control:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Y.jsxs)(Ye,{value:o,onValueChange:e=>{let t=ee.find(t=>t.value===e);t&&M(h)(t.value)},children:[(0,Y.jsx)(Ke,{"aria-label":r(`config:interfaceSettings.accentColor`),className:`min-w-36`,children:(0,Y.jsx)(Ge,{})}),(0,Y.jsx)(qe,{align:`end`,children:ee.map(e=>(0,Y.jsxs)(Je,{value:e.value,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 rounded-full border border-stroke-strong`,style:{backgroundColor:e.value===`custom`?s:Gr[e.value]}}),e.label]},e.value))})]}),o===`custom`&&(0,Y.jsx)(Jr,{value:Qt(s)||Wt.customAccent,onCommit:M(g)})]})})]})}),(0,Y.jsxs)(je,{open:E,onOpenChange:O,children:[(0,Y.jsx)(Ae,{asChild:!0,children:(0,Y.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,Y.jsx)(D,{size:16,"aria-hidden":`true`,className:R(`text-content-muted transition-transform`,!E&&`-rotate-90`)}),r(`config:interfaceSettings.advanced`)]})}),(0,Y.jsx)(ke,{id:k,children:(0,Y.jsxs)(ar,{className:`mt-3`,children:[(0,Y.jsxs)(`div`,{className:`divide-y divide-stroke-soft`,"data-config-card":`interface-style`,children:[(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.uiFontSize`),description:r(`config:interfaceSettings.numericFontHint`),control:(0,Y.jsx)(Ur,{role:`ui`,label:r(`config:interfaceSettings.uiFontSize`),value:c,onCommit:M(y)})}),(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.codeFontSize`),control:(0,Y.jsx)(Ur,{role:`code`,label:r(`config:interfaceSettings.codeFontSize`),value:u,onCommit:M(b)})}),(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.cornerStyle`),control:(0,Y.jsx)(Wr,{label:r(`config:interfaceSettings.cornerStyle`),options:te,value:d,onChange:M(x)})})]}),(0,Y.jsxs)(`div`,{className:`divide-y divide-stroke-soft`,"data-config-card":`interface-motion`,children:[(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.interfaceDensity`),control:(0,Y.jsx)(Wr,{label:r(`config:interfaceSettings.interfaceDensity`),options:P,value:a,onChange:M(m)})}),(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.pinInspector`),description:r(`config:interfaceSettings.pinInspectorDescription`),control:(0,Y.jsx)(Qe,{checked:w,onCheckedChange:M(T),"aria-label":r(`config:interfaceSettings.pinInspector`),"data-setting":`pin-inspector`})}),(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.motion`),control:(0,Y.jsx)(Wr,{label:r(`config:interfaceSettings.motion`),options:F,value:f,onChange:M(S)})}),(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.automaticByTime`),description:r(`config:interfaceSettings.automaticByTimeDescription`),control:(0,Y.jsx)(Qe,{checked:i===`scheduled`,onCheckedChange:e=>M(p)(e?`scheduled`:`system`),"aria-label":r(`config:interfaceSettings.automaticByTime`)})})]})]})})]}),(0,Y.jsx)(Hr,{notify:e})]})}function Xr({requestConfirm:e}){let{t}=l(),n=it(e=>e.bindings),r=it(e=>e.boardBindings),i=it(e=>e.setBinding),a=it(e=>e.setBoardBinding),o=it(e=>e.resetBindings),[s,c]=(0,J.useState)(null),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(!1),m=$t(),h=m.actions,g=m.boardActions,_=(e,n)=>{p(!1);let i=lt(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=st(n,e,r);if(a){d({action:e,message:t(`config:shortcuts.conflict`,{action:h[a]})});return}try{rt({...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=ct.includes(n),i=r?dt(e.nativeEvent):ut(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=ot.some(e=>n[e]!==at[e])||ct.some(e=>r[e]!==pt[e]),S=e=>{let i=ct.includes(e),a=i?g[e]:h[e],o=i?r[e]:n[e],l=i?pt[e]:at[e],f=t=>i?_(e,t):v(e,t);return(0,Y.jsxs)(`div`,{className:`py-2.5`,"data-shortcut-action":e,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-5 gap-y-2`,children:[(0,Y.jsx)(`label`,{htmlFor:`shortcut-${e}`,className:`min-w-0 text-sm font-medium text-content`,children:a}),(0,Y.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1 max-[650px]:w-full`,children:[(0,Y.jsx)(B,{id:`shortcut-${e}`,"data-shortcut-recorder":!0,variant:`outline`,className:R(`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,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:t(`config:shortcuts.recording`)}):ft(o)?(0,Y.jsx)($e,{className:`min-w-0 flex-wrap justify-center`,children:ft(o).split(` + `).map((e,t)=>(0,Y.jsx)(et,{className:`text-content-secondary`,children:e},t))}):(0,Y.jsx)(`span`,{className:`text-content-muted`,children:t(`config:shortcuts.disabled`)})}),(0,Y.jsxs)(Ve,{children:[(0,Y.jsx)(ze,{asChild:!0,children:(0,Y.jsx)(B,{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,Y.jsx)(P,{className:`size-4`})})}),(0,Y.jsxs)(Be,{align:`end`,className:`w-40`,onCloseAutoFocus:e=>{document.activeElement?.hasAttribute(`data-shortcut-recorder`)&&e.preventDefault()},children:[(0,Y.jsxs)(Le,{disabled:o===null,onSelect:()=>f(null),children:[(0,Y.jsx)(xe,{className:`size-4`}),t(`config:shortcuts.disableKey`)]}),(0,Y.jsxs)(Le,{disabled:o===l,onSelect:()=>f(l),children:[(0,Y.jsx)(fe,{className:`size-4`}),t(`config:shortcuts.resetAll`)]})]})]})]})]}),u?.action===e&&(0,Y.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,Y.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,Y.jsxs)(`span`,{className:`min-w-0 text-sm text-content-secondary`,children:[m.label(e),(0,Y.jsx)(`span`,{className:`ml-1.5 text-xs text-content-muted`,children:t(`board:shortcuts.fixed`)})]}),(0,Y.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1 max-[650px]:w-full`,children:[(0,Y.jsx)(nn,{keys:e.keys,className:`h-8 w-44 justify-center px-2.5 max-[650px]:flex-1`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`size-7 flex-none pointer-coarse:size-11 max-[650px]:size-11`})]})]},tn(e)):S(e.action);return(0,Y.jsxs)(`section`,{className:`w-full min-w-0`,"data-config-card":`shortcuts-bindings`,children:[(0,Y.jsx)(`div`,{className:`flex flex-col gap-5`,children:en.map((e,n)=>(0,Y.jsxs)(`section`,{"aria-labelledby":`shortcut-group-${e.id}`,"data-shortcut-group":e.id,children:[(0,Y.jsxs)(`div`,{className:`flex min-h-7 items-center justify-between gap-3`,children:[(0,Y.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,Y.jsxs)(B,{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,Y.jsx)(fe,{className:`size-3.5`,"aria-hidden":`true`}),t(`config:shortcuts.resetAll`)]})]}),(0,Y.jsx)(`p`,{className:`mb-2 text-xs text-content-muted`,children:m.groups[e.id].hint}),(0,Y.jsx)(ar,{children:e.entries.map(C)})]},e.id))}),(0,Y.jsx)(`div`,{className:`mt-3 min-h-5 text-xs text-content-muted`,role:`status`,"aria-live":`polite`,children:u?.action===null?(0,Y.jsx)(`span`,{className:`text-destructive`,children:u.message}):t(f?`config:shortcuts.saved`:`config:shortcuts.deviceScope`)})]})}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 Zr(e){let t=(0,J.useContext)(Ut);return(0,J.useLayoutEffect)(()=>{t?.update(e)}),(0,J.useLayoutEffect)(()=>()=>t?.remove(e.id),[t,e.id]),{requestClose:(0,J.useCallback)(n=>{t?t.requestClose(e.id,n):n()},[t,e.id])}}var Qr=[[`openai-responses`,`OpenAI Responses`],[`openai-completions`,`OpenAI Chat Completions`],[`anthropic-messages`,`Anthropic Messages`],[`google-generative-ai`,`Google Generative AI`]],$r={"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 ei(e){return!e||Qr.some(([t])=>t===e)?Qr:[...Qr,[e,$r[e]||e]]}var ti={openai:w,"openai-codex":w,anthropic:T,google:ge,deepseek:j,xai:ce,openrouter:se,"kimi-coding":ge,"zai-coding-cn":T},ni={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 ri(e,t){return t.name!==e.name||t.api!==e.api||t.baseUrl!==(e.baseUrl||``)||!!t.apiKey}function ii({provider:e,onSave:t,draft:n,onDraftChange:r,onSavingChange:i,children:a}){let{t:o}=l(),[s,c]=(0,J.useState)(!1),[u,d]=(0,J.useState)(``),f=(0,J.useId)(),p=ri(e,n),m=async a=>{if(a.preventDefault(),!s){c(!0),i(!0),d(``);try{t(await ni.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,Y.jsxs)(`form`,{onSubmit:e=>void m(e),"data-provider-connection-editor":!0,children:[(0,Y.jsxs)(`fieldset`,{disabled:s,className:`min-w-0 divide-y divide-stroke-soft`,children:[(0,Y.jsx)(or,{label:o(`config:configPage.displayName`),htmlFor:`${f}-name`,children:(0,Y.jsx)(V,{id:`${f}-name`,required:!0,value:n.name,onChange:e=>r({...n,name:e.target.value})})}),(0,Y.jsx)(or,{label:o(`config:configPage.apiKey`),htmlFor:`${f}-key`,children:(0,Y.jsx)(V,{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,Y.jsx)(or,{label:o(`config:configPage.apiProtocol`),labelId:`${f}-api-label`,help:(0,Y.jsx)(`span`,{className:`font-mono`,children:n.api}),children:(0,Y.jsx)(q,{"aria-labelledby":`${f}-api-label`,value:n.api,onChange:e=>r({...n,api:e.target.value}),children:ei(n.api).map(([e,t])=>(0,Y.jsx)(`option`,{value:e,children:t},e))})}),(0,Y.jsx)(or,{label:`Base URL`,htmlFor:`${f}-url`,children:(0,Y.jsx)(V,{id:`${f}-url`,required:!0,type:`url`,className:`font-mono`,value:n.baseUrl,onChange:e=>r({...n,baseUrl:e.target.value})})})]}),u&&(0,Y.jsx)(G,{className:`mt-2 mb-3`,children:u}),a,(0,Y.jsxs)(`div`,{className:R(`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,Y.jsx)(`span`,{role:`status`,className:`mr-auto text-xs text-content-muted`,children:o(`config:configPage.unsavedChanges`)}),(0,Y.jsx)(B,{type:`submit`,className:`max-[650px]:h-11`,disabled:!p,loading:s,children:o(s?`config:configPage.saving`:`config:configPage.saveChanges`)})]})]})}var ai=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function oi({label:e,checked:t,disabled:n,onChange:r}){return(0,Y.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t,disabled:n,onClick:r,className:R(`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,Y.jsx)(`span`,{"aria-hidden":`true`,className:R(`grid size-3.5 place-items-center rounded-[3px] border border-control`,t&&`border-star bg-star text-on-accent`),children:t&&(0,Y.jsx)(E,{size:11})}),e]})}function si({provider:e,model:t,onSave:n,onClose:r}){let{t:i}=l(),[a]=(0,J.useState)(()=>t?.contextWindow||2e5),[o,s]=(0,J.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,J.useState)(()=>({contextWindow:String(a),maxTokens:String(t?.maxTokens||8192)})),[d,f]=(0,J.useState)(t?.thinkingLevels||[`off`,`low`,`medium`,`high`]),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(``),y=o.capabilities.includes(`chat`),b=async i=>{if(i.preventDefault(),!h){g(!0),v(``);try{n(await ni.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,Y.jsx)(Ct,{open:!0,onOpenChange:e=>{!e&&!h&&r()},children:(0,Y.jsxs)(yt,{className:`sm:max-w-[540px] p-5`,showCloseButton:!h,onEscapeKeyDown:e=>{h&&e.preventDefault()},onInteractOutside:e=>e.preventDefault(),children:[(0,Y.jsxs)(St,{children:[(0,Y.jsx)(bt,{children:i(t?`providers:modelEditor.edit`:`providers:modelEditor.add`)}),(0,Y.jsxs)(vt,{children:[e.name,` · `,i(`providers:modelEditor.description`)]})]}),(0,Y.jsxs)(`form`,{onSubmit:e=>void b(e),className:`space-y-5`,children:[(0,Y.jsxs)(`fieldset`,{disabled:h,className:`space-y-5`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(`providers:modelEditor.id`),(0,Y.jsx)(V,{required:!0,disabled:!!t,value:o.modelId,onChange:e=>s({...o,modelId:e.target.value})})]}),(0,Y.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(`config:configPage.modelName`),(0,Y.jsx)(V,{value:o.name,onChange:e=>s({...o,name:e.target.value})})]})]}),(0,Y.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Y.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`providers:modelEditor.capabilities`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`chat`,`image`,`video`].map(e=>(0,Y.jsx)(oi,{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,Y.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:i(`providers:modelEditor.capabilitiesHint`)})]}),y&&(0,Y.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Y.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`providers:modelEditor.chatCapabilities`)}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(oi,{label:i(`providers:modelEditor.vision`),checked:o.input.includes(`image`),onChange:()=>s({...o,input:o.input.includes(`image`)?[`text`]:[`text`,`image`]})}),(0,Y.jsx)(oi,{label:i(`providers:modelEditor.reasoning`),checked:o.reasoning,onChange:()=>s({...o,reasoning:!o.reasoning})})]})]}),y&&o.reasoning&&(0,Y.jsxs)(`fieldset`,{children:[(0,Y.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`config:configPage.modelThinkingLevels`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ai.map(e=>(0,Y.jsx)(oi,{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,Y.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[`contextWindow`,`maxTokens`].map(e=>(0,Y.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(e===`contextWindow`?`providers:modelEditor.contextWindow`:`providers:modelEditor.maxTokens`),(0,Y.jsx)(V,{required:!0,type:`number`,min:1,max:1e8,step:1,value:c[e],onChange:t=>u({...c,[e]:t.target.value})})]},e))})]}),_&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:_}),(0,Y.jsxs)(xt,{children:[(0,Y.jsx)(B,{type:`button`,variant:`ghost`,disabled:h,onClick:r,children:i(`config:configPage.cancel`)}),(0,Y.jsxs)(B,{type:`submit`,disabled:h||!o.capabilities.length||!o.modelId.trim(),children:[h&&(0,Y.jsx)(I,{className:`animate-spin`,size:14}),` `,i(h?`config:configPage.saving`:`config:configPage.saveChanges`)]})]})]})]})})}function ci(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 li(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 ui(e){return e?e>=1e6?`${Number((e/1e6).toFixed(2))}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e):`—`}function di(e){return ei(e).find(([t])=>t===e)?.[1]||e}var fi=`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 pi(e){let{t}=l(),n=(0,J.useId)(),{providers:r,defaultId:i}=ci(e.config,e.selectedProviderId),a=r.find(t=>t.id===e.selectedProviderId),[o,s]=(0,J.useState)({}),[c,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(null),p=!!(c||e.settingDefault||e.settingModel||e.toggling||e.deletingModel);Zr({id:`provider-drafts-${n}`,dirty:r.some(e=>!!(o[e.id]&&ri(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`,ae,t.includes(`chat`)],[`image`,ne,t.includes(`image`)],[`video`,L,t.includes(`video`)],[`reasoning`,T,!!e.reasoning&&t.includes(`chat`)]].filter(([,,e])=>e).map(([e,t])=>(0,Y.jsxs)(`span`,{title:m[e],className:`inline-flex`,children:[(0,Y.jsx)(t,{size:13,"aria-hidden":`true`}),(0,Y.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,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,Y.jsx)(E,{className:`size-3.5`,"aria-hidden":`true`}),t(`config:providerWorkbench.connected`)]}):t(`config:configPage.disabled2`):t(`config:providerWorkbench.notConnected`),v=n=>(0,Y.jsxs)(`div`,{className:`@container/card min-w-0`,"data-provider-detail":n.id,children:[(0,Y.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,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-content-muted`,children:n.id}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-2 text-sm text-content-secondary`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:t(`config:configPage.enabled`)}),(0,Y.jsx)(ir,{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,Y.jsxs)(Ve,{children:[(0,Y.jsx)(ze,{asChild:!0,children:(0,Y.jsx)(B,{variant:`ghost`,size:`icon-sm`,className:`pointer-coarse:size-11 max-[650px]:size-11`,"aria-label":t(`config:providerWorkbench.actions`),children:(0,Y.jsx)(P,{size:16})})}),(0,Y.jsxs)(Be,{align:`end`,children:[(0,Y.jsxs)(Le,{disabled:n.id===i||!n.configured||!n.enabled||!n.defaultModel||p,onSelect:()=>void e.onSetDefault(n),children:[(0,Y.jsx)(Sn,{size:14}),t(`config:configPage.setAsDefaultProvider`)]}),(0,Y.jsxs)(Le,{disabled:p,onSelect:()=>e.onClone(n),children:[(0,Y.jsx)(M,{size:14}),t(`config:configPage.cloneProvider`)]}),n.custom&&(0,Y.jsxs)(Le,{className:`text-destructive`,disabled:p,onSelect:()=>void e.onDelete(n),children:[(0,Y.jsx)(ve,{size:14}),t(`config:configPage.deleteProvider`)]})]})]})]}),(0,Y.jsxs)(ii,{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,Y.jsxs)(`div`,{className:`mt-2 flex min-h-10 items-center gap-2 border-t border-stroke-soft pt-2`,children:[(0,Y.jsxs)(`h3`,{className:`text-[13px] font-medium text-content-muted`,children:[t(`config:providerWorkbench.models`),(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,n.models.length]})]}),(0,Y.jsxs)(B,{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,Y.jsx)(le,{size:14}),t(`providers:modelEditor.add`)]})]}),n.models.length>0&&(0,Y.jsxs)(`div`,{className:R(fi,`hidden h-8 text-xs font-medium text-content-muted @min-[560px]/card:grid`),children:[(0,Y.jsx)(`span`,{children:t(`providers:modelEditor.id`)}),(0,Y.jsx)(`span`,{children:t(`config:configPage.displayName`)}),(0,Y.jsx)(`span`,{className:`text-right`,children:t(`config:providerWorkbench.contextColumn`)}),(0,Y.jsx)(`span`,{children:t(`providers:modelEditor.capabilities`)}),(0,Y.jsx)(`span`,{"aria-hidden":`true`})]}),n.models.map(r=>{let i=n.defaultModel===r.id;return(0,Y.jsxs)(`div`,{"data-provider-model":r.id,className:R(fi,`min-h-11.5 border-t border-stroke-soft py-px text-sm text-content-secondary`),children:[(0,Y.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,Y.jsx)(`span`,{className:`block truncate font-mono text-[12.5px] text-content`,children:r.id}),(0,Y.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,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:r.name||r.id}),(0,Y.jsx)(`span`,{className:`tabular-nums`,children:ui(r.contextWindow)}),h(r)]})]}),(0,Y.jsx)(`span`,{className:`hidden min-w-0 truncate text-content @min-[560px]/card:block`,children:r.name||r.id}),(0,Y.jsx)(`span`,{className:`hidden text-right tabular-nums @min-[560px]/card:block`,children:ui(r.contextWindow)}),(0,Y.jsx)(`span`,{className:`hidden items-center gap-2 text-content-muted @min-[560px]/card:flex`,children:h(r)}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[r.kind===`chat`&&(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`icon-sm`,className:R(`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,Y.jsx)(Sn,{size:15,className:R(i&&`fill-current`)})}),(0,Y.jsx)(B,{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,Y.jsx)(bn,{size:14})}),(0,Y.jsx)(B,{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,Y.jsx)(ve,{size:14})})]})]},r.id)})]},n.id)]});return(0,Y.jsxs)(W,{"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,Y.jsx)(U,{children:r.map(n=>{let r=n.id===i,o=a?.id===n.id;return(0,Y.jsx)(H,{"data-provider-row":n.id,icon:(0,Y.jsx)(`span`,{className:`text-[13px] font-semibold text-content-secondary`,children:li(n.name)}),name:n.name,description:[g(n),t(`config:configPage.countModels`,{count:n.models.length}),di(n.api)].join(` · `),status:(0,Y.jsxs)(Y.Fragment,{children:[r&&(0,Y.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,Y.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,Y.jsx)(gt,{size:40,className:`mb-1`}),(0,Y.jsx)(`p`,{className:`text-sm font-medium text-content`,children:t(`config:providerWorkbench.noConnections`)}),(0,Y.jsx)(`p`,{className:`max-w-sm text-xs text-content-muted`,children:t(`config:providerWorkbench.addConnectionHint`)})]}),e.onAddConnection&&(0,Y.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,Y.jsx)(le,{size:16,"aria-hidden":`true`,className:`flex-none text-content-muted`}),(0,Y.jsx)(`span`,{className:`flex-none`,children:t(`config:providerWorkbench.addProvider`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:t(`config:providerWorkbench.addProviderHint`)})]}),d&&(0,Y.jsx)(si,{provider:d.provider,model:d.model,onSave:e.onSave,onClose:()=>f(null)})]})}function mi(){let e=globalThis.crypto.getRandomValues(new Uint32Array(4));return`custom-${Array.from(e,e=>e.toString(16).padStart(8,`0`)).join(``)}`}function hi({value:e,onChange:t,configured:n=!1,cloning:r=!1}){let{t:i}=l();return(0,Y.jsxs)(K,{variant:`control`,children:[i(`config:configPage.apiKey`),(0,Y.jsx)(V,{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 gi({ids:e,onChange:t,placeholder:n,primaryId:r=``}){let{t:i}=l(),[a,o]=(0,J.useState)(``),s=()=>{let n=a.trim();!n||n===r.trim()||e.includes(n)||(t([...e,n]),o(``))};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(K,{variant:`control`,children:[i(`config:configPage.manualModelIds`),(0,Y.jsxs)(`div`,{className:`flex items-stretch gap-1.5`,children:[(0,Y.jsx)(V,{"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,Y.jsx)(B,{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,Y.jsx)(le,{size:14})})]})]}),e.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-col overflow-hidden rounded-md border border-stroke`,children:e.map(n=>(0,Y.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,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12.5px] text-content`,children:n}),(0,Y.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,Y.jsx)(xe,{size:12})})]},n))}),(0,Y.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`config:configPage.manualModelIdsHint`)})]})}function _i(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 vi({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=_i(c,d),[m,h]=(0,J.useState)(``),g=!!(i||m),[_,v]=(0,J.useState)(()=>({name:a?s(`config:configPage.clonedProviderName`,{name:a.name}):i?.name||``,id:a?mi():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,J.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,J.useState)(!1),[T,D]=(0,J.useState)(``),[O,k]=(0,J.useState)(``),A=O.trim()||void 0,[j,M]=(0,J.useState)([]),N=e=>v(t=>({...t,name:e,id:t.id||e.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)}));return(0,J.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,Y.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,Y.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,Y.jsxs)(Ft,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{children:s(u?`config:configPage.cloneProvider`:g?`config:configPage.editProviderConnection`:`config:configPage.addProviderConnection`)}),!u&&(0,Y.jsx)(`p`,{children:s(g?`config:configPage.updateProviderKeyURLAndModelSettings`:`config:configPage.youCanCreateMultipleConnectionsUsingTheSameProtocolEachWithItsOwnKeyAndBaseURL`)})]}),(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`config:configPage.closeDialog`),disabled:C,onClick:t=>{t.preventDefault(),t.stopPropagation(),e()},children:(0,Y.jsx)(xe,{size:17})})]}),(0,Y.jsxs)(`div`,{className:`form-grid grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(K,{variant:`control`,children:[s(`config:configPage.displayName`),(0,Y.jsx)(V,{value:_.name,onChange:e=>N(e.target.value),placeholder:s(`config:configPage.forExampleOpenAIOfficial`)})]}),(0,Y.jsxs)(K,{variant:`control`,children:[`Provider ID`,(0,Y.jsx)(V,{value:_.id,disabled:g,onChange:e=>v({..._,id:e.target.value}),placeholder:`openai-official`})]})]}),(0,Y.jsx)(hi,{value:O,onChange:k,configured:i?.configured,cloning:u}),!u&&(0,Y.jsxs)(Y.Fragment,{children:[!o&&(0,Y.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,Y.jsx)(`span`,{className:`text-xs text-content-muted`,children:s(`config:configPage.providerPurpose`)}),(0,Y.jsx)(`strong`,{className:`font-mono text-xs font-medium`,children:_.providerType===`visual`?s(`config:configPage.visualProvider`):s(`config:configPage.chatProvider`)})]}),(0,Y.jsxs)(K,{variant:`control`,children:[s(`config:configPage.apiProtocol`),(0,Y.jsx)(q,{value:_.api,onChange:e=>v({..._,api:e.target.value}),children:Qr.map(([e,t])=>(0,Y.jsx)(`option`,{value:e,children:t},e))})]}),(0,Y.jsxs)(K,{variant:`control`,children:[`Base URL`,(0,Y.jsx)(V,{value:_.baseUrl,onChange:e=>v({..._,baseUrl:e.target.value}),placeholder:`https://api.openai.com/v1`})]}),(0,Y.jsxs)(`div`,{className:`form-grid grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(K,{variant:`control`,children:[s(g?`config:configPage.providerDefaultModel`:`config:configPage.initialModelID`),(0,Y.jsx)(V,{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,Y.jsxs)(K,{variant:`control`,children:[s(`config:configPage.modelName`),(0,Y.jsx)(V,{value:_.modelName,onChange:e=>v({..._,modelName:e.target.value}),placeholder:s(`config:configPage.leaveBlankToUseTheModelID`)})]})]}),(0,Y.jsxs)(`details`,{open:!o||void 0,className:`group rounded-lg border border-border px-3 py-2 [&[open]]:space-y-3`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer text-[13px] text-muted-foreground`,children:s(`config:providerWorkbench.modelOptions`)}),(0,Y.jsxs)(K,{variant:`control`,children:[s(`config:configPage.modelType`),(0,Y.jsxs)(q,{value:_.modelKind,onChange:e=>v({..._,modelKind:e.target.value,providerType:e.target.value===`chat`?`chat`:`visual`}),children:[(0,Y.jsx)(`option`,{value:`chat`,children:s(`providers:modelEditor.chat`)}),(0,Y.jsx)(`option`,{value:`image`,children:s(`providers:modelEditor.image`)}),(0,Y.jsx)(`option`,{value:`video`,children:s(`providers:modelEditor.video`)})]})]}),(0,Y.jsx)(`div`,{className:`grid gap-[9px]`,children:(0,Y.jsx)(gi,{ids:j,onChange:M,primaryId:_.model,placeholder:_.providerType===`visual`?`gpt-image-1`:`gpt-5.5`})}),_.modelKind===`chat`&&(0,Y.jsxs)(K,{variant:`control`,children:[s(`config:configPage.modelThinkingLevels`),(0,Y.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,Y.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r,onClick:()=>!t&&S(e),className:R(`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,Y.jsx)(E,{size:12}),e]},e)})}),(0,Y.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:s(`config:configPage.modelThinkingLevelsHint`)})]})]}),!o&&(0,Y.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,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Y.jsx)(`strong`,{className:`text-[13px]`,children:g?s(`config:configPage.providerEnabled`,{name:_.name}):s(`config:configPage.enableAfterCreation`)}),_.providerType===`visual`&&(0,Y.jsx)(`small`,{className:`text-[13px] text-muted-foreground`,children:s(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]}),(0,Y.jsx)(ir,{value:_.enabled,onChange:e=>v({..._,enabled:e})})]})]}),T&&(0,Y.jsxs)(Nt,{children:[(0,Y.jsx)(ye,{size:13}),T]}),(0,Y.jsxs)(`div`,{className:`mt-[18px] flex justify-end gap-2`,children:[(0,Y.jsx)(B,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:C,onClick:e,children:s(`config:configPage.cancel`)}),(0,Y.jsxs)(B,{type:`submit`,className:`max-[650px]:h-11`,disabled:C,children:[C?(0,Y.jsx)(z,{className:`text-current`}):g?(0,Y.jsx)(E,{size:14}):(0,Y.jsx)(le,{size:14}),s(C?`config:configPage.saving`:u?`config:configPage.cloneProvider`:g?`config:configPage.saveChanges`:`config:configPage.createConnection`)]})]})]})})}function yi(e){return(e.providers||[]).filter(e=>e.importable&&!e.imported&&!e.conflict).length}function bi(e){return yi(e)>0}function xi(e,t){return!t&&!bi(e)}function Si(e,t,n){let r=e.providers||[],i=e.errors||[],a=bi(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 Ci(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 wi(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 Ti(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 Ei({discovery:e,discovering:t,error:n,importing:r,forceVisible:i=!1,onRefresh:a,onImport:o}){let{t:s}=l(),[c,u]=(0,J.useState)(null),d=e.providers||[],f=e.errors||[];if(!i&&!Si(e,t,n))return null;let p=c??(!i&&xi(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,Y.jsxs)(tr,{className:`mb-3 py-3.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5 max-[650px]:flex-wrap`,children:[(0,Y.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,Y.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,Y.jsx)(me,{size:18})}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium text-content`,children:s(`config:configPage.localProviderConfiguration`)}),(0,Y.jsx)(`span`,{className:`text-xs leading-[1.45] text-content-muted`,children:s(`config:configPage.readProviderEndpointModelAndAuthenticationFieldsFromCodexConfigTomlAndClaudeSettingsJson`)})]}),(0,Y.jsx)(D,{size:16,"aria-hidden":`true`,className:R(`flex-none text-content-muted transition-transform`,!p&&`rotate-180`)})]}),(0,Y.jsxs)(B,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:t||!!r,onClick:m,children:[t?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(ue,{size:13}),s(`config:configPage.rescan`)]})]}),!p&&(0,Y.jsxs)(Y.Fragment,{children:[t&&!d.length?(0,Y.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,Y.jsx)(z,{}),s(`config:configPage.scanningProviderConfigurationFiles`)]}):d.length?(0,Y.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 max-[650px]:grid-cols-1`,children:d.map(e=>{let t=Ci(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,Y.jsxs)(`div`,{className:R(`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,Y.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,Y.jsx)(i,{size:15})}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Y.jsxs)(`span`,{className:`truncate text-sm font-medium text-content`,children:[t,` · `,e.providerName]}),(0,Y.jsxs)(`span`,{className:`truncate font-mono text-xs text-content-muted`,children:[e.api,` · `,a]}),(0,Y.jsxs)(`span`,{className:`truncate text-xs text-content-muted`,children:[e.kind===`authentication`?s(`config:configPage.officialEndpointOnly`):e.baseUrl||s(`config:configPage.noBaseURLSpecified`),` `,`· `,wi(e,s),` · `,e.location]})]}),(0,Y.jsx)(`span`,{className:`flex min-w-0 flex-none items-center max-[650px]:col-start-2`,children:e.imported?(0,Y.jsx)(rr,{tone:`green`,children:s(`config:configPage.loaded`)}):e.conflict?(0,Y.jsx)(rr,{tone:`amber`,children:s(`config:configPage.conflictDetected`)}):e.importable?(0,Y.jsxs)(B,{type:`button`,size:`sm`,className:`pointer-coarse:h-11`,disabled:n||!!r,onClick:()=>h(e),children:[n?(0,Y.jsx)(z,{className:`size-3 text-current`}):(0,Y.jsx)(N,{size:12}),n?s(`config:configPage.loading`):e.kind===`authentication`?s(`config:configPage.loadLoginState`):s(`config:configPage.loadConfiguration`)]}):(0,Y.jsx)(rr,{tone:`gray`,children:s(`config:configPage.cannotLoad`)})})]},e.id)})}):(0,Y.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,Y.jsx)(me,{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,Y.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,Y.jsxs)(`span`,{children:[(0,Y.jsx)(ye,{size:13}),n]}),f.map((e,t)=>(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(ye,{size:13}),Ci(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,Y.jsxs)(`span`,{children:[(0,Y.jsx)(ye,{size:13}),Ci(e),` · `,Ti(t.code,s)]},`${e.id}-${t.code}-${n}`)))]})]})]})}function Di(e){try{return{name:new URL(e).hostname.replace(/^www\./i,``)||`Custom Provider`}}catch{return{name:`Custom Provider`}}}function Oi({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,J.useState)(1),[d,p]=(0,J.useState)(s),[m]=(0,J.useState)(mi),[h,g]=(0,J.useState)(``),_=(0,J.useRef)(null),v=(0,J.useRef)(null),[y,S]=(0,J.useState)(s?.baseUrl||``),[C,w]=(0,J.useState)(s?.api||`openai-responses`),[T,D]=(0,J.useState)(``),O=T.trim()||void 0,[k,A]=(0,J.useState)(s?.organization||``),[j,M]=(0,J.useState)(s?.name||``),[N,P]=(0,J.useState)(s?.models||[]),[F,ee]=(0,J.useState)(s?.defaultModel||``),[te,ne]=(0,J.useState)([]),[re,ie]=(0,J.useState)(s?.models.find(e=>e.id===s.defaultModel)?.kind||(t===`visual`?`image`:`chat`)),[I,ae]=(0,J.useState)(!1),[oe,L]=(0,J.useState)(``),[se,ce]=(0,J.useState)(``),le=Di(y),de=o(t===`visual`?`config:configPage.visualProvider`:`config:configPage.chatProvider`),fe=o(c===1?`config:configPage.quickSetupStepBaseUrl`:c===2?`config:configPage.quickSetupStepProtocol`:`config:configPage.quickSetupStepModel`),pe=N.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{L(o(`config:configPage.providerBaseURLMustBeHTTPOrHTTPS`));return}L(``),j.trim()||M(le.name),u(2)},ge=()=>{if(!C){L(o(`config:configPage.selectAPIProtocol`));return}L(``),u(3)},_e=async()=>{if(I)return;let e=d;if(!O&&!e?.configured&&!h){L(o(`config:configPage.enterTheAPIKeyForThisConnection`));return}ae(!0),L(``),ce(``);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){L(o(t===`visual`?`config:configPage.fetchOrAddAVisualModel`:`config:configPage.fetchOrAddAChatModel`));return}P(n);let r=n.find(e=>e.id===F)||n[0];ee(r.id),ie(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){P(i);let e=i.find(e=>e.id===F)||i[0];ee(e.id),ie(t===`visual`?e.kind:`chat`),ce(r)}else L(r)}finally{ae(!1)}},ve=async()=>{if(I)return;let e=F.trim()||te[0]||``;if(!e){L(o(`config:configPage.selectModelToFinish`));return}if(!O&&!d?.configured&&!h){L(o(`config:configPage.enterTheAPIKeyForThisConnection`));return}let n=new Set((d?.models||[]).map(e=>e.id)),r=te.filter(t=>t!==e&&!n.has(t));ae(!0),L(``);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`?re:`chat`,apiKey:O,setAsDefault:!1,enabled:!0})}):await f(`/api/providers`,{method:`POST`,body:JSON.stringify({id:m,name:j.trim()||le.name,providerType:t,api:C,baseUrl:y,organization:k,apiKey:O,model:e,modelKind:t===`visual`?re:`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`?re:`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){L(e instanceof Error?e.message:String(e));return}}a(l?{...o,createdProviderId:l}:o)}catch(e){L(e instanceof Error?e.message:String(e))}finally{ae(!1)}};return(0,Y.jsx)(Ct,{open:!0,onOpenChange:e=>{!e&&!I&&r()},children:(0,Y.jsxs)(yt,{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":I,onEscapeKeyDown:e=>{I&&e.preventDefault()},onInteractOutside:e=>{I&&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,Y.jsxs)(Ft,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(bt,{asChild:!0,children:(0,Y.jsx)(`h2`,{children:o(t===`visual`?`config:configPage.visualQuickSetupTitle`:`config:configPage.quickSetupTitle`)})}),(0,Y.jsx)(vt,{asChild:!0,children:(0,Y.jsxs)(`p`,{children:[o(`config:configPage.stepIndicator`,{current:c,total:3}),` · `,fe]})})]}),(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`icon`,className:`pointer-coarse:size-11`,"aria-label":o(`config:configPage.closeDialog`),disabled:I,onClick:r,children:(0,Y.jsx)(xe,{size:17})})]}),(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`mt-3 grid grid-cols-3 gap-1`,children:[1,2,3].map(e=>(0,Y.jsx)(`span`,{className:R(`h-1 rounded-full`,e<=c?`bg-star`:`bg-surface-active`)},e))}),(0,Y.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,Y.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,Y.jsx)(me,{size:15,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`truncate text-sm font-medium text-content`,children:j||le.name}),(0,Y.jsx)(`small`,{className:`text-xs text-content-muted`,children:de})]}),(0,Y.jsx)(rr,{tone:`gray`,children:de})]}),c===1&&(0,Y.jsxs)(`div`,{className:`[margin-top:14px]`,children:[(0,Y.jsxs)(K,{variant:`control`,children:[`Base URL`,(0,Y.jsx)(V,{ref:v,value:y,onChange:e=>S(e.target.value),placeholder:`https://api.example.com/v1`,inputMode:`url`})]}),(0,Y.jsx)(`p`,{className:`mt-2 text-xs leading-[1.5] text-content-muted`,children:o(`config:configPage.quickSetupBaseUrlHint`)})]}),c===2&&(0,Y.jsxs)(`div`,{className:`[margin-top:14px]`,children:[(0,Y.jsxs)(K,{variant:`control`,children:[o(`config:configPage.apiProtocol`),(0,Y.jsx)(q,{value:C,onChange:e=>w(e.target.value),children:Qr.map(([e,t])=>(0,Y.jsx)(`option`,{value:e,children:t},e))})]}),(0,Y.jsxs)(K,{variant:`control`,children:[`Organization`,(0,Y.jsx)(V,{value:k,onChange:e=>A(e.target.value),placeholder:o(`config:configPage.optionalUsedOnlyForOpenAIOrganization`)})]})]}),c===3&&(0,Y.jsxs)(`div`,{className:`[margin-top:14px]`,children:[!d&&(0,Y.jsxs)(K,{variant:`control`,children:[o(`config:configPage.displayName`),(0,Y.jsx)(V,{value:j,onChange:e=>M(e.target.value),placeholder:le.name})]}),(0,Y.jsx)(hi,{value:T,onChange:D,configured:d?.configured}),(0,Y.jsxs)(B,{type:`button`,variant:`secondary`,className:`mt-2.5 w-full max-[650px]:h-11`,disabled:I,onClick:()=>void _e(),children:[I?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(ue,{size:14}),o(I?`config:configPage.fetchingModels`:`config:configPage.fetchModels`)]}),se&&(0,Y.jsxs)(Mt,{className:`[margin-top:10px]`,children:[(0,Y.jsx)(ye,{size:15}),(0,Y.jsx)(`small`,{children:o(`config:configPage.discoverFailedUsingExisting`,{message:se})})]}),pe.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(`div`,{className:`flex max-h-[260px] flex-col overflow-y-auto rounded-md border border-stroke`,children:pe.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:R(`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`,F===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:()=>{ee(e.id),ie(t===`visual`?e.kind:`chat`)},children:[(0,Y.jsx)(`span`,{className:R(`grid size-4 flex-none place-items-center rounded-full border border-control text-transparent`,F===e.id&&`border-star bg-star text-on-accent`),children:(0,Y.jsx)(E,{size:11})}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-content`,children:e.name}),t===`visual`&&(0,Y.jsx)(rr,{tone:`gray`,children:e.kind===`video`?o(`config:configPage.visualVideoModel`):o(`config:configPage.visualImageModel`)})]},`${e.id}-${e.kind}`))})]}),(0,Y.jsxs)(`div`,{className:`mt-3.5 grid gap-2`,children:[(0,Y.jsxs)(K,{variant:`control`,children:[o(`config:configPage.manualModelId`),(0,Y.jsx)(V,{value:F,onChange:e=>ee(e.target.value),placeholder:t===`visual`?`gpt-image-1`:`gpt-5.4`})]}),(0,Y.jsx)(`p`,{className:`text-xs text-content-muted`,children:o(`config:configPage.manualModelIdHint`)}),t===`visual`&&(0,Y.jsxs)(K,{variant:`control`,children:[o(`config:configPage.modelType`),(0,Y.jsxs)(q,{value:re,onChange:e=>ie(e.target.value),children:[(0,Y.jsx)(`option`,{value:`image`,children:o(`config:configPage.imageGenerationAndEditing`)}),(0,Y.jsx)(`option`,{value:`video`,children:o(`config:configPage.videoGeneration`)})]})]}),(0,Y.jsx)(gi,{ids:te,onChange:ne,primaryId:F,placeholder:t===`visual`?`gpt-image-1`:`gpt-5.5`})]})]}),oe&&(0,Y.jsxs)(Nt,{children:[(0,Y.jsx)(ye,{size:13}),oe]}),(0,Y.jsxs)(`div`,{className:`mt-[18px] flex justify-between gap-2`,children:[(0,Y.jsxs)(B,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:I||c===1,onClick:()=>{L(``),u(c-1)},children:[(0,Y.jsx)(b,{size:14}),o(`config:configPage.previousStep`)]}),c===1?(0,Y.jsxs)(B,{type:`button`,className:`max-[650px]:h-11`,disabled:I||!y.trim(),onClick:he,children:[(0,Y.jsx)(x,{size:14}),o(`config:configPage.nextStep`)]}):c===2?(0,Y.jsxs)(B,{type:`button`,className:`max-[650px]:h-11`,disabled:I,onClick:ge,children:[(0,Y.jsx)(x,{size:14}),o(`config:configPage.nextStep`)]}):(0,Y.jsxs)(B,{type:`button`,className:`max-[650px]:h-11`,disabled:I||!F.trim()&&te.length===0,onClick:()=>void ve(),children:[I?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(E,{size:14}),o(I?`config:configPage.saving`:`config:configPage.saveChanges`)]})]})]})})}var ki=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],Ai=``;function ji(e){return`${e.provider.id}/${e.model.id}`}function Mi({labelId:e,label:t,hint:n,children:r}){return(0,Y.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,Y.jsxs)(`div`,{className:`min-w-[min(240px,100%)] flex-1`,children:[(0,Y.jsx)(`div`,{id:e,className:`text-sm font-medium text-content`,children:t}),(0,Y.jsx)(`p`,{id:`${e}-hint`,className:`mt-0.5 text-xs text-content-muted`,children:n})]}),(0,Y.jsx)(`div`,{className:`w-[min(280px,100%)] min-w-0 max-[650px]:w-full`,children:r})]})}function Ni({config:e,notify:t,busy:n,onConfigChanged:r,onSetDefaultModel:i}){let{t:a}=l(),o=(0,J.useId)(),[s,c]=(0,J.useState)(!1),[u,d]=(0,J.useState)(``),[p,m]=(0,J.useState)(e.thinkingLevel),[h,g]=(0,J.useState)(e.toolMode);(0,J.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-CsE52ydO.js";import{i,r as a}from"./vendor-react-DwNgTV1j.js";import{c as o,d as s,n as c}from"./i18n-CHmr7GzM.js";import{t as l}from"./use-i18n-B5p-Kzvz.js";import{a as u,l as d,t as f}from"./api-BO7LAPSQ.js";import{n as p}from"./runtime-capabilities-4_ZwLBqF.js";import{t as m}from"./runtime-capabilities-store-C2Qv7uDP.js";import{n as h}from"./client-store-6GNC8uyK.js";import{t as g}from"./createLucideIcon-Cd-3GVxJ.js";import{a as _,i as v,t as y}from"./permission-rules-api-BoJ_1W-m.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 N}from"./download-BCfIiuaL.js";import{t as P}from"./ellipsis-CfGKfbq6.js";import{t as F}from"./external-link-CEQqPcqc.js";import{n as ee,t as te}from"./wand-sparkles-CvEBNUFz.js";import{t as ne}from"./image-BY_c3FYU.js";import{i as re,o as ie}from"./settings-navigation-_yUm71Uk.js";import{t as I}from"./loader-circle-BOwQzHB-.js";import{t as ae}from"./message-square-SKjZyY3v.js";import{t as oe}from"./monitor-smartphone-B1gIjItA.js";import{n as L,r as se,t as ce}from"./zap-DZHw5afO.js";import{t as le}from"./plus-fQbSqB1n.js";import{t as ue}from"./refresh-cw-TbWxTY4K.js";import{t as de}from"./rocket-BgLSjoHY.js";import{t as fe}from"./rotate-ccw-C0v8V77_.js";import{t as pe}from"./search-D0mqDaf_.js";import{t as me}from"./server-BgNvmqwJ.js";import{t as he}from"./shield-check-Gvek4RJ7.js";import{t as ge}from"./sparkles-S_eeuqn9.js";import{t as _e}from"./square-terminal-BVG6cUT1.js";import{t as ve}from"./trash-2-CNrPOoPR.js";import{t as ye}from"./triangle-alert-CE1q54ci.js";import{t as be}from"./wrench-6pg6_bqI.js";import{t as xe}from"./x-07u4-129.js";import{t as Se}from"./brand-DIEc3fK8.js";import{a as Ce}from"./dist-41X0pdUs.js";import{c as we,i as Te,o as Ee,s as De}from"./dist-BsRXXcSL.js";import{t as Oe}from"./dist-DzGQ7sLi.js";import{n as ke,r as Ae,t as je}from"./collapsible-DMaUQRX4.js";import{t as Me}from"./dist-OB2r6Xsr.js";import{n as Ne,r as Pe,t as Fe}from"./dist-BaBySQmo.js";import{c as Ie,i as Le,n as Re,p as ze,r as Be,t as Ve}from"./dropdown-menu-CFIFNaKO.js";import{i as He,n as Ue,t as We}from"./popover--UmYQ9yB.js";import{a as Ge,i as Ke,n as qe,r as Je,t as Ye}from"./select-DD_WO-gs.js";import{t as Xe}from"./separator-BPh_qxvc.js";import{t as Ze}from"./slider-DTmAZl-R.js";import{t as Qe}from"./switch-D_G8wFhs.js";import{t as R}from"./utils-C8uzG5AZ.js";import{n as z,t as B}from"./button-CCcCN8tE.js";import{n as $e,t as et}from"./kbd-CAufZTkl.js";import{i as tt,t as nt}from"./config-search-HBKDuym0.js";import{_ as rt,c as it,d as at,f as ot,h as st,l as ct,m as lt,o as ut,p as dt,t as ft,u as pt}from"./shortcuts-Cvp9WD9O.js";import{a as mt}from"./format-DMJQzoZ7.js";import{n as ht,r as gt,t as _t}from"./PageState-Cz6vFMXv.js";import{a as vt,i as yt,l as bt,o as xt,s as St,t as Ct}from"./dialog-CUhFgsVd.js";import{t as V}from"./input-CPw-zkYh.js";import{t as wt}from"./textarea-DmATpOqT.js";import{t as Tt}from"./model-display-kDwvtxrW.js";import{t as Et}from"./useOverlayFocusReturn-NkxBSSjb.js";import{i as H,n as U,o as W,r as Dt,s as Ot,t as G}from"./FeaturePage-Bkt1wWVg.js";import{n as K}from"./field-DoLEb0np.js";import{t as kt}from"./MarkdownMessage-yl-PSRAz.js";import{t as At}from"./StatusGlyph-1KgitlUg.js";import{t as jt}from"./badge-CWB3lj2H.js";import{a as Mt,i as Nt,l as Pt,n as Ft,o as It,r as Lt,s as Rt,t as zt}from"./app-primitives-Drz_SjnR.js";import{t as q}from"./AppSelect-BGVBQRP1.js";import{t as Bt}from"./usePagePrimaryAction-CWPC0C_f.js";import{t as Vt}from"./BrandLogo-k3CvJjd4.js";import{a as Ht,c as Ut,d as Wt,f as Gt,g as Kt,i as qt,m as Jt,o as Yt,p as Xt,r as Zt,v as Qt}from"./app-update-DKWPHTUY.js";import{a as $t,n as en,r as tn,t as nn}from"./ShortcutKeys-DQFnMnX1.js";import{i as rn,n as an,r as on,t as sn}from"./browser-notifications-DBS0oXqN.js";var cn=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`}]]),ln=g(`blend`,[[`circle`,{cx:`9`,cy:`9`,r:`7`,key:`p2h5vp`}],[`circle`,{cx:`15`,cy:`15`,r:`7`,key:`19ennj`}]]),un=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`}]]),dn=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`}]]),fn=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`}]]),pn=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`}]]),mn=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`}]]),hn=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`}]]),gn=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`}]]),_n=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`}]]),vn=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`}]]),yn=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`}]]),bn=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`}]]),xn=g(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Sn=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`}]]),Cn=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`}]]),wn=g(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Tn=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`}]]),J=e(i(),1),Y=a(),En=Object.defineProperty,X=(e,t)=>En(e,`name`,{value:t,configurable:!0}),Dn=`Radio`,[On,kn]=De(Dn),[An,jn]=On(Dn);function Mn(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]=J.useState(null),[p,m]=J.useState(null),h=J.useRef(!1),[g,_]=J.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:X(()=>s?.(),`onCheck`)};return(0,Y.jsx)(An,{scope:t,...v,children:Ln(u)?u(v):r})}X(Mn,`RadioProvider`);var Nn=`RadioTrigger`,Pn=J.forwardRef(X(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}=jn(Nn,e),p=Ce(r,s);return(0,Y.jsx)(we.button,{type:`button`,role:`radio`,"aria-checked":i,"data-state":Rn(i),"data-disabled":a?``:void 0,disabled:a,value:o,...n,ref:p,onClick:Ee(t,e=>{i||(u(),c()),f&&d&&(l.current=e.isPropagationStopped(),l.current||e.stopPropagation())})})},`RadioTrigger`)),Fn=`RadioBubbleInput`,In=J.forwardRef(X(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}=jn(Fn,e),h=Ce(r,f),g=Me(i),_=J.useRef(!1),v=J.useRef(a),y=J.useRef(m);J.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=J.useRef(a);return(0,Y.jsx)(we.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:Ee(t,e=>{_.current&&e.stopPropagation()}),style:{...n.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`RadioBubbleInput`));function Ln(e){return typeof e==`function`}X(Ln,`isFunction`);function Rn(e){return e?`checked`:`unchecked`}X(Rn,`getState`);var zn=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`],Bn=`RadioGroup`,[Vn,Hn]=De(Bn,[Pe,kn]),Un=Pe(),Wn=kn(),[Gn,Kn]=Vn(Bn),qn=J.forwardRef(X(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=Un(n),h=Oe(u),[g,_]=Te({prop:o,defaultProp:a??null,onChange:f,caller:Bn}),[v,y]=J.useState(null),b=Ce(t,y),x=J.useRef(g);return J.useEffect(()=>{let e=i?v?.ownerDocument.getElementById(i):v?.closest(`form`);if(e instanceof HTMLFormElement){let t=X(()=>_(x.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[v,i,_]),(0,Y.jsx)(Gn,{scope:n,name:r,form:i,required:s,disabled:c,value:g,onValueChange:_,children:(0,Y.jsx)(Ne,{asChild:!0,...m,orientation:l,dir:h,loop:d,children:(0,Y.jsx)(we.div,{role:`radiogroup`,"aria-required":s,"aria-orientation":l,"data-disabled":c?``:void 0,dir:h,...p,ref:b})})})},`RadioGroup`)),Jn=`RadioGroupItemProvider`,Yn=`RadioGroupItemTrigger`;function Xn(e){let{__scopeRadioGroup:t,value:n,disabled:r,children:i,internal_do_not_use_render:a}=e,o=Kn(Jn,t),s=Wn(t),c=o.disabled||r;return(0,Y.jsx)(Mn,{...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})}X(Xn,`RadioGroupItemProvider`);var Zn=J.forwardRef(X(function(e,t){let{__scopeRadioGroup:n,...r}=e,i=Un(n),a=Wn(n),{checked:o,disabled:s}=jn(Yn,a.__scopeRadio),c=J.useRef(null),l=Ce(t,c),u=J.useRef(!1);return J.useEffect(()=>{let e=X(e=>{zn.includes(e.key)&&(u.current=!0)},`handleKeyDown`),t=X(()=>u.current=!1,`handleKeyUp`);return document.addEventListener(`keydown`,e),document.addEventListener(`keyup`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`keyup`,t)}},[]),(0,Y.jsx)(Fe,{asChild:!0,...i,focusable:!s,active:o,children:(0,Y.jsx)(Pn,{...a,...r,ref:l,onKeyDown:Ee(r.onKeyDown,e=>{e.key===`Enter`&&e.preventDefault()}),onFocus:Ee(r.onFocus,()=>{u.current&&c.current?.click()})})})},`RadioGroupItemTrigger`)),Qn=J.forwardRef(X(function(e,t){let{__scopeRadioGroup:n,value:r,disabled:i,...a}=e;return(0,Y.jsx)(Xn,{__scopeRadioGroup:n,value:r,disabled:i,internal_do_not_use_render:({isFormControl:e})=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Zn,{...a,ref:t,__scopeRadioGroup:n}),e&&(0,Y.jsx)($n,{__scopeRadioGroup:n})]})})},`RadioGroupItem`)),$n=J.forwardRef(X(function(e,t){let{__scopeRadioGroup:n,...r}=e,i=Wn(n);return(0,Y.jsx)(In,{...i,...r,ref:t})},`RadioGroupItemBubbleInput`));function er(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(`移动端原生桥不可用。`))}function tr({className:e,...t}){return(0,Y.jsx)(zt,{"data-settings-card":!0,className:R(`rounded-none border-x-0 border-t border-b-0 border-stroke-soft bg-transparent px-0`,e),...t})}var nr=It,rr=Pt;function ir(e){return(0,Y.jsx)(Rt,{density:`compact`,...e})}function ar({className:e,...t}){return(0,Y.jsx)(`div`,{"data-settings-group":!0,className:R(`@container/card min-w-0 divide-y divide-stroke-soft border-y border-stroke-soft`,e),...t})}function or({label:e,help:t,htmlFor:n,labelId:r,helpId:i,children:a,className:o}){return(0,Y.jsxs)(`div`,{className:R(`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,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`label`,{id:r,htmlFor:n,className:`text-sm font-medium text-content`,children:e}),t&&(0,Y.jsx)(`p`,{id:i,className:`mt-0.5 text-xs text-content-muted`,children:t})]}),(0,Y.jsx)(`div`,{className:`min-w-0 @min-[480px]/card:max-w-[460px]`,children:a})]})}var sr=`0.6.11`,cr=`https://github.com/ling-kong-ran/pisper`,lr=`${cr}/blob/release/LICENSE`;function ur({href:e,icon:t,label:n,value:r,onClick:i}){return(0,Y.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,Y.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,Y.jsx)(t,{size:16,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block text-sm font-medium text-content`,children:n}),(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate font-mono text-xs text-content-muted`,children:r})]}),(0,Y.jsx)(F,{"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||sr,i=e=>{er(e,e.currentTarget.href)?.catch(()=>t(n(`config:aboutSettings.openLinkFailed`),`error`))};return(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full flex-col gap-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 rounded-[15px] shadow-raise`,children:(0,Y.jsx)(Vt,{size:56})}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`h2`,{className:`text-[length:calc(var(--ui-font-size)*10/7)] leading-[1.3] font-semibold tracking-[-.015em] text-content`,children:`Pisper`}),(0,Y.jsxs)(rr,{tone:`gray`,className:`font-mono`,children:[`v`,r]})]}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-content-muted`,children:n(`config:aboutSettings.description`)})]})]}),(0,Y.jsxs)(`section`,{"data-config-card":`about-project`,children:[(0,Y.jsx)(nr,{title:n(`config:aboutSettings.projectInformation`),className:`mb-3 text-[15px] leading-6 font-medium text-content`}),(0,Y.jsxs)(ar,{children:[(0,Y.jsx)(ur,{href:cr,icon:j,label:n(`config:aboutSettings.sourceCode`),value:`github.com/ling-kong-ran/pisper`,onClick:i}),(0,Y.jsx)(ur,{href:lr,icon:vn,label:n(`config:aboutSettings.license`),value:`MIT License`,onClick:i})]})]}),(0,Y.jsx)(tr,{className:`py-4`,"data-config-card":`about-support`,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 max-[540px]:flex-col max-[540px]:items-stretch`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(nr,{title:n(`config:aboutSettings.supportPisper`)}),(0,Y.jsx)(`p`,{className:`mt-0.5 max-w-[520px] text-xs leading-5 text-content-muted`,children:n(`config:aboutSettings.supportDescription`)})]}),(0,Y.jsx)(B,{asChild:!0,className:`max-[650px]:h-11 max-[540px]:w-full`,children:(0,Y.jsxs)(`a`,{href:cr,target:`_blank`,rel:`noopener noreferrer`,"data-web-preview":`external`,onClick:i,children:[(0,Y.jsx)(Sn,{size:15}),n(`config:aboutSettings.starOnGitHub`)]})})]})}),(0,Y.jsx)(`p`,{className:`text-center text-xs text-content-muted`,children:n(`config:aboutSettings.copyright`)})]})}function fr(e){window.dispatchEvent(new CustomEvent(`pisper:desktop-pet-changed`,{detail:e}))}function pr({notify:e,requestConfirm:t}){let{t:n}=l(),r=window.pisperDesktop,i=(0,J.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,J.useState)(null),[s,c]=(0,J.useState)(``),[u,d]=(0,J.useState)([]),[p,m]=(0,J.useState)(100),[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(``),y=(0,J.useCallback)(e=>{o(e),m(Math.round((e.opacity??1)*100))},[]),b=(0,J.useCallback)(async()=>{try{v(``),y(await i.getStatus())}catch(e){v(e instanceof Error?e.message:String(e))}},[y,i]),x=(0,J.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,J.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),fr(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),fr(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),fr(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),fr(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),fr(t),e(n(`config:desktopPetSettings.petRemoved`,{name:r.name}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(``)}}};return(0,Y.jsxs)(Y.Fragment,{children:[_&&(0,Y.jsx)(G,{children:_}),(0,Y.jsx)(W,{title:n(`config:desktopPetSettings.displayTitle`),"data-config-card":`desktop-pet-settings`,children:a?(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{icon:(0,Y.jsx)(un,{}),name:n(`config:desktopPetSettings.showOnDesktop`),description:a.selectedName?n(`config:desktopPetSettings.currentPet`,{name:a.selectedName}):n(`config:desktopPetSettings.installBeforeEnabling`),status:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[a.running&&(0,Y.jsx)(At,{status:`done`,className:`size-3.5`}),a.running?n(`config:desktopPetSettings.running`):n(`config:desktopPetSettings.stopped`)]}),actions:(0,Y.jsx)(Qe,{checked:a.enabled,disabled:!!h||!a.installed.length,onCheckedChange:e=>void S(e),"aria-label":n(`config:desktopPetSettings.showOnDesktop`)})}),(0,Y.jsx)(H,{icon:(0,Y.jsx)(ln,{}),name:n(`config:desktopPetSettings.opacity`),nameMeta:`${p}%`,actions:(0,Y.jsx)(Ze,{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,Y.jsx)(ht,{kind:`loading`,title:n(`config:desktopPetSettings.loading`)})}),(0,Y.jsxs)(W,{title:n(`config:desktopPetSettings.installTitle`),"data-config-card":`desktop-pet-install`,description:n(`config:desktopPetSettings.installDescription`),actions:(0,Y.jsxs)(B,{variant:`ghost`,size:`sm`,onClick:i.openCatalog,children:[(0,Y.jsx)(F,{}),n(`config:desktopPetSettings.browsePetdex`)]}),children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex gap-2`,children:[(0,Y.jsx)(V,{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,Y.jsxs)(B,{variant:`secondary`,className:`h-9 shrink-0 pointer-coarse:h-11 max-[650px]:h-11`,disabled:h===`search`,onClick:x,children:[h===`search`?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(pe,{}),n(`config:desktopPetSettings.search`)]})]}),u.length>0&&(0,Y.jsx)(U,{children:u.map(e=>{let t=a?.installed.some(t=>t.slug===e.slug);return(0,Y.jsx)(H,{"data-pet-catalog":e.slug,icon:(0,Y.jsx)(un,{}),name:e.displayName,nameMeta:e.slug,status:t?n(`config:desktopPetSettings.installed`):void 0,actions:(0,Y.jsxs)(B,{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,Y.jsx)(E,{}):(0,Y.jsx)(N,{}),n(t?`config:desktopPetSettings.use`:`config:desktopPetSettings.install`)]})},e.slug)})})]}),a&&a.installed.length>0&&(0,Y.jsx)(W,{title:n(`config:desktopPetSettings.installedTitle`),count:a.installed.length,"data-config-card":`desktop-pet-installed`,description:n(`config:desktopPetSettings.installedDescription`),children:(0,Y.jsx)(U,{children:a.installed.map(e=>{let t=e.slug===a.selectedSlug;return(0,Y.jsx)(H,{"data-pet-installed":e.slug,"data-selected":t||void 0,className:R(`relative`,t&&`after:absolute after:inset-y-3 after:-left-3 after:w-[3px] after:rounded-full after:bg-star`),icon:(0,Y.jsx)(un,{}),name:e.name,nameMeta:`${e.slug} · ${e.source===`pisper`?`Pisper`:`Petdex`}`,status:t?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,Y.jsx)(At,{status:`done`,className:`size-3.5`}),n(`config:desktopPetSettings.inUse`)]}):void 0,actions:(0,Y.jsxs)(Y.Fragment,{children:[!t&&(0,Y.jsx)(B,{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,Y.jsx)(B,{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,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(ve,{})})]})},`${e.source}:${e.slug}`)})})})]})}function Z(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 mr(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 hr,Q,gr,_r,vr=`__TAURI_TO_IPC_KEY__`;function yr(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}var br=class{constructor(e){hr.set(this,void 0),Q.set(this,0),gr.set(this,[]),_r.set(this,void 0),mr(this,hr,e||(()=>{}),`f`),this.id=yr(e=>{let t=e.index;if(`end`in e){t==Z(this,Q,`f`)?this.cleanupCallback():mr(this,_r,t,`f`);return}let n=e.message;if(t==Z(this,Q,`f`)){for(Z(this,hr,`f`).call(this,n),mr(this,Q,Z(this,Q,`f`)+1,`f`);Z(this,Q,`f`)in Z(this,gr,`f`);){let e=Z(this,gr,`f`)[Z(this,Q,`f`)];Z(this,hr,`f`).call(this,e),delete Z(this,gr,`f`)[Z(this,Q,`f`)],mr(this,Q,Z(this,Q,`f`)+1,`f`)}Z(this,Q,`f`)===Z(this,_r,`f`)&&this.cleanupCallback()}else Z(this,gr,`f`)[t]=n})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){mr(this,hr,e,`f`)}get onmessage(){return Z(this,hr,`f`)}[(hr=new WeakMap,Q=new WeakMap,gr=new WeakMap,_r=new WeakMap,vr)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[vr]()}};function xr(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function Sr(e,t){return xr(`plugin:barcode-scanner|${e}`,t)}function Cr(e){return e instanceof Error?e.message:String(e)}function wr(e){return/cancel(?:led|ed)/i.test(Cr(e))}function Tr(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function Er(e){return Array.isArray(e)?new TextDecoder().decode(Uint8Array.from(e)):``}function Dr(e){if(!e.isActive||!e.port)return null;let t=Er(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=Er(e.txt.name)||e.name||`Pisper Desktop`,a=`https://${r}:${e.port}`;return{id:`${e.fullName}:${a}`,name:i,url:a,fingerprint:t}}function Or(e){return new Promise(t=>window.setTimeout(t,e))}function kr({open:e,onOpenChange:t}){let{t:n}=l(),r=Et(e),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(!1),[c,u]=(0,J.useState)([]),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(``),[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(``),y=(0,J.useRef)(!1),x=(0,J.useRef)(!1),S=(0,J.useRef)(!1),C=(0,J.useRef)(0),w=(0,J.useRef)(``),T=(0,J.useCallback)(e=>{y.current=e,s(e)},[]),E=(0,J.useCallback)(async()=>{x.current=!0,y.current&&await Sr(`cancel`).catch(()=>void 0),T(!1),a(null)},[T]);(0,J.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,J.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,J.useCallback)(async()=>{let e=++C.current;f(!0),m(``),u([]);let t=new br;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=Dr(t.service);r&&u(e=>[...e.filter(e=>e.fingerprint!==r.fingerprint),r])};let r=null;try{await xr(`mobile_ensure_local_network_permission`),r=(await xr(`plugin:dns-sd|browse_start`,{options:{service:{type:`pisper`,protocol:`tcp`,domain:`local`},timeoutMs:4e3},channel:t})).browseId,await Or(4300)}catch(t){C.current===e&&m(Cr(t).includes(`local_network_permission_denied`)?n(`config:mobileServer.localNetworkDenied`):n(`config:mobileServer.discoveryFailed`))}finally{r!==null&&await xr(`plugin:dns-sd|browse_stop`,{browseId:r}).catch(()=>void 0),C.current===e&&f(!1)}},[n]);(0,J.useEffect)(()=>{if(!(!e||o))return O(),()=>{C.current+=1}},[O,e,o]);let k=(0,J.useCallback)(async()=>{let e=w.current;w.current=``,e&&await xr(`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 xr(`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(Cr(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 Sr(`check_permissions`);if(e.camera!==`granted`&&(e=await Sr(`request_permissions`)),e.camera!==`granted`)throw Error(n(`config:mobileServer.cameraDenied`));if(x.current||(T(!0),await Tr(),x.current))return;let t=await Sr(`scan`,{windowed:!0,formats:[]});if(!t.content)throw Error(n(`config:mobileServer.scanFailed`));S.current=!0,D(await xr(`mobile_pair`,{payloadJson:t.content,deviceName:null}))}catch(e){!x.current&&!wr(e)&&v(Cr(e))}finally{T(!1),a(null),x.current=!1}};return(0,Y.jsx)(Ct,{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,Y.jsx)(yt,{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,Y.jsxs)(`div`,{className:`flex h-dvh w-screen flex-col overflow-hidden`,children:[(0,Y.jsxs)(St,{className:`sr-only`,children:[(0,Y.jsx)(bt,{children:n(`config:mobileServer.scanTitle`)}),(0,Y.jsx)(vt,{children:n(`config:mobileServer.scanHint`)})]}),(0,Y.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,Y.jsxs)(B,{variant:`ghost`,className:`h-10 bg-black/40 px-3 text-white hover:bg-black/70 hover:text-white`,onClick:()=>void E(),children:[(0,Y.jsx)(b,{}),n(`config:mobileServer.cancelScan`)]}),(0,Y.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium`,children:n(`config:mobileServer.scanTitle`)}),(0,Y.jsx)(`div`,{className:`w-[88px]`,"aria-hidden":`true`})]}),(0,Y.jsx)(`main`,{className:`grid min-h-0 flex-1 place-items-center p-6`,children:(0,Y.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,Y.jsx)(yn,{className:`absolute top-1/2 left-1/2 size-10 -translate-x-1/2 -translate-y-1/2 text-white/75`})})}),(0,Y.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,Y.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-white/90`,children:n(`config:mobileServer.scanHint`)}),(0,Y.jsx)(B,{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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(St,{children:[(0,Y.jsx)(bt,{children:n(`config:mobileServer.addServer`)}),(0,Y.jsx)(vt,{children:n(`config:mobileServer.discoverDescription`)})]}),(0,Y.jsxs)(`section`,{className:`grid gap-2`,"aria-live":`polite`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Y.jsx)(_n,{className:`size-4`}),n(`config:mobileServer.nearby`)]}),(0,Y.jsx)(B,{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,Y.jsx)(ue,{className:d?`animate-spin`:void 0})})]}),c.length?(0,Y.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,Y.jsxs)(`li`,{className:`flex min-h-12 items-center justify-between gap-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(me,{className:`size-4 flex-none text-muted-foreground`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`truncate text-sm`,children:e.name}),(0,Y.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.url})]})]}),(0,Y.jsxs)(B,{size:`sm`,className:`pointer-coarse:min-h-11`,disabled:i!==null,onClick:()=>void A(e),children:[t?(0,Y.jsx)(I,{className:`animate-spin`}):null,n(`config:mobileServer.requestConnect`)]})]},e.id)})}):(0,Y.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:n(d?`config:mobileServer.discovering`:`config:mobileServer.noNearby`)}),p?(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs leading-relaxed text-content-secondary`,children:p}):null,h?(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-[var(--r-md)] bg-surface-subtle px-3 py-2`,children:[(0,Y.jsx)(`p`,{role:`status`,className:`text-xs leading-relaxed`,children:h}),(0,Y.jsx)(B,{size:`sm`,variant:`outline`,className:`pointer-coarse:min-h-11`,onClick:()=>void k(),children:n(`config:mobileServer.cancelRequest`)})]}):null]}),(0,Y.jsxs)(`div`,{className:`relative py-1`,children:[(0,Y.jsx)(Xe,{}),(0,Y.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,Y.jsxs)(B,{className:`w-full pointer-coarse:min-h-11`,disabled:i!==null,onClick:()=>void j(),children:[i===`scan`?(0,Y.jsx)(I,{className:`animate-spin`}):(0,Y.jsx)(gn,{}),n(`config:mobileServer.scan`)]}),_?(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs leading-relaxed text-content-secondary`,children:_}):null]})})})}function Ar(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function jr({requestConfirm:e}){let{t}=l(),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)(``),[c,u]=(0,J.useState)(!1),d=(0,J.useCallback)(async()=>{try{r(await Ar(`mobile_state`)),a(``)}catch{a(t(`config:mobileServer.loadFailed`))}},[t]);(0,J.useEffect)(()=>{d()},[d]);let f=async(e,t,n=``)=>{s(n||e);try{r(await Ar(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 Ar(`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,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(At,{status:`done`,className:`size-3.5`}):(0,Y.jsx)(k,{className:`size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:v}),n?.activeTransport?(0,Y.jsx)(`span`,{className:`flex-none font-mono text-xs text-content-muted`,children:y(n.activeTransport)}):null]}),(0,Y.jsx)(kr,{open:c,onOpenChange:u}),i?(0,Y.jsx)(G,{className:`mt-3`,children:i}):null,(0,Y.jsx)(W,{title:t(`config:mobileServer.localTitle`),"data-config-card":`mobile-server-local`,children:(0,Y.jsx)(U,{children:(0,Y.jsx)(H,{icon:(0,Y.jsx)(xn,{}),name:t(`config:mobileServer.localTitle`),description:t(`config:mobileServer.localDescription`),status:h?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,Y.jsx)(At,{status:`done`,className:`size-3.5`}),t(`config:mobileServer.currentLocal`)]}):void 0,actions:h?void 0:(0,Y.jsx)(B,{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 Ar(`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,Y.jsx)(W,{title:t(`config:mobileServer.title`),count:n?.servers?.length??0,"data-config-card":`mobile-server-main`,description:t(`config:mobileServer.description`),actions:(0,Y.jsxs)(B,{size:`sm`,onClick:()=>u(!0),children:[(0,Y.jsx)(le,{}),t(`config:mobileServer.addServer`)]}),children:n?.servers?.length?(0,Y.jsx)(U,{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,Y.jsx)(H,{"data-mobile-server":e.id,icon:(0,Y.jsx)(me,{}),name:e.name,nameMeta:t(i&&a?`config:mobileServer.transportLanP2p`:a?`config:mobileServer.transportP2p`:`config:mobileServer.transportLan`),description:(0,Y.jsx)(`span`,{className:`font-mono`,children:s}),status:r?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,Y.jsx)(At,{status:`done`,className:`size-3.5`}),n.activeTransport?t(`config:mobileServer.activeTransport`,{transport:y(n.activeTransport)}):t(`config:mobileServer.current`)]}):void 0,actions:(0,Y.jsxs)(Y.Fragment,{children:[r?null:(0,Y.jsx)(B,{size:`sm`,variant:`ghost`,disabled:o===e.id,onClick:()=>void m(e.id),children:t(`config:mobileServer.connect`)}),(0,Y.jsx)(B,{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,Y.jsx)(ve,{})})]})},e.id)})}):(0,Y.jsx)(_t,{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 Mr({notify:e}){let{t,language:n}=l(),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)([]),[u,d]=(0,J.useState)([]),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(``),[y,b]=(0,J.useState)(``),[x,S]=(0,J.useState)(!1),[C,w]=(0,J.useState)(``),T=(0,J.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,J.useEffect)(()=>{T()},[T]),(0,J.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(``)}},N=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,Y.jsx)(ht,{kind:`error`,title:t(`config:remoteAccess.loadFailed`),action:(0,Y.jsxs)(B,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void T(),children:[(0,Y.jsx)(ue,{}),t(`config:remoteAccess.refresh`)]})});if(!r)return(0,Y.jsx)(ht,{kind:`loading`,title:t(`config:remoteAccess.loading`)});let P=r.error?`failed`:r.listening?`on`:r.enabled?`starting`:`off`,F=a!==null&&!a.busy&&[`needs_authorization`,`cancelled`,`error`,`cleanup_pending`].includes(a.state);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ct,{open:h&&p!==null,onOpenChange:g,children:(0,Y.jsxs)(yt,{className:`sm:max-w-md`,children:[(0,Y.jsxs)(St,{children:[(0,Y.jsx)(bt,{children:t(`config:remoteAccess.pairingQrTitle`)}),(0,Y.jsx)(vt,{children:t(`config:remoteAccess.scanQrDescription`)})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-2`,"aria-live":`polite`,children:[p?.qrDataUrl?(0,Y.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,Y.jsx)(`p`,{role:`alert`,className:`text-center text-xs leading-relaxed text-content-secondary`,children:_}):null,p?(0,Y.jsxs)(`div`,{className:`text-center`,children:[(0,Y.jsx)(`div`,{className:`font-mono text-[20px] font-medium tracking-[0.2em] text-content`,children:p.code}),(0,Y.jsx)(`div`,{className:`mt-1 text-xs text-content-muted tabular-nums`,children:t(`config:remoteAccess.codeExpiresAt`,{time:mt(p.expiresAt,n)})})]}):null]}),p?.connectionInfo&&(0,Y.jsxs)(`details`,{className:`min-w-0 rounded-md border border-stroke px-3 py-2 text-sm`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer text-content-secondary`,children:t(`remote-workspace:manualConnection`)}),(0,Y.jsxs)(`div`,{className:`mt-2 space-y-2 text-xs text-content-muted`,children:[(0,Y.jsx)(`div`,{children:t(`remote-workspace:serverAddress`)}),p.connectionInfo.endpoints.map(e=>(0,Y.jsx)(`code`,{className:`block font-mono break-all text-content select-all`,children:e.url},e.url)),(0,Y.jsx)(`div`,{children:t(`remote-workspace:fingerprint`)}),(0,Y.jsx)(`code`,{className:`block font-mono break-all text-content select-all`,children:p.connectionInfo.fingerprint})]})]}),(0,Y.jsx)(xt,{children:(0,Y.jsxs)(B,{disabled:x,onClick:()=>void j(),children:[x?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(ue,{}),t(x?`config:remoteAccess.generatingQr`:`config:remoteAccess.regenerate`)]})})]})}),C&&(0,Y.jsx)(G,{children:C}),(0,Y.jsx)(W,{title:t(`config:remoteAccess.thisComputer`),"data-config-card":`remote-access-main`,children:(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{icon:(0,Y.jsx)(oe,{}),name:t(`config:remoteAccess.allowConnections`),description:t(`config:remoteAccess.description`),status:(0,Y.jsx)(Nr,{attention:P===`failed`,glyph:P===`on`?`done`:P===`starting`?`run`:null,children:t(P===`failed`?`config:remoteAccess.stateFailed`:P===`on`?`config:remoteAccess.stateListening`:P===`starting`?`config:remoteAccess.stateStarting`:`config:remoteAccess.stateOff`)}),actions:(0,Y.jsx)(Qe,{checked:r.enabled,disabled:x,onCheckedChange:e=>void D(e),"aria-label":t(`config:remoteAccess.title`)}),detail:r.error?(0,Y.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,Y.jsx)(H,{"aria-live":`polite`,icon:(0,Y.jsx)(he,{}),name:t(`config:remoteAccess.firewallTitle`),description:a.busy?t(`config:remoteAccess.firewallWorking`):k[a.state],status:a.busy?(0,Y.jsx)(Nr,{glyph:`run`,children:t(`config:remoteAccess.firewallChecking`)}):F?(0,Y.jsx)(Nr,{attention:!0,children:t(`config:remoteAccess.firewallNeedsYou`)}):void 0,actions:r.enabled||a.state===`cleanup_pending`?(0,Y.jsxs)(B,{size:`sm`,variant:`secondary`,disabled:x||a.busy,onClick:()=>void O(),children:[x||a.busy?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(ue,{}),r.enabled?t(`config:remoteAccess.firewallRetry`):t(`config:remoteAccess.firewallRetryCleanup`)]}):void 0,detail:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-xs leading-relaxed text-content-muted`,children:[a.reason&&A[a.reason]?(0,Y.jsx)(`p`,{className:`text-content-secondary`,children:A[a.reason]}):null,r.enabled?(0,Y.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,Y.jsx)(`p`,{children:t(`config:remoteAccess.firewallReachability`)}),a.checkedAt?(0,Y.jsx)(`p`,{className:`tabular-nums`,children:t(`config:remoteAccess.firewallCheckedAt`,{time:mt(a.checkedAt,n)})}):null]})}):null]})}),r.listening&&u.length?(0,Y.jsx)(W,{"aria-live":`polite`,title:t(`config:remoteAccess.pendingApprovals`),count:u.length,meta:(0,Y.jsx)(`span`,{className:`font-medium text-st-attn`,children:t(`config:remoteAccess.waitingForYou`)}),description:t(`config:remoteAccess.pendingApprovalsDescription`),children:(0,Y.jsx)(U,{children:u.map(e=>(0,Y.jsx)(H,{"data-pairing-request":e.id,icon:(0,Y.jsx)(xn,{}),name:e.deviceName,description:(0,Y.jsx)(`span`,{className:`font-mono`,children:t(`config:remoteAccess.requestSource`,{ip:e.ip})}),meta:t(`config:remoteAccess.requestedAt`,{time:mt(e.requestedAt,n)}),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(B,{size:`sm`,variant:`ghost`,disabled:y===e.id,onClick:()=>void M(e,!1),children:[(0,Y.jsx)(xe,{}),t(`config:remoteAccess.reject`)]}),(0,Y.jsxs)(B,{size:`sm`,disabled:y===e.id,onClick:()=>void M(e,!0),children:[y===e.id?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(E,{}),t(`config:remoteAccess.approve`)]})]})},e.id))})}):null,r.listening?(0,Y.jsx)(W,{title:t(`config:remoteAccess.pairing`),"data-config-card":`remote-access-pairing`,children:(0,Y.jsx)(U,{children:(0,Y.jsx)(H,{icon:(0,Y.jsx)(gn,{}),name:t(`config:remoteAccess.pairWithPhone`),description:t(`config:remoteAccess.pairingDescription`),actions:(0,Y.jsxs)(B,{size:`sm`,disabled:x,onClick:()=>void j(),children:[x?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(gn,{}),t(x?`config:remoteAccess.generatingQr`:`config:remoteAccess.generateQr`)]}),detail:_&&!h?(0,Y.jsx)(`p`,{className:`text-xs leading-relaxed text-content-secondary`,"aria-live":`polite`,children:_}):void 0})})}):null,(0,Y.jsx)(W,{title:t(`config:remoteAccess.devices`),count:s.length,"data-config-card":`remote-access-devices`,actions:(0,Y.jsx)(B,{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,Y.jsx)(ue,{})}),children:s.length===0?(0,Y.jsx)(_t,{compact:!0,title:t(`config:remoteAccess.noDevices`)}):(0,Y.jsx)(U,{children:s.map(e=>(0,Y.jsx)(H,{icon:(0,Y.jsx)(xn,{}),name:e.name,nameMeta:e.current?t(`config:remoteAccess.currentDevice`):void 0,description:t(`config:remoteAccess.lastSeen`,{time:mt(e.lastSeenAt,n)}),actions:(0,Y.jsx)(B,{size:`sm`,variant:`ghost`,className:`hover:bg-danger-soft hover:text-danger`,"aria-label":`${t(`config:remoteAccess.revoke`)}: ${e.name}`,onClick:()=>void N(e),children:t(`config:remoteAccess.revoke`)})},e.id))})})]})}function Nr({attention:e=!1,glyph:t=null,children:n}){let r=e?`attention`:t;return(0,Y.jsxs)(`span`,{className:R(`inline-flex min-w-0 items-center gap-1.5 whitespace-nowrap`,e?`font-medium text-st-attn`:`text-content-secondary`),children:[r&&(0,Y.jsx)(At,{status:r,className:`size-3.5`}),n]})}function Pr({requestConfirm:e}){let{t}=l(),n=window.pisperDesktop?.remoteWorkspaces,[r,i]=(0,J.useState)([]),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(``),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(``),v=(0,J.useCallback)(async()=>{n&&i(await n.list())},[n]);(0,J.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,Y.jsx)(W,{title:t(`config:remoteWorkspace.title`),"data-config-card":`remote-workspaces`,children:(0,Y.jsx)(U,{children:(0,Y.jsx)(H,{icon:(0,Y.jsx)(me,{}),name:t(`remote-workspace:activeTitle`),description:t(`remote-workspace:activeDescription`),detail:(0,Y.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:t(`remote-workspace:isolation`)})})})}):n?(0,Y.jsxs)(W,{title:t(`config:remoteWorkspace.title`),count:r.length,"data-config-card":`remote-workspaces`,description:t(`remote-workspace:description`),actions:(0,Y.jsx)(B,{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,Y.jsx)(ue,{className:`size-3.5`})}),children:[r.length>0&&(0,Y.jsx)(U,{children:r.map(r=>(0,Y.jsx)(H,{icon:(0,Y.jsx)(me,{}),name:r.name,description:(0,Y.jsx)(`span`,{className:`font-mono`,children:r.address}),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(B,{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,Y.jsx)(S,{className:`size-3.5`})]}),(0,Y.jsx)(B,{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,Y.jsx)(ve,{className:`size-3.5`})})]})},r.id))}),(0,Y.jsxs)(`div`,{className:`@container/card mt-3 rounded-[var(--r-md)] border border-stroke px-3 pt-2 pb-1`,children:[(0,Y.jsx)(`p`,{className:`py-1.5 text-xs leading-relaxed text-content-secondary`,children:t(`remote-workspace:instructions`)}),(0,Y.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,Y.jsx)(or,{label:t(`remote-workspace:name`),htmlFor:`remote-workspace-name`,children:(0,Y.jsx)(V,{id:`remote-workspace-name`,value:a,maxLength:160,disabled:m,placeholder:`Linux`,onChange:e=>o(e.target.value)})}),(0,Y.jsx)(or,{label:t(`remote-workspace:address`),htmlFor:`remote-workspace-address`,children:(0,Y.jsx)(V,{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,Y.jsx)(or,{label:t(`remote-workspace:fingerprint`),htmlFor:`remote-workspace-fingerprint`,children:(0,Y.jsx)(V,{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,Y.jsx)(or,{label:t(`remote-workspace:code`),htmlFor:`remote-workspace-code`,children:(0,Y.jsx)(V,{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,Y.jsx)(`div`,{className:`flex justify-end py-3`,children:(0,Y.jsxs)(B,{type:`submit`,className:`max-[650px]:h-11`,disabled:m,children:[m?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(S,{className:`size-3.5`}),t(`remote-workspace:pair`)]})})]})]}),g&&(0,Y.jsx)(G,{className:`mt-3`,children:g}),(0,Y.jsx)(`p`,{className:`mt-3 text-xs leading-relaxed text-content-muted`,children:t(`remote-workspace:isolation`)})]}):null}function Fr({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,Y.jsx)(pr,{notify:t,requestConfirm:n}):e===`mobile-server`?(0,Y.jsx)(jr,{requestConfirm:n}):(0,Y.jsxs)(Y.Fragment,{children:[!window.__PISPER_REMOTE_WORKSPACE__&&(0,Y.jsx)(Mr,{notify:t}),(0,Y.jsx)(Pr,{requestConfirm:n})]}):(0,Y.jsx)(Ir,{section:e,support:s}),(0,Y.jsx)(Dt,{"data-device-feature":e,title:c,description:u,back:r&&{label:i(`navigation:sidebar.features`),ariaLabel:i(`navigation:shell.backToFeaturesLabel`),onBack:r},children:(0,Y.jsx)(`div`,{"data-config-card":nt,className:`min-w-0`,children:d})})}function Ir({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,Y.jsx)(W,{title:n(`config:deviceFeature.unavailableTitle`),"data-device-unsupported":!0,children:(0,Y.jsx)(U,{children:(0,Y.jsx)(H,{icon:e===`desktop-pet`?(0,Y.jsx)(w,{}):(0,Y.jsx)(oe,{}),name:r,description:i,status:n(`config:deviceFeature.unavailable`),actions:(0,Y.jsx)(Qe,{checked:!1,disabled:!0,"aria-label":r})})})})}function Lr({title:e,description:t,action:n,children:r,className:i,...a}){let o=(0,J.useId)();return(0,Y.jsxs)(`section`,{"aria-labelledby":o,className:R(`min-w-0`,i),...a,children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h2`,{id:o,className:`text-[15px] leading-6 font-medium text-content`,children:e}),t&&(0,Y.jsx)(`p`,{className:`mt-0.5 text-[13px] text-content-muted`,children:t})]}),n]}),(0,Y.jsx)(`div`,{className:`divide-y divide-stroke-soft`,children:r})]})}function Rr({title:e,description:t,control:n,nested:r,children:i,className:a,...o}){return(0,Y.jsxs)(`div`,{className:R(`min-w-0 py-3`,r&&`pl-4`,a),...o,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-6 gap-y-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 basis-40`,children:[(0,Y.jsx)(`div`,{className:`text-[13px] font-medium text-content`,children:e}),t&&(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-content-muted`,children:t})]}),n&&(0,Y.jsx)(`div`,{className:`max-w-full shrink-0`,children:n})]}),i]})}function zr({className:e,...t}){return(0,Y.jsx)(qn,{"data-slot":`radio-group`,className:R(`grid w-full gap-2`,e),...t})}function Br({className:e,...t}){return(0,Y.jsx)(Qn,{"data-slot":`radio-group-option`,className:R(`disabled:pointer-events-none disabled:opacity-50`,e),...t})}function Vr(e,t){return t(e===`en-US`?`config:languageSettings.english`:`config:languageSettings.simplifiedChinese`)}function Hr({notify:e}){let{language:t,setLanguage:n,t:r}=l(),i=(0,J.useId)(),a=(0,J.useId)(),o=r=>{r!==t&&(n(r),e(s(r===`en-US`?`config:languageSettings.displayLanguageChangedToEnglish`:`config:languageSettings.displayLanguageChangedToSimplifiedChinese`,r)))};return(0,Y.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,Y.jsxs)(`div`,{className:`min-w-0 flex-1 basis-40`,children:[(0,Y.jsx)(`h2`,{id:i,className:`text-sm font-medium text-content`,children:r(`config:languageSettings.displayLanguage`)}),(0,Y.jsx)(`p`,{id:a,className:`mt-0.5 text-xs leading-relaxed text-content-muted`,children:r(`config:languageSettings.interfaceOnlyHint`)})]}),(0,Y.jsxs)(Ye,{value:t,onValueChange:e=>{let t=c.find(t=>t.value===e);t&&o(t.value)},children:[(0,Y.jsx)(Ke,{"aria-labelledby":i,"aria-describedby":a,className:`min-w-36 shrink-0`,children:(0,Y.jsx)(Ge,{})}),(0,Y.jsx)(qe,{align:`end`,children:c.map(e=>(0,Y.jsx)(Je,{value:e.value,children:Vr(e.value,r)},e.value))})]})]})}function Ur({role:e,label:t,value:n,onCommit:r}){let{t:i}=l(),a=(0,J.useId)(),[o,s]=(0,J.useState)(String(n)),c=(0,J.useRef)(o),u=(0,J.useRef)(n),d=e===`ui`?Jt:Xt;(0,J.useEffect)(()=>{u.current=n,c.current=String(n),s(String(n))},[n]);let f=o!==String(n)&&Kt(o,e)===null,p=()=>{let t=Kt(c.current,e);t!==null&&t!==u.current&&(r(t),u.current=t)};return(0,Y.jsxs)(`div`,{className:`flex max-w-full flex-col items-end gap-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(V,{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,Y.jsx)(`span`,{className:`text-sm text-content-muted`,children:`px`})]}),f&&(0,Y.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 Wr({label:e,options:t,value:n,onChange:r}){return(0,Y.jsx)(zr,{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,Y.jsx)(Br,{type:`button`,className:R(`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 Gr={neutral:`var(--primary)`,blue:`#3d4bef`,teal:`#0f766e`,violet:`#6d4ad6`,coral:`#c93a48`,custom:`#3d4bef`};function Kr(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 qr({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 Jr({value:e,onCommit:t}){let{t:n}=l(),[r,i]=(0,J.useState)(e),a=(0,J.useRef)(e),[o,s]=(0,J.useState)(()=>Kr(e)),c=(0,J.useId)(),u=e=>{a.current=e,i(e)};(0,J.useEffect)(()=>{a.current=e,i(e),s(Kr(e))},[e]);let d=e=>{s(e),u(qr(e))},f=()=>{let n=Qt(a.current);n&&n!==Qt(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()&&!Qt(r);return(0,Y.jsxs)(We,{onOpenChange:t=>{t||(f(),Qt(a.current)||(u(e),s(Kr(e))))},children:[(0,Y.jsx)(He,{asChild:!0,children:(0,Y.jsxs)(B,{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,Y.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 shrink-0 rounded-full border border-stroke-strong`,style:{backgroundColor:e}}),(0,Y.jsx)(`span`,{className:`font-mono`,children:e})]})}),(0,Y.jsxs)(Ue,{align:`end`,sideOffset:8,className:`w-auto rounded-xl p-3`,children:[(0,Y.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(Kr(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,Y.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,Y.jsx)(Ze,{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,Y.jsx)(V,{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=Qt(e.target.value);t&&s(Kr(t))},onBlur:f,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f())}}),(0,Y.jsx)(`p`,{id:c,className:`max-w-34 text-xs text-muted-foreground`,children:n(m?`config:interfaceSettings.invalidAccentColor`:`config:interfaceSettings.colorSpectrumHint`)})]})]})}function Yr({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}=Gt(),w=v(e=>e.pinned),T=v(e=>e.setPinned),[E,O]=(0,J.useState)(t),k=(0,J.useId)(),A=(0,J.useId)();(0,J.useEffect)(()=>{t&&O(!0)},[t,n]);let j=i!==Wt.theme||a!==Wt.density||o!==Wt.accent||s!==Wt.customAccent||c!==Wt.uiFontSize||u!==Wt.codeFontSize||d!==Wt.radius||f!==Wt.motion,M=t=>n=>{t(n),e(r(`config:interfaceSettings.preferencesUpdated`))},N=[{value:`system`,label:r(`config:interfaceSettings.followSystem`),description:r(`config:interfaceSettings.followSystemDescription`),icon:mn},{value:`light`,label:r(`config:interfaceSettings.light`),description:r(`config:interfaceSettings.lightDescription`),icon:Cn},{value:`dark`,label:r(`config:interfaceSettings.dark`),description:r(`config:interfaceSettings.darkDescription`),icon:hn}],P=[{value:`comfortable`,label:r(`config:interfaceSettings.comfortable`),description:r(`config:interfaceSettings.comfortableDescription`),icon:Tn},{value:`compact`,label:r(`config:interfaceSettings.compact`),description:r(`config:interfaceSettings.compactDescription`),icon:fn}],F=[{value:`system`,label:r(`config:interfaceSettings.motionSystem`),description:r(`config:interfaceSettings.motionSystemDescription`),icon:mn},{value:`full`,label:r(`config:interfaceSettings.motionFull`),description:r(`config:interfaceSettings.motionFullDescription`),icon:ge},{value:`reduced`,label:r(`config:interfaceSettings.motionReduced`),description:r(`config:interfaceSettings.motionReducedDescription`),icon:_}],ee=[{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`)}],te=[{value:`sharp`,label:r(`config:interfaceSettings.sharp`)},{value:`default`,label:r(`config:interfaceSettings.standard`)},{value:`soft`,label:r(`config:interfaceSettings.soft`)}];return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Y.jsx)(Lr,{title:r(`config:interfaceSettings.visualStyle`),description:r(`config:interfaceSettings.appearanceDescription`),"data-config-card":`interface-appearance`,action:(0,Y.jsxs)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`pointer-coarse:h-11`,disabled:!j,onClick:()=>{C(),e(r(`config:interfaceSettings.defaultsRestored`))},children:[(0,Y.jsx)(fe,{size:14}),r(`config:interfaceSettings.restoreDefaults`)]}),children:(0,Y.jsxs)(ar,{children:[(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.colorMode`),control:(0,Y.jsx)(`div`,{role:`radiogroup`,"aria-label":r(`config:interfaceSettings.colorMode`),className:`grid w-68 max-w-full grid-cols-3 gap-4`,children:N.map(e=>(0,Y.jsxs)(`label`,{className:`group flex min-w-0 cursor-pointer flex-col items-center gap-2 text-xs text-content-muted`,children:[(0,Y.jsx)(`input`,{className:`peer sr-only`,type:`radio`,name:A,value:e.value,checked:i===e.value,onChange:()=>M(p)(e.value)}),(0,Y.jsxs)(`span`,{"aria-hidden":`true`,className:R(`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,Y.jsxs)(`span`,{className:`absolute inset-2 rounded border border-(--preview-light-line) bg-(--preview-light-bg)`,children:[(0,Y.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-1/4 border-r border-(--preview-light-line) bg-(--preview-light-side)`}),(0,Y.jsx)(`span`,{className:`absolute top-3 right-1 h-0.5 w-1/2 rounded bg-(--preview-light-line)`}),(0,Y.jsx)(`span`,{className:`absolute top-5 right-2 h-0.5 w-1/3 rounded bg-(--preview-light-line)`})]}),e.value!==`light`&&(0,Y.jsxs)(`span`,{className:R(`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,Y.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-1/4 border-r border-(--preview-dark-line) bg-(--preview-dark-side)`}),(0,Y.jsx)(`span`,{className:`absolute top-3 right-1 h-0.5 w-1/2 rounded bg-(--preview-dark-line)`}),(0,Y.jsx)(`span`,{className:`absolute top-5 right-2 h-0.5 w-1/3 rounded bg-(--preview-dark-line)`})]})]}),(0,Y.jsx)(`span`,{className:R(i===e.value&&`font-medium text-content`),children:e.label})]},e.value))})}),(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.accentColor`),description:r(`config:interfaceSettings.accentDescription`),control:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Y.jsxs)(Ye,{value:o,onValueChange:e=>{let t=ee.find(t=>t.value===e);t&&M(h)(t.value)},children:[(0,Y.jsx)(Ke,{"aria-label":r(`config:interfaceSettings.accentColor`),className:`min-w-36`,children:(0,Y.jsx)(Ge,{})}),(0,Y.jsx)(qe,{align:`end`,children:ee.map(e=>(0,Y.jsxs)(Je,{value:e.value,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 rounded-full border border-stroke-strong`,style:{backgroundColor:e.value===`custom`?s:Gr[e.value]}}),e.label]},e.value))})]}),o===`custom`&&(0,Y.jsx)(Jr,{value:Qt(s)||Wt.customAccent,onCommit:M(g)})]})})]})}),(0,Y.jsxs)(je,{open:E,onOpenChange:O,children:[(0,Y.jsx)(Ae,{asChild:!0,children:(0,Y.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,Y.jsx)(D,{size:16,"aria-hidden":`true`,className:R(`text-content-muted transition-transform`,!E&&`-rotate-90`)}),r(`config:interfaceSettings.advanced`)]})}),(0,Y.jsx)(ke,{id:k,children:(0,Y.jsxs)(ar,{className:`mt-3`,children:[(0,Y.jsxs)(`div`,{className:`divide-y divide-stroke-soft`,"data-config-card":`interface-style`,children:[(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.uiFontSize`),description:r(`config:interfaceSettings.numericFontHint`),control:(0,Y.jsx)(Ur,{role:`ui`,label:r(`config:interfaceSettings.uiFontSize`),value:c,onCommit:M(y)})}),(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.codeFontSize`),control:(0,Y.jsx)(Ur,{role:`code`,label:r(`config:interfaceSettings.codeFontSize`),value:u,onCommit:M(b)})}),(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.cornerStyle`),control:(0,Y.jsx)(Wr,{label:r(`config:interfaceSettings.cornerStyle`),options:te,value:d,onChange:M(x)})})]}),(0,Y.jsxs)(`div`,{className:`divide-y divide-stroke-soft`,"data-config-card":`interface-motion`,children:[(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.interfaceDensity`),control:(0,Y.jsx)(Wr,{label:r(`config:interfaceSettings.interfaceDensity`),options:P,value:a,onChange:M(m)})}),(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.pinInspector`),description:r(`config:interfaceSettings.pinInspectorDescription`),control:(0,Y.jsx)(Qe,{checked:w,onCheckedChange:M(T),"aria-label":r(`config:interfaceSettings.pinInspector`),"data-setting":`pin-inspector`})}),(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.motion`),control:(0,Y.jsx)(Wr,{label:r(`config:interfaceSettings.motion`),options:F,value:f,onChange:M(S)})}),(0,Y.jsx)(Rr,{title:r(`config:interfaceSettings.automaticByTime`),description:r(`config:interfaceSettings.automaticByTimeDescription`),control:(0,Y.jsx)(Qe,{checked:i===`scheduled`,onCheckedChange:e=>M(p)(e?`scheduled`:`system`),"aria-label":r(`config:interfaceSettings.automaticByTime`)})})]})]})})]}),(0,Y.jsx)(Hr,{notify:e})]})}function Xr({requestConfirm:e}){let{t}=l(),n=it(e=>e.bindings),r=it(e=>e.boardBindings),i=it(e=>e.setBinding),a=it(e=>e.setBoardBinding),o=it(e=>e.resetBindings),[s,c]=(0,J.useState)(null),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(!1),m=$t(),h=m.actions,g=m.boardActions,_=(e,n)=>{p(!1);let i=lt(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=st(n,e,r);if(a){d({action:e,message:t(`config:shortcuts.conflict`,{action:h[a]})});return}try{rt({...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=ct.includes(n),i=r?dt(e.nativeEvent):ut(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=ot.some(e=>n[e]!==at[e])||ct.some(e=>r[e]!==pt[e]),S=e=>{let i=ct.includes(e),a=i?g[e]:h[e],o=i?r[e]:n[e],l=i?pt[e]:at[e],f=t=>i?_(e,t):v(e,t);return(0,Y.jsxs)(`div`,{className:`py-2.5`,"data-shortcut-action":e,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-5 gap-y-2`,children:[(0,Y.jsx)(`label`,{htmlFor:`shortcut-${e}`,className:`min-w-0 text-sm font-medium text-content`,children:a}),(0,Y.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1 max-[650px]:w-full`,children:[(0,Y.jsx)(B,{id:`shortcut-${e}`,"data-shortcut-recorder":!0,variant:`outline`,className:R(`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,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:t(`config:shortcuts.recording`)}):ft(o)?(0,Y.jsx)($e,{className:`min-w-0 flex-wrap justify-center`,children:ft(o).split(` + `).map((e,t)=>(0,Y.jsx)(et,{className:`text-content-secondary`,children:e},t))}):(0,Y.jsx)(`span`,{className:`text-content-muted`,children:t(`config:shortcuts.disabled`)})}),(0,Y.jsxs)(Ve,{children:[(0,Y.jsx)(ze,{asChild:!0,children:(0,Y.jsx)(B,{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,Y.jsx)(P,{className:`size-4`})})}),(0,Y.jsxs)(Be,{align:`end`,className:`w-40`,onCloseAutoFocus:e=>{document.activeElement?.hasAttribute(`data-shortcut-recorder`)&&e.preventDefault()},children:[(0,Y.jsxs)(Le,{disabled:o===null,onSelect:()=>f(null),children:[(0,Y.jsx)(xe,{className:`size-4`}),t(`config:shortcuts.disableKey`)]}),(0,Y.jsxs)(Le,{disabled:o===l,onSelect:()=>f(l),children:[(0,Y.jsx)(fe,{className:`size-4`}),t(`config:shortcuts.resetAll`)]})]})]})]})]}),u?.action===e&&(0,Y.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,Y.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,Y.jsxs)(`span`,{className:`min-w-0 text-sm text-content-secondary`,children:[m.label(e),(0,Y.jsx)(`span`,{className:`ml-1.5 text-xs text-content-muted`,children:t(`board:shortcuts.fixed`)})]}),(0,Y.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1 max-[650px]:w-full`,children:[(0,Y.jsx)(nn,{keys:e.keys,className:`h-8 w-44 justify-center px-2.5 max-[650px]:flex-1`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`size-7 flex-none pointer-coarse:size-11 max-[650px]:size-11`})]})]},tn(e)):S(e.action);return(0,Y.jsxs)(`section`,{className:`w-full min-w-0`,"data-config-card":`shortcuts-bindings`,children:[(0,Y.jsx)(`div`,{className:`flex flex-col gap-5`,children:en.map((e,n)=>(0,Y.jsxs)(`section`,{"aria-labelledby":`shortcut-group-${e.id}`,"data-shortcut-group":e.id,children:[(0,Y.jsxs)(`div`,{className:`flex min-h-7 items-center justify-between gap-3`,children:[(0,Y.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,Y.jsxs)(B,{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,Y.jsx)(fe,{className:`size-3.5`,"aria-hidden":`true`}),t(`config:shortcuts.resetAll`)]})]}),(0,Y.jsx)(`p`,{className:`mb-2 text-xs text-content-muted`,children:m.groups[e.id].hint}),(0,Y.jsx)(ar,{children:e.entries.map(C)})]},e.id))}),(0,Y.jsx)(`div`,{className:`mt-3 min-h-5 text-xs text-content-muted`,role:`status`,"aria-live":`polite`,children:u?.action===null?(0,Y.jsx)(`span`,{className:`text-destructive`,children:u.message}):t(f?`config:shortcuts.saved`:`config:shortcuts.deviceScope`)})]})}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 Zr(e){let t=(0,J.useContext)(Ut);return(0,J.useLayoutEffect)(()=>{t?.update(e)}),(0,J.useLayoutEffect)(()=>()=>t?.remove(e.id),[t,e.id]),{requestClose:(0,J.useCallback)(n=>{t?t.requestClose(e.id,n):n()},[t,e.id])}}var Qr=[[`openai-responses`,`OpenAI Responses`],[`openai-completions`,`OpenAI Chat Completions`],[`anthropic-messages`,`Anthropic Messages`],[`google-generative-ai`,`Google Generative AI`]],$r={"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 ei(e){return!e||Qr.some(([t])=>t===e)?Qr:[...Qr,[e,$r[e]||e]]}var ti={openai:w,"openai-codex":w,anthropic:T,google:ge,deepseek:j,xai:ce,openrouter:se,"kimi-coding":ge,"zai-coding-cn":T},ni={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 ri(e,t){return t.name!==e.name||t.api!==e.api||t.baseUrl!==(e.baseUrl||``)||!!t.apiKey}function ii({provider:e,onSave:t,draft:n,onDraftChange:r,onSavingChange:i,children:a}){let{t:o}=l(),[s,c]=(0,J.useState)(!1),[u,d]=(0,J.useState)(``),f=(0,J.useId)(),p=ri(e,n),m=async a=>{if(a.preventDefault(),!s){c(!0),i(!0),d(``);try{t(await ni.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,Y.jsxs)(`form`,{onSubmit:e=>void m(e),"data-provider-connection-editor":!0,children:[(0,Y.jsxs)(`fieldset`,{disabled:s,className:`min-w-0 divide-y divide-stroke-soft`,children:[(0,Y.jsx)(or,{label:o(`config:configPage.displayName`),htmlFor:`${f}-name`,children:(0,Y.jsx)(V,{id:`${f}-name`,required:!0,value:n.name,onChange:e=>r({...n,name:e.target.value})})}),(0,Y.jsx)(or,{label:o(`config:configPage.apiKey`),htmlFor:`${f}-key`,children:(0,Y.jsx)(V,{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,Y.jsx)(or,{label:o(`config:configPage.apiProtocol`),labelId:`${f}-api-label`,help:(0,Y.jsx)(`span`,{className:`font-mono`,children:n.api}),children:(0,Y.jsx)(q,{"aria-labelledby":`${f}-api-label`,value:n.api,onChange:e=>r({...n,api:e.target.value}),children:ei(n.api).map(([e,t])=>(0,Y.jsx)(`option`,{value:e,children:t},e))})}),(0,Y.jsx)(or,{label:`Base URL`,htmlFor:`${f}-url`,children:(0,Y.jsx)(V,{id:`${f}-url`,required:!0,type:`url`,className:`font-mono`,value:n.baseUrl,onChange:e=>r({...n,baseUrl:e.target.value})})})]}),u&&(0,Y.jsx)(G,{className:`mt-2 mb-3`,children:u}),a,(0,Y.jsxs)(`div`,{className:R(`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,Y.jsx)(`span`,{role:`status`,className:`mr-auto text-xs text-content-muted`,children:o(`config:configPage.unsavedChanges`)}),(0,Y.jsx)(B,{type:`submit`,className:`max-[650px]:h-11`,disabled:!p,loading:s,children:o(s?`config:configPage.saving`:`config:configPage.saveChanges`)})]})]})}var ai=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function oi({label:e,checked:t,disabled:n,onChange:r}){return(0,Y.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t,disabled:n,onClick:r,className:R(`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,Y.jsx)(`span`,{"aria-hidden":`true`,className:R(`grid size-3.5 place-items-center rounded-[3px] border border-control`,t&&`border-star bg-star text-on-accent`),children:t&&(0,Y.jsx)(E,{size:11})}),e]})}function si({provider:e,model:t,onSave:n,onClose:r}){let{t:i}=l(),[a]=(0,J.useState)(()=>t?.contextWindow||2e5),[o,s]=(0,J.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,J.useState)(()=>({contextWindow:String(a),maxTokens:String(t?.maxTokens||8192)})),[d,f]=(0,J.useState)(t?.thinkingLevels||[`off`,`low`,`medium`,`high`]),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(``),y=o.capabilities.includes(`chat`),b=async i=>{if(i.preventDefault(),!h){g(!0),v(``);try{n(await ni.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,Y.jsx)(Ct,{open:!0,onOpenChange:e=>{!e&&!h&&r()},children:(0,Y.jsxs)(yt,{className:`sm:max-w-[540px] p-5`,showCloseButton:!h,onEscapeKeyDown:e=>{h&&e.preventDefault()},onInteractOutside:e=>e.preventDefault(),children:[(0,Y.jsxs)(St,{children:[(0,Y.jsx)(bt,{children:i(t?`providers:modelEditor.edit`:`providers:modelEditor.add`)}),(0,Y.jsxs)(vt,{children:[e.name,` · `,i(`providers:modelEditor.description`)]})]}),(0,Y.jsxs)(`form`,{onSubmit:e=>void b(e),className:`space-y-5`,children:[(0,Y.jsxs)(`fieldset`,{disabled:h,className:`space-y-5`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(`providers:modelEditor.id`),(0,Y.jsx)(V,{required:!0,disabled:!!t,value:o.modelId,onChange:e=>s({...o,modelId:e.target.value})})]}),(0,Y.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(`config:configPage.modelName`),(0,Y.jsx)(V,{value:o.name,onChange:e=>s({...o,name:e.target.value})})]})]}),(0,Y.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Y.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`providers:modelEditor.capabilities`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`chat`,`image`,`video`].map(e=>(0,Y.jsx)(oi,{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,Y.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:i(`providers:modelEditor.capabilitiesHint`)})]}),y&&(0,Y.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Y.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`providers:modelEditor.chatCapabilities`)}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(oi,{label:i(`providers:modelEditor.vision`),checked:o.input.includes(`image`),onChange:()=>s({...o,input:o.input.includes(`image`)?[`text`]:[`text`,`image`]})}),(0,Y.jsx)(oi,{label:i(`providers:modelEditor.reasoning`),checked:o.reasoning,onChange:()=>s({...o,reasoning:!o.reasoning})})]})]}),y&&o.reasoning&&(0,Y.jsxs)(`fieldset`,{children:[(0,Y.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`config:configPage.modelThinkingLevels`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ai.map(e=>(0,Y.jsx)(oi,{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,Y.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[`contextWindow`,`maxTokens`].map(e=>(0,Y.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(e===`contextWindow`?`providers:modelEditor.contextWindow`:`providers:modelEditor.maxTokens`),(0,Y.jsx)(V,{required:!0,type:`number`,min:1,max:1e8,step:1,value:c[e],onChange:t=>u({...c,[e]:t.target.value})})]},e))})]}),_&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:_}),(0,Y.jsxs)(xt,{children:[(0,Y.jsx)(B,{type:`button`,variant:`ghost`,disabled:h,onClick:r,children:i(`config:configPage.cancel`)}),(0,Y.jsxs)(B,{type:`submit`,disabled:h||!o.capabilities.length||!o.modelId.trim(),children:[h&&(0,Y.jsx)(I,{className:`animate-spin`,size:14}),` `,i(h?`config:configPage.saving`:`config:configPage.saveChanges`)]})]})]})]})})}function ci(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 li(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 ui(e){return e?e>=1e6?`${Number((e/1e6).toFixed(2))}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e):`—`}function di(e){return ei(e).find(([t])=>t===e)?.[1]||e}var fi=`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 pi(e){let{t}=l(),n=(0,J.useId)(),{providers:r,defaultId:i}=ci(e.config,e.selectedProviderId),a=r.find(t=>t.id===e.selectedProviderId),[o,s]=(0,J.useState)({}),[c,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(null),p=!!(c||e.settingDefault||e.settingModel||e.toggling||e.deletingModel);Zr({id:`provider-drafts-${n}`,dirty:r.some(e=>!!(o[e.id]&&ri(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`,ae,t.includes(`chat`)],[`image`,ne,t.includes(`image`)],[`video`,L,t.includes(`video`)],[`reasoning`,T,!!e.reasoning&&t.includes(`chat`)]].filter(([,,e])=>e).map(([e,t])=>(0,Y.jsxs)(`span`,{title:m[e],className:`inline-flex`,children:[(0,Y.jsx)(t,{size:13,"aria-hidden":`true`}),(0,Y.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,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,Y.jsx)(E,{className:`size-3.5`,"aria-hidden":`true`}),t(`config:providerWorkbench.connected`)]}):t(`config:configPage.disabled2`):t(`config:providerWorkbench.notConnected`),v=n=>(0,Y.jsxs)(`div`,{className:`@container/card min-w-0`,"data-provider-detail":n.id,children:[(0,Y.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,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-content-muted`,children:n.id}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-2 text-sm text-content-secondary`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:t(`config:configPage.enabled`)}),(0,Y.jsx)(ir,{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,Y.jsxs)(Ve,{children:[(0,Y.jsx)(ze,{asChild:!0,children:(0,Y.jsx)(B,{variant:`ghost`,size:`icon-sm`,className:`pointer-coarse:size-11 max-[650px]:size-11`,"aria-label":t(`config:providerWorkbench.actions`),children:(0,Y.jsx)(P,{size:16})})}),(0,Y.jsxs)(Be,{align:`end`,children:[(0,Y.jsxs)(Le,{disabled:n.id===i||!n.configured||!n.enabled||!n.defaultModel||p,onSelect:()=>void e.onSetDefault(n),children:[(0,Y.jsx)(Sn,{size:14}),t(`config:configPage.setAsDefaultProvider`)]}),(0,Y.jsxs)(Le,{disabled:p,onSelect:()=>e.onClone(n),children:[(0,Y.jsx)(M,{size:14}),t(`config:configPage.cloneProvider`)]}),n.custom&&(0,Y.jsxs)(Le,{className:`text-destructive`,disabled:p,onSelect:()=>void e.onDelete(n),children:[(0,Y.jsx)(ve,{size:14}),t(`config:configPage.deleteProvider`)]})]})]})]}),(0,Y.jsxs)(ii,{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,Y.jsxs)(`div`,{className:`mt-2 flex min-h-10 items-center gap-2 border-t border-stroke-soft pt-2`,children:[(0,Y.jsxs)(`h3`,{className:`text-[13px] font-medium text-content-muted`,children:[t(`config:providerWorkbench.models`),(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,n.models.length]})]}),(0,Y.jsxs)(B,{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,Y.jsx)(le,{size:14}),t(`providers:modelEditor.add`)]})]}),n.models.length>0&&(0,Y.jsxs)(`div`,{className:R(fi,`hidden h-8 text-xs font-medium text-content-muted @min-[560px]/card:grid`),children:[(0,Y.jsx)(`span`,{children:t(`providers:modelEditor.id`)}),(0,Y.jsx)(`span`,{children:t(`config:configPage.displayName`)}),(0,Y.jsx)(`span`,{className:`text-right`,children:t(`config:providerWorkbench.contextColumn`)}),(0,Y.jsx)(`span`,{children:t(`providers:modelEditor.capabilities`)}),(0,Y.jsx)(`span`,{"aria-hidden":`true`})]}),n.models.map(r=>{let i=n.defaultModel===r.id;return(0,Y.jsxs)(`div`,{"data-provider-model":r.id,className:R(fi,`min-h-11.5 border-t border-stroke-soft py-px text-sm text-content-secondary`),children:[(0,Y.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,Y.jsx)(`span`,{className:`block truncate font-mono text-[12.5px] text-content`,children:r.id}),(0,Y.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,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:r.name||r.id}),(0,Y.jsx)(`span`,{className:`tabular-nums`,children:ui(r.contextWindow)}),h(r)]})]}),(0,Y.jsx)(`span`,{className:`hidden min-w-0 truncate text-content @min-[560px]/card:block`,children:r.name||r.id}),(0,Y.jsx)(`span`,{className:`hidden text-right tabular-nums @min-[560px]/card:block`,children:ui(r.contextWindow)}),(0,Y.jsx)(`span`,{className:`hidden items-center gap-2 text-content-muted @min-[560px]/card:flex`,children:h(r)}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[r.kind===`chat`&&(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`icon-sm`,className:R(`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,Y.jsx)(Sn,{size:15,className:R(i&&`fill-current`)})}),(0,Y.jsx)(B,{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,Y.jsx)(bn,{size:14})}),(0,Y.jsx)(B,{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,Y.jsx)(ve,{size:14})})]})]},r.id)})]},n.id)]});return(0,Y.jsxs)(W,{"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,Y.jsx)(U,{children:r.map(n=>{let r=n.id===i,o=a?.id===n.id;return(0,Y.jsx)(H,{"data-provider-row":n.id,icon:(0,Y.jsx)(`span`,{className:`text-[13px] font-semibold text-content-secondary`,children:li(n.name)}),name:n.name,description:[g(n),t(`config:configPage.countModels`,{count:n.models.length}),di(n.api)].join(` · `),status:(0,Y.jsxs)(Y.Fragment,{children:[r&&(0,Y.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,Y.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,Y.jsx)(gt,{size:40,className:`mb-1`}),(0,Y.jsx)(`p`,{className:`text-sm font-medium text-content`,children:t(`config:providerWorkbench.noConnections`)}),(0,Y.jsx)(`p`,{className:`max-w-sm text-xs text-content-muted`,children:t(`config:providerWorkbench.addConnectionHint`)})]}),e.onAddConnection&&(0,Y.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,Y.jsx)(le,{size:16,"aria-hidden":`true`,className:`flex-none text-content-muted`}),(0,Y.jsx)(`span`,{className:`flex-none`,children:t(`config:providerWorkbench.addProvider`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:t(`config:providerWorkbench.addProviderHint`)})]}),d&&(0,Y.jsx)(si,{provider:d.provider,model:d.model,onSave:e.onSave,onClose:()=>f(null)})]})}function mi(){let e=globalThis.crypto.getRandomValues(new Uint32Array(4));return`custom-${Array.from(e,e=>e.toString(16).padStart(8,`0`)).join(``)}`}function hi({value:e,onChange:t,configured:n=!1,cloning:r=!1}){let{t:i}=l();return(0,Y.jsxs)(K,{variant:`control`,children:[i(`config:configPage.apiKey`),(0,Y.jsx)(V,{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 gi({ids:e,onChange:t,placeholder:n,primaryId:r=``}){let{t:i}=l(),[a,o]=(0,J.useState)(``),s=()=>{let n=a.trim();!n||n===r.trim()||e.includes(n)||(t([...e,n]),o(``))};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(K,{variant:`control`,children:[i(`config:configPage.manualModelIds`),(0,Y.jsxs)(`div`,{className:`flex items-stretch gap-1.5`,children:[(0,Y.jsx)(V,{"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,Y.jsx)(B,{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,Y.jsx)(le,{size:14})})]})]}),e.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-col overflow-hidden rounded-md border border-stroke`,children:e.map(n=>(0,Y.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,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12.5px] text-content`,children:n}),(0,Y.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,Y.jsx)(xe,{size:12})})]},n))}),(0,Y.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`config:configPage.manualModelIdsHint`)})]})}function _i(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 vi({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=_i(c,d),[m,h]=(0,J.useState)(``),g=!!(i||m),[_,v]=(0,J.useState)(()=>({name:a?s(`config:configPage.clonedProviderName`,{name:a.name}):i?.name||``,id:a?mi():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,J.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,J.useState)(!1),[T,D]=(0,J.useState)(``),[O,k]=(0,J.useState)(``),A=O.trim()||void 0,[j,M]=(0,J.useState)([]),N=e=>v(t=>({...t,name:e,id:t.id||e.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)}));return(0,J.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,Y.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,Y.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,Y.jsxs)(Ft,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{children:s(u?`config:configPage.cloneProvider`:g?`config:configPage.editProviderConnection`:`config:configPage.addProviderConnection`)}),!u&&(0,Y.jsx)(`p`,{children:s(g?`config:configPage.updateProviderKeyURLAndModelSettings`:`config:configPage.youCanCreateMultipleConnectionsUsingTheSameProtocolEachWithItsOwnKeyAndBaseURL`)})]}),(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`config:configPage.closeDialog`),disabled:C,onClick:t=>{t.preventDefault(),t.stopPropagation(),e()},children:(0,Y.jsx)(xe,{size:17})})]}),(0,Y.jsxs)(`div`,{className:`form-grid grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(K,{variant:`control`,children:[s(`config:configPage.displayName`),(0,Y.jsx)(V,{value:_.name,onChange:e=>N(e.target.value),placeholder:s(`config:configPage.forExampleOpenAIOfficial`)})]}),(0,Y.jsxs)(K,{variant:`control`,children:[`Provider ID`,(0,Y.jsx)(V,{value:_.id,disabled:g,onChange:e=>v({..._,id:e.target.value}),placeholder:`openai-official`})]})]}),(0,Y.jsx)(hi,{value:O,onChange:k,configured:i?.configured,cloning:u}),!u&&(0,Y.jsxs)(Y.Fragment,{children:[!o&&(0,Y.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,Y.jsx)(`span`,{className:`text-xs text-content-muted`,children:s(`config:configPage.providerPurpose`)}),(0,Y.jsx)(`strong`,{className:`font-mono text-xs font-medium`,children:_.providerType===`visual`?s(`config:configPage.visualProvider`):s(`config:configPage.chatProvider`)})]}),(0,Y.jsxs)(K,{variant:`control`,children:[s(`config:configPage.apiProtocol`),(0,Y.jsx)(q,{value:_.api,onChange:e=>v({..._,api:e.target.value}),children:Qr.map(([e,t])=>(0,Y.jsx)(`option`,{value:e,children:t},e))})]}),(0,Y.jsxs)(K,{variant:`control`,children:[`Base URL`,(0,Y.jsx)(V,{value:_.baseUrl,onChange:e=>v({..._,baseUrl:e.target.value}),placeholder:`https://api.openai.com/v1`})]}),(0,Y.jsxs)(`div`,{className:`form-grid grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(K,{variant:`control`,children:[s(g?`config:configPage.providerDefaultModel`:`config:configPage.initialModelID`),(0,Y.jsx)(V,{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,Y.jsxs)(K,{variant:`control`,children:[s(`config:configPage.modelName`),(0,Y.jsx)(V,{value:_.modelName,onChange:e=>v({..._,modelName:e.target.value}),placeholder:s(`config:configPage.leaveBlankToUseTheModelID`)})]})]}),(0,Y.jsxs)(`details`,{open:!o||void 0,className:`group rounded-lg border border-border px-3 py-2 [&[open]]:space-y-3`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer text-[13px] text-muted-foreground`,children:s(`config:providerWorkbench.modelOptions`)}),(0,Y.jsxs)(K,{variant:`control`,children:[s(`config:configPage.modelType`),(0,Y.jsxs)(q,{value:_.modelKind,onChange:e=>v({..._,modelKind:e.target.value,providerType:e.target.value===`chat`?`chat`:`visual`}),children:[(0,Y.jsx)(`option`,{value:`chat`,children:s(`providers:modelEditor.chat`)}),(0,Y.jsx)(`option`,{value:`image`,children:s(`providers:modelEditor.image`)}),(0,Y.jsx)(`option`,{value:`video`,children:s(`providers:modelEditor.video`)})]})]}),(0,Y.jsx)(`div`,{className:`grid gap-[9px]`,children:(0,Y.jsx)(gi,{ids:j,onChange:M,primaryId:_.model,placeholder:_.providerType===`visual`?`gpt-image-1`:`gpt-5.5`})}),_.modelKind===`chat`&&(0,Y.jsxs)(K,{variant:`control`,children:[s(`config:configPage.modelThinkingLevels`),(0,Y.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,Y.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r,onClick:()=>!t&&S(e),className:R(`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,Y.jsx)(E,{size:12}),e]},e)})}),(0,Y.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:s(`config:configPage.modelThinkingLevelsHint`)})]})]}),!o&&(0,Y.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,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Y.jsx)(`strong`,{className:`text-[13px]`,children:g?s(`config:configPage.providerEnabled`,{name:_.name}):s(`config:configPage.enableAfterCreation`)}),_.providerType===`visual`&&(0,Y.jsx)(`small`,{className:`text-[13px] text-muted-foreground`,children:s(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]}),(0,Y.jsx)(ir,{value:_.enabled,onChange:e=>v({..._,enabled:e})})]})]}),T&&(0,Y.jsxs)(Nt,{children:[(0,Y.jsx)(ye,{size:13}),T]}),(0,Y.jsxs)(`div`,{className:`mt-[18px] flex justify-end gap-2`,children:[(0,Y.jsx)(B,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:C,onClick:e,children:s(`config:configPage.cancel`)}),(0,Y.jsxs)(B,{type:`submit`,className:`max-[650px]:h-11`,disabled:C,children:[C?(0,Y.jsx)(z,{className:`text-current`}):g?(0,Y.jsx)(E,{size:14}):(0,Y.jsx)(le,{size:14}),s(C?`config:configPage.saving`:u?`config:configPage.cloneProvider`:g?`config:configPage.saveChanges`:`config:configPage.createConnection`)]})]})]})})}function yi(e){return(e.providers||[]).filter(e=>e.importable&&!e.imported&&!e.conflict).length}function bi(e){return yi(e)>0}function xi(e,t){return!t&&!bi(e)}function Si(e,t,n){let r=e.providers||[],i=e.errors||[],a=bi(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 Ci(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 wi(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 Ti(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 Ei({discovery:e,discovering:t,error:n,importing:r,forceVisible:i=!1,onRefresh:a,onImport:o}){let{t:s}=l(),[c,u]=(0,J.useState)(null),d=e.providers||[],f=e.errors||[];if(!i&&!Si(e,t,n))return null;let p=c??(!i&&xi(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,Y.jsxs)(tr,{className:`mb-3 py-3.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5 max-[650px]:flex-wrap`,children:[(0,Y.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,Y.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,Y.jsx)(me,{size:18})}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium text-content`,children:s(`config:configPage.localProviderConfiguration`)}),(0,Y.jsx)(`span`,{className:`text-xs leading-[1.45] text-content-muted`,children:s(`config:configPage.readProviderEndpointModelAndAuthenticationFieldsFromCodexConfigTomlAndClaudeSettingsJson`)})]}),(0,Y.jsx)(D,{size:16,"aria-hidden":`true`,className:R(`flex-none text-content-muted transition-transform`,!p&&`rotate-180`)})]}),(0,Y.jsxs)(B,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:t||!!r,onClick:m,children:[t?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(ue,{size:13}),s(`config:configPage.rescan`)]})]}),!p&&(0,Y.jsxs)(Y.Fragment,{children:[t&&!d.length?(0,Y.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,Y.jsx)(z,{}),s(`config:configPage.scanningProviderConfigurationFiles`)]}):d.length?(0,Y.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 max-[650px]:grid-cols-1`,children:d.map(e=>{let t=Ci(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,Y.jsxs)(`div`,{className:R(`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,Y.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,Y.jsx)(i,{size:15})}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Y.jsxs)(`span`,{className:`truncate text-sm font-medium text-content`,children:[t,` · `,e.providerName]}),(0,Y.jsxs)(`span`,{className:`truncate font-mono text-xs text-content-muted`,children:[e.api,` · `,a]}),(0,Y.jsxs)(`span`,{className:`truncate text-xs text-content-muted`,children:[e.kind===`authentication`?s(`config:configPage.officialEndpointOnly`):e.baseUrl||s(`config:configPage.noBaseURLSpecified`),` `,`· `,wi(e,s),` · `,e.location]})]}),(0,Y.jsx)(`span`,{className:`flex min-w-0 flex-none items-center max-[650px]:col-start-2`,children:e.imported?(0,Y.jsx)(rr,{tone:`green`,children:s(`config:configPage.loaded`)}):e.conflict?(0,Y.jsx)(rr,{tone:`amber`,children:s(`config:configPage.conflictDetected`)}):e.importable?(0,Y.jsxs)(B,{type:`button`,size:`sm`,className:`pointer-coarse:h-11`,disabled:n||!!r,onClick:()=>h(e),children:[n?(0,Y.jsx)(z,{className:`size-3 text-current`}):(0,Y.jsx)(N,{size:12}),n?s(`config:configPage.loading`):e.kind===`authentication`?s(`config:configPage.loadLoginState`):s(`config:configPage.loadConfiguration`)]}):(0,Y.jsx)(rr,{tone:`gray`,children:s(`config:configPage.cannotLoad`)})})]},e.id)})}):(0,Y.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,Y.jsx)(me,{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,Y.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,Y.jsxs)(`span`,{children:[(0,Y.jsx)(ye,{size:13}),n]}),f.map((e,t)=>(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(ye,{size:13}),Ci(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,Y.jsxs)(`span`,{children:[(0,Y.jsx)(ye,{size:13}),Ci(e),` · `,Ti(t.code,s)]},`${e.id}-${t.code}-${n}`)))]})]})]})}function Di(e){try{return{name:new URL(e).hostname.replace(/^www\./i,``)||`Custom Provider`}}catch{return{name:`Custom Provider`}}}function Oi({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,J.useState)(1),[d,p]=(0,J.useState)(s),[m]=(0,J.useState)(mi),[h,g]=(0,J.useState)(``),_=(0,J.useRef)(null),v=(0,J.useRef)(null),[y,S]=(0,J.useState)(s?.baseUrl||``),[C,w]=(0,J.useState)(s?.api||`openai-responses`),[T,D]=(0,J.useState)(``),O=T.trim()||void 0,[k,A]=(0,J.useState)(s?.organization||``),[j,M]=(0,J.useState)(s?.name||``),[N,P]=(0,J.useState)(s?.models||[]),[F,ee]=(0,J.useState)(s?.defaultModel||``),[te,ne]=(0,J.useState)([]),[re,ie]=(0,J.useState)(s?.models.find(e=>e.id===s.defaultModel)?.kind||(t===`visual`?`image`:`chat`)),[I,ae]=(0,J.useState)(!1),[oe,L]=(0,J.useState)(``),[se,ce]=(0,J.useState)(``),le=Di(y),de=o(t===`visual`?`config:configPage.visualProvider`:`config:configPage.chatProvider`),fe=o(c===1?`config:configPage.quickSetupStepBaseUrl`:c===2?`config:configPage.quickSetupStepProtocol`:`config:configPage.quickSetupStepModel`),pe=N.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{L(o(`config:configPage.providerBaseURLMustBeHTTPOrHTTPS`));return}L(``),j.trim()||M(le.name),u(2)},ge=()=>{if(!C){L(o(`config:configPage.selectAPIProtocol`));return}L(``),u(3)},_e=async()=>{if(I)return;let e=d;if(!O&&!e?.configured&&!h){L(o(`config:configPage.enterTheAPIKeyForThisConnection`));return}ae(!0),L(``),ce(``);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){L(o(t===`visual`?`config:configPage.fetchOrAddAVisualModel`:`config:configPage.fetchOrAddAChatModel`));return}P(n);let r=n.find(e=>e.id===F)||n[0];ee(r.id),ie(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){P(i);let e=i.find(e=>e.id===F)||i[0];ee(e.id),ie(t===`visual`?e.kind:`chat`),ce(r)}else L(r)}finally{ae(!1)}},ve=async()=>{if(I)return;let e=F.trim()||te[0]||``;if(!e){L(o(`config:configPage.selectModelToFinish`));return}if(!O&&!d?.configured&&!h){L(o(`config:configPage.enterTheAPIKeyForThisConnection`));return}let n=new Set((d?.models||[]).map(e=>e.id)),r=te.filter(t=>t!==e&&!n.has(t));ae(!0),L(``);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`?re:`chat`,apiKey:O,setAsDefault:!1,enabled:!0})}):await f(`/api/providers`,{method:`POST`,body:JSON.stringify({id:m,name:j.trim()||le.name,providerType:t,api:C,baseUrl:y,organization:k,apiKey:O,model:e,modelKind:t===`visual`?re:`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`?re:`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){L(e instanceof Error?e.message:String(e));return}}a(l?{...o,createdProviderId:l}:o)}catch(e){L(e instanceof Error?e.message:String(e))}finally{ae(!1)}};return(0,Y.jsx)(Ct,{open:!0,onOpenChange:e=>{!e&&!I&&r()},children:(0,Y.jsxs)(yt,{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":I,onEscapeKeyDown:e=>{I&&e.preventDefault()},onInteractOutside:e=>{I&&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,Y.jsxs)(Ft,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(bt,{asChild:!0,children:(0,Y.jsx)(`h2`,{children:o(t===`visual`?`config:configPage.visualQuickSetupTitle`:`config:configPage.quickSetupTitle`)})}),(0,Y.jsx)(vt,{asChild:!0,children:(0,Y.jsxs)(`p`,{children:[o(`config:configPage.stepIndicator`,{current:c,total:3}),` · `,fe]})})]}),(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`icon`,className:`pointer-coarse:size-11`,"aria-label":o(`config:configPage.closeDialog`),disabled:I,onClick:r,children:(0,Y.jsx)(xe,{size:17})})]}),(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`mt-3 grid grid-cols-3 gap-1`,children:[1,2,3].map(e=>(0,Y.jsx)(`span`,{className:R(`h-1 rounded-full`,e<=c?`bg-star`:`bg-surface-active`)},e))}),(0,Y.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,Y.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,Y.jsx)(me,{size:15,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`truncate text-sm font-medium text-content`,children:j||le.name}),(0,Y.jsx)(`small`,{className:`text-xs text-content-muted`,children:de})]}),(0,Y.jsx)(rr,{tone:`gray`,children:de})]}),c===1&&(0,Y.jsxs)(`div`,{className:`[margin-top:14px]`,children:[(0,Y.jsxs)(K,{variant:`control`,children:[`Base URL`,(0,Y.jsx)(V,{ref:v,value:y,onChange:e=>S(e.target.value),placeholder:`https://api.example.com/v1`,inputMode:`url`})]}),(0,Y.jsx)(`p`,{className:`mt-2 text-xs leading-[1.5] text-content-muted`,children:o(`config:configPage.quickSetupBaseUrlHint`)})]}),c===2&&(0,Y.jsxs)(`div`,{className:`[margin-top:14px]`,children:[(0,Y.jsxs)(K,{variant:`control`,children:[o(`config:configPage.apiProtocol`),(0,Y.jsx)(q,{value:C,onChange:e=>w(e.target.value),children:Qr.map(([e,t])=>(0,Y.jsx)(`option`,{value:e,children:t},e))})]}),(0,Y.jsxs)(K,{variant:`control`,children:[`Organization`,(0,Y.jsx)(V,{value:k,onChange:e=>A(e.target.value),placeholder:o(`config:configPage.optionalUsedOnlyForOpenAIOrganization`)})]})]}),c===3&&(0,Y.jsxs)(`div`,{className:`[margin-top:14px]`,children:[!d&&(0,Y.jsxs)(K,{variant:`control`,children:[o(`config:configPage.displayName`),(0,Y.jsx)(V,{value:j,onChange:e=>M(e.target.value),placeholder:le.name})]}),(0,Y.jsx)(hi,{value:T,onChange:D,configured:d?.configured}),(0,Y.jsxs)(B,{type:`button`,variant:`secondary`,className:`mt-2.5 w-full max-[650px]:h-11`,disabled:I,onClick:()=>void _e(),children:[I?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(ue,{size:14}),o(I?`config:configPage.fetchingModels`:`config:configPage.fetchModels`)]}),se&&(0,Y.jsxs)(Mt,{className:`[margin-top:10px]`,children:[(0,Y.jsx)(ye,{size:15}),(0,Y.jsx)(`small`,{children:o(`config:configPage.discoverFailedUsingExisting`,{message:se})})]}),pe.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(`div`,{className:`flex max-h-[260px] flex-col overflow-y-auto rounded-md border border-stroke`,children:pe.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:R(`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`,F===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:()=>{ee(e.id),ie(t===`visual`?e.kind:`chat`)},children:[(0,Y.jsx)(`span`,{className:R(`grid size-4 flex-none place-items-center rounded-full border border-control text-transparent`,F===e.id&&`border-star bg-star text-on-accent`),children:(0,Y.jsx)(E,{size:11})}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-content`,children:e.name}),t===`visual`&&(0,Y.jsx)(rr,{tone:`gray`,children:e.kind===`video`?o(`config:configPage.visualVideoModel`):o(`config:configPage.visualImageModel`)})]},`${e.id}-${e.kind}`))})]}),(0,Y.jsxs)(`div`,{className:`mt-3.5 grid gap-2`,children:[(0,Y.jsxs)(K,{variant:`control`,children:[o(`config:configPage.manualModelId`),(0,Y.jsx)(V,{value:F,onChange:e=>ee(e.target.value),placeholder:t===`visual`?`gpt-image-1`:`gpt-5.4`})]}),(0,Y.jsx)(`p`,{className:`text-xs text-content-muted`,children:o(`config:configPage.manualModelIdHint`)}),t===`visual`&&(0,Y.jsxs)(K,{variant:`control`,children:[o(`config:configPage.modelType`),(0,Y.jsxs)(q,{value:re,onChange:e=>ie(e.target.value),children:[(0,Y.jsx)(`option`,{value:`image`,children:o(`config:configPage.imageGenerationAndEditing`)}),(0,Y.jsx)(`option`,{value:`video`,children:o(`config:configPage.videoGeneration`)})]})]}),(0,Y.jsx)(gi,{ids:te,onChange:ne,primaryId:F,placeholder:t===`visual`?`gpt-image-1`:`gpt-5.5`})]})]}),oe&&(0,Y.jsxs)(Nt,{children:[(0,Y.jsx)(ye,{size:13}),oe]}),(0,Y.jsxs)(`div`,{className:`mt-[18px] flex justify-between gap-2`,children:[(0,Y.jsxs)(B,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:I||c===1,onClick:()=>{L(``),u(c-1)},children:[(0,Y.jsx)(b,{size:14}),o(`config:configPage.previousStep`)]}),c===1?(0,Y.jsxs)(B,{type:`button`,className:`max-[650px]:h-11`,disabled:I||!y.trim(),onClick:he,children:[(0,Y.jsx)(x,{size:14}),o(`config:configPage.nextStep`)]}):c===2?(0,Y.jsxs)(B,{type:`button`,className:`max-[650px]:h-11`,disabled:I,onClick:ge,children:[(0,Y.jsx)(x,{size:14}),o(`config:configPage.nextStep`)]}):(0,Y.jsxs)(B,{type:`button`,className:`max-[650px]:h-11`,disabled:I||!F.trim()&&te.length===0,onClick:()=>void ve(),children:[I?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(E,{size:14}),o(I?`config:configPage.saving`:`config:configPage.saveChanges`)]})]})]})})}var ki=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],Ai=``;function ji(e){return`${e.provider.id}/${e.model.id}`}function Mi({labelId:e,label:t,hint:n,children:r}){return(0,Y.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,Y.jsxs)(`div`,{className:`min-w-[min(240px,100%)] flex-1`,children:[(0,Y.jsx)(`div`,{id:e,className:`text-sm font-medium text-content`,children:t}),(0,Y.jsx)(`p`,{id:`${e}-hint`,className:`mt-0.5 text-xs text-content-muted`,children:n})]}),(0,Y.jsx)(`div`,{className:`w-[min(280px,100%)] min-w-0 max-[650px]:w-full`,children:r})]})}function Ni({config:e,notify:t,busy:n,onConfigChanged:r,onSetDefaultModel:i}){let{t:a}=l(),o=(0,J.useId)(),[s,c]=(0,J.useState)(!1),[u,d]=(0,J.useState)(``),[p,m]=(0,J.useState)(e.thinkingLevel),[h,g]=(0,J.useState)(e.toolMode);(0,J.useEffect)(()=>{m(e.thinkingLevel),g(e.toolMode)},[e.thinkingLevel,e.toolMode]);let _=(e.fallbackModels||[]).join(`
2
2
  `),[v,y]=(0,J.useState)(e.fallbackModels||[]);(0,J.useEffect)(()=>{y(_?_.split(`
3
3
  `):[])},[_]);let[b,x]=(0,J.useState)(e.auxiliaryModel||``);(0,J.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}${Ai}${t.id}`}))),O=w&&C?`${w.id}${Ai}${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 ni.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 ni.saveAuxiliaryModel(e)),t(a(`config:providerWorkbench.auxiliaryModelSaved`))}catch(e){x(n),d(e instanceof Error?e.message:String(e))}finally{c(!1)}},N=(e,t)=>(0,Y.jsxs)(q,{"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,Y.jsx)(`option`,{value:``,children:a(`config:providerWorkbench.fallbackNone`)}),v[e]&&!D.some(t=>ji(t)===v[e])&&(0,Y.jsx)(`option`,{value:v[e],children:v[e]}),D.map(e=>(0,Y.jsx)(`option`,{value:ji(e),children:`${e.model.name||e.model.id} · ${e.provider.name}`},e.value))]});return(0,Y.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,Y.jsx)(`h2`,{id:`${o}-heading`,className:`sr-only`,children:a(`config:configPage.currentChatModel`)}),(0,Y.jsxs)(`div`,{"data-config-target":`models-runtime-policy`,className:`border-t border-stroke`,children:[(0,Y.jsx)(Mi,{labelId:`${o}-model`,label:a(`config:providerWorkbench.defaultModel`),hint:a(`config:providerWorkbench.defaultModelHint`),children:(0,Y.jsxs)(q,{"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(Ai),r=E.find(e=>e.id===t);r&&n&&i(r,n)},children:[!D.length&&(0,Y.jsx)(`option`,{value:``,children:a(`config:providerWorkbench.noChatModel`)}),D.map(({provider:e,model:t,value:n})=>(0,Y.jsx)(`option`,{value:n,children:`${Tt(t.name||t.id,D.map(e=>e.model.name||e.model.id))} · ${e.name}`},n))]})}),(0,Y.jsx)(Mi,{labelId:`${o}-fallback`,label:a(`config:providerWorkbench.fallbackModels`),hint:a(`config:providerWorkbench.fallbackModelsHint`),children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Y.jsx)(`span`,{id:`${o}-fallback-1`,className:`sr-only`,children:a(`config:providerWorkbench.fallbackFirst`)}),N(0,`${o}-fallback ${o}-fallback-1`),(0,Y.jsx)(`span`,{id:`${o}-fallback-2`,className:`sr-only`,children:a(`config:providerWorkbench.fallbackSecond`)}),N(1,`${o}-fallback ${o}-fallback-2`)]})}),(0,Y.jsx)(Mi,{labelId:`${o}-auxiliary`,label:a(`config:providerWorkbench.auxiliaryModel`),hint:a(`config:providerWorkbench.auxiliaryModelHint`),children:(0,Y.jsxs)(q,{"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,Y.jsx)(`option`,{value:``,children:a(`config:providerWorkbench.auxiliaryFollowSession`)}),b&&!D.some(e=>ji(e)===b)&&(0,Y.jsx)(`option`,{value:b,children:b}),D.map(e=>(0,Y.jsx)(`option`,{value:ji(e),children:`${e.model.name||e.model.id} · ${e.provider.name}`},e.value))]})}),(0,Y.jsx)(Mi,{labelId:`${o}-thinking`,label:a(`config:configPage.thinkingLevel`),hint:a(`config:providerWorkbench.thinkingHint`),children:(0,Y.jsx)(q,{"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:ki.map(e=>(0,Y.jsx)(`option`,{children:e},e))})}),(0,Y.jsx)(Mi,{labelId:`${o}-tools`,label:a(`config:configPage.availableTools`),hint:a(`config:providerWorkbench.toolsHint`),children:(0,Y.jsxs)(q,{"aria-labelledby":`${o}-tools`,className:`w-full`,disabled:A,value:h,onChange:e=>{g(e.target.value),k({toolMode:e.target.value})},children:[(0,Y.jsx)(`option`,{value:`full`,children:a(`config:configPage.fullToolAccess`)}),(0,Y.jsx)(`option`,{value:`custom`,children:a(`config:configPage.customManageEachToolOnThePluginsPage`)})]})})]}),(!T||s)&&(0,Y.jsxs)(`p`,{className:`mt-2 flex items-center gap-2 text-xs text-content-muted`,role:`status`,children:[s&&(0,Y.jsx)(z,{className:`size-3`}),a(s?`config:configPage.saving`:`config:providerWorkbench.defaultsNeedProvider`)]}),u&&(0,Y.jsx)(G,{children:u})]})}var Pi=[`fast`,`standard`,`strong`],Fi={listProfiles(){return f(`/api/agent-profiles`)},saveModelTiers(e){return f(`/api/config/subagent-model-tiers`,{method:`PUT`,body:JSON.stringify({tiers:e})})}};function Ii({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,J.useId)(),[c,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(``),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(``),_=e.subagentModelTiers||{},v=Pi.map(e=>_[e]||``).join(`
4
4
  `),[y,b]=(0,J.useState)(_);(0,J.useEffect)(()=>{let e=v.split(`
5
- `);b(Object.fromEntries(Pi.map((t,n)=>[t,e[n]]).filter(([,e])=>e)))},[v]),(0,J.useEffect)(()=>{let e=!0;return Fi.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:`${Tt(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 Fi.saveModelTiers(o)),t(i(`config:subagents.tiersSaved`))}catch(e){b(a),f(e instanceof Error?e.message:String(e))}finally{u(!1)}},w=p?.profiles||[],T=p?.errors||[];return(0,Y.jsxs)(`section`,{"aria-labelledby":`${s}-heading`,"aria-busy":c||void 0,"data-config-card":`models-subagents`,"data-config-target":`models-subagents`,className:`mt-6 min-w-0`,children:[(0,Y.jsx)(`h2`,{id:`${s}-heading`,className:`text-sm font-medium text-content`,children:i(`config:subagents.title`)}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-content-muted`,children:i(`config:subagents.hint`)}),(0,Y.jsx)(`div`,{className:`mt-3 border-t border-stroke`,children:Pi.map(e=>{let t=y[e]||``;return(0,Y.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,Y.jsxs)(`div`,{className:`min-w-[min(240px,100%)] flex-1`,children:[(0,Y.jsxs)(`div`,{id:`${s}-${e}`,className:`text-sm text-content`,children:[a(e),(0,Y.jsx)(`code`,{className:`ml-2 font-mono text-xs text-content-muted`,children:e})]}),(0,Y.jsx)(`p`,{id:`${s}-${e}-hint`,className:`mt-0.5 text-xs text-content-muted`,children:o(e)})]}),(0,Y.jsx)(`div`,{className:`w-[min(280px,100%)] min-w-0 max-[650px]:w-full`,children:(0,Y.jsxs)(q,{"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,Y.jsx)(`option`,{value:``,children:i(`config:subagents.followSession`)}),t&&!S.some(e=>e.value===t)&&(0,Y.jsx)(`option`,{value:t,children:t}),S.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})})]},e)})}),d&&(0,Y.jsx)(G,{children:d}),(0,Y.jsx)(`h3`,{className:`mt-5 text-[13px] font-medium text-content`,children:i(`config:subagents.globalDefinitions`)}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-content-muted`,children:i(`config:subagents.definitionsHint`)}),p===null?(0,Y.jsxs)(`p`,{role:`status`,className:`mt-3 flex items-center gap-2 text-xs text-content-muted`,children:[(0,Y.jsx)(z,{className:`size-3`}),i(`config:subagents.loading`)]}):w.length===0&&T.length===0?(0,Y.jsx)(`p`,{className:`mt-3 text-xs text-content-muted`,children:i(`config:subagents.empty`)}):(0,Y.jsxs)(`ul`,{className:`mt-3 flex min-w-0 flex-col border-t border-stroke`,children:[w.map(e=>(0,Y.jsxs)(`li`,{className:`min-w-0 border-b border-stroke py-2 text-[13px]`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`code`,{className:`shrink-0 font-mono text-content`,children:e.name}),(0,Y.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,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-content-secondary`,children:e.description})]},e.name)),T.map(e=>(0,Y.jsxs)(`li`,{className:`min-w-0 border-b border-stroke py-2 text-[13px]`,children:[(0,Y.jsx)(`code`,{className:`font-mono text-danger`,children:e.file||e.scope}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-danger`,children:e.message})]},`${e.scope}:${e.file}`))]}),h&&(0,Y.jsx)(G,{children:h})]})}function Li(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)||e}function Ri({notify:e}){let{t}=l(),n=(0,J.useId)(),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(!1),[u,d]=(0,J.useState)(`allow`),[f,p]=(0,J.useState)(`bash`),[m,h]=(0,J.useState)(``);(0,J.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,Y.jsxs)(`section`,{"aria-labelledby":`${n}-heading`,"data-config-card":`models-permission-rules`,"data-config-target":`models-permission-rules`,className:`mt-6 min-w-0`,children:[(0,Y.jsx)(`h2`,{id:`${n}-heading`,className:`text-sm font-medium text-content`,children:t(`config:permissionRules.title`)}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-content-muted`,children:t(`config:permissionRules.hint`)}),r===null?(0,Y.jsxs)(`p`,{role:`status`,className:`mt-3 flex items-center gap-2 text-xs text-content-muted`,children:[(0,Y.jsx)(z,{className:`size-3`}),t(`config:permissionRules.loading`)]}):r.length===0?(0,Y.jsx)(`p`,{className:`mt-3 text-xs text-content-muted`,children:t(`config:permissionRules.empty`)}):(0,Y.jsx)(`ul`,{className:`mt-3 flex min-w-0 flex-col border-t border-stroke`,children:r.map(e=>(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 border-b border-stroke py-2 text-[13px]`,children:[(0,Y.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,Y.jsx)(`span`,{className:`shrink-0 text-xs text-content-muted`,children:e.tool===`files`?t(`config:permissionRules.files`):t(`config:permissionRules.command`)}),(0,Y.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-content`,title:e.pattern,children:e.pattern}),(0,Y.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate text-xs text-content-muted`,title:e.cwd||void 0,children:e.cwd?Li(e.cwd):t(`config:permissionRules.global`)}),(0,Y.jsx)(B,{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,Y.jsx)(ve,{})})]},e.id))}),(0,Y.jsxs)(`form`,{className:`mt-3 flex min-w-0 flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,Y.jsxs)(q,{"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,Y.jsx)(`option`,{value:`allow`,children:t(`config:permissionRules.allow`)}),(0,Y.jsx)(`option`,{value:`deny`,children:t(`config:permissionRules.deny`)})]}),(0,Y.jsxs)(q,{"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,Y.jsx)(`option`,{value:`bash`,children:t(`config:permissionRules.command`)}),(0,Y.jsx)(`option`,{value:`files`,children:t(`config:permissionRules.files`)})]}),(0,Y.jsx)(V,{"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,Y.jsxs)(B,{type:`submit`,variant:`secondary`,disabled:s||!m.trim(),className:`max-[650px]:min-h-11`,children:[s&&(0,Y.jsx)(z,{className:`size-3`}),t(`config:permissionRules.add`)]})]}),a&&(0,Y.jsx)(G,{children:a})]})}function zi(e){return e instanceof Error?e.message:String(e)}function Bi({notify:e,requestConfirm:t,t:n}){let[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(!0),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(``),[d,p]=(0,J.useState)(``),[m,h]=(0,J.useState)(``),[g,_]=(0,J.useState)(``),v=(0,J.useRef)(0),y=(0,J.useRef)(!1);(0,J.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(zi(n)),o(!1))}),()=>{e=!1,y.current=!1,v.current+=1}},[]);let b=(0,J.useCallback)(e=>{v.current+=1,i(e),o(!1),c(``)},[]),x=(0,J.useCallback)(async()=>{let e=v.current,t=await f(`/api/config`);y.current&&v.current===e&&b(t)},[b]),S=(0,J.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(zi(e))}finally{u(``)}},[b,e,n]),C=(0,J.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(zi(e))}finally{p(``)}},[b,e,n]),w=(0,J.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(zi(e))}finally{h(``)}},[b,e,n]),T=(0,J.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(zi(e))}finally{p(``)}},[b,e,n]),E=(0,J.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(zi(e))}finally{y.current&&o(!1)}},[b]),D=(0,J.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 ni.deleteModel(r.id,i.id)),e(n(`providers:modelEditor.deleted`))}catch(e){c(zi(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,J.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(zi(e))}}},[b,e,t,n]),deleteModel:D}}function Vi({requestConfirm:e,onImported:t,onAutoImported:n,t:r}){let[i,a]=(0,J.useState)({providers:[],errors:[]}),[o,s]=(0,J.useState)(!0),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(``),[p,m]=(0,J.useState)(``),[h,g]=(0,J.useState)({imported:0,skipped:0}),_=(0,J.useRef)(0),v=(0,J.useRef)(n);v.current=n;let y=(0,J.useCallback)(async()=>{let e=++_.current;s(!0),l(``);try{let t=await ni.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(zi(t))}finally{e===_.current&&s(!1)}},[]);return(0,J.useEffect)(()=>(y(),()=>{_.current+=1}),[y]),{discovery:i,autoImport:h,discovering:o,error:c,operationError:u,importing:p,refresh:y,importProvider:(0,J.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(zi(e))}finally{m(``)}}},[t,e,r])}}function Hi({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,Y.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:p.map(e=>{let l=ti[e.id]||me,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,Y.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,Y.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,Y.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,Y.jsx)(l,{size:15})}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),p&&(0,Y.jsx)(jt,{variant:`accent`,children:f(`config:configPage.defaultBadge`)})]}),c&&e.models.some(e=>e.kind===`chat`)?(0,Y.jsxs)(`label`,{className:`grid min-w-0 gap-1 text-xs text-content-muted`,children:[f(`config:configPage.providerDefaultModel`),(0,Y.jsxs)(q,{"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,Y.jsx)(`option`,{value:e.defaultModel||``,disabled:!0,children:e.defaultModel||f(`config:configPage.selectModel`)}),e.models.filter(e=>e.kind===`chat`).map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}):e.defaultModel?(0,Y.jsxs)(`small`,{className:`truncate font-mono text-xs text-content-muted`,title:e.defaultModel,children:[f(`config:configPage.providerDefaultModel`),`: `,e.defaultModel]}):null,(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`small`,{className:`text-xs text-content-muted`,children:m}),(0,Y.jsxs)(`div`,{className:`flex flex-none items-center gap-1.5`,children:[s&&(0,Y.jsx)(B,{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,Y.jsx)(Sn,{size:13})}),(0,Y.jsx)(B,{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,Y.jsx)(M,{size:13})}),(0,Y.jsx)(ir,{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,Y.jsx)(B,{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,Y.jsx)(ve,{size:13})})]})]})]},e.id)})})}var Ui=`pisper.config.visualConnectionsOpen`,$={running:null,result:null,error:``};function Wi(){return r.getItem(Ui)===`1`}function Gi({config:e,notify:t,toggling:n,onToggleProvider:i,onDeleteProvider:a,onCloneProvider:o,onQuickSetup:s,onEditVisualProvider:c}){let{t:u}=l(),[d,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(!0),[g,_]=(0,J.useState)(``),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(null),[S,C]=(0,J.useState)(``),[w,T]=(0,J.useState)(Wi),O=(0,J.useCallback)(async()=>{try{p(await f(`/api/visual/models`)),C(``)}catch(e){C(e instanceof Error?e.message:String(e))}finally{h(!1)}},[]);(0,J.useEffect)(()=>{O()},[O,e]),(0,J.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)}},N=e=>{T(e),r.setItem(Ui,e?`1`:`0`)},P=e.providers.filter(e=>e.type===`visual`),F=P.filter(e=>e.configured||e.custom),ne=d?.imageModels||[],re=d?.videoModels||[];return(0,Y.jsxs)(`section`,{className:`mt-3`,children:[(0,Y.jsxs)(tr,{className:`mb-3 py-3.5`,"data-config-card":`models-visual`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:R(`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,Y.jsx)(ge,{size:18})}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-content-muted`,children:u(`config:configPage.currentVisualModel`)}),m?(0,Y.jsxs)(`span`,{role:`status`,className:`flex items-center gap-2 text-xs text-content-muted`,children:[(0,Y.jsx)(z,{className:`size-3.5`}),u(`config:configPage.loadingVisualStatus`)]}):d?.image?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`truncate text-sm font-medium text-content`,children:[d.image.providerName,` / `,d.image.name]}),(0,Y.jsxs)(rr,{tone:`green`,children:[(0,Y.jsx)(A,{size:11,className:`mr-[3px] inline`}),u(`config:configPage.authenticationReady`)]})]}),d.video&&(0,Y.jsxs)(`small`,{className:`text-xs text-content-muted [overflow-wrap:anywhere]`,children:[u(`config:configPage.visualVideoModel`),`:`,d.video.providerName,` /`,` `,d.video.name]})]}):(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-warning-strong`,children:[(0,Y.jsx)(k,{size:14,"aria-hidden":`true`}),u(`config:configPage.visualNoneConfigured`)]}),(0,Y.jsx)(`small`,{className:`text-xs text-content-muted`,children:u(`config:configPage.visualEmptyHint`)})]})]}),(0,Y.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,Y.jsxs)(B,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:v,onClick:()=>void M(),children:[v?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(ee,{size:13}),u(v?`config:configPage.testingGeneration`:`config:configPage.testGeneration`)]}),(0,Y.jsxs)(B,{className:`max-[650px]:h-11`,onClick:s,children:[(0,Y.jsx)(te,{size:13}),u(`config:configPage.visualQuickSetup`)]})]})]}),b&&(0,Y.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,Y.jsx)(`img`,{src:b.previewDataUrl,alt:b.modelName,className:`size-11 flex-none rounded-xs object-cover`}):(0,Y.jsx)(E,{size:16,className:`flex-none text-success`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-px text-xs`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-success-strong`,children:u(`config:configPage.testSucceeded`)}),(0,Y.jsxs)(`span`,{className:`truncate font-mono text-content-muted`,children:[b.providerName,` / `,b.modelName,` · `,b.path]})]})]})]}),(0,Y.jsxs)(je,{open:w,onOpenChange:N,children:[(0,Y.jsx)(Ae,{asChild:!0,children:(0,Y.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,Y.jsx)(D,{size:16,"aria-hidden":`true`,className:`flex-none text-content-muted transition-transform group-data-[state=closed]:-rotate-90`}),(0,Y.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-content`,children:u(`config:configPage.visualConnections`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:u(`config:configPage.visualConnectionsHint`)})]})}),(0,Y.jsx)(ke,{children:(0,Y.jsxs)(tr,{className:`mt-2 py-4`,children:[(0,Y.jsx)(Hi,{providers:P,toggling:n,onClone:o,onConfigure:e=>c(e.id),onToggle:i,onDelete:a}),F.length===0&&(0,Y.jsx)(`p`,{className:`text-xs text-content-muted`,children:u(`config:configPage.visualEmptyHint`)}),(ne.length>0||re.length>0)&&(0,Y.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 border-t border-stroke-soft pt-3`,children:[ne.length>0&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-16 flex-none text-xs text-content-muted`,children:u(`config:configPage.visualImageModel`)}),(0,Y.jsxs)(q,{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,Y.jsx)(`option`,{value:``,children:u(`config:configPage.visualAutoSelected`)}),ne.map(e=>(0,Y.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),re.length>0&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-16 flex-none text-xs text-content-muted`,children:u(`config:configPage.visualVideoModel`)}),(0,Y.jsxs)(q,{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,Y.jsx)(`option`,{value:``,children:u(`config:configPage.visualAutoSelected`)}),re.map(e=>(0,Y.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),(0,Y.jsx)(`small`,{className:`text-xs text-content-muted`,children:u(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]})]})})]}),S&&(0,Y.jsx)(`div`,{className:`mt-2.5`,children:(0,Y.jsxs)(Nt,{children:[(0,Y.jsx)(ye,{size:13}),S]})})]})}var Ki=`pisper.config.manageConnectionsOpen`;function qi(){let e=r.getItem(Ki);return e===`1`||e!==`0`&&null}function Ji({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,J.useState)(``),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(()=>u||e?!0:qi());(0,J.useEffect)(()=>{u&&v(!0)},[u]),(0,J.useEffect)(()=>{e&&v(!0)},[e,n]);let y=Bi({notify:i,requestConfirm:o,t:s}),{config:b}=y,x=Vi({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(Bt(a,()=>m({providerType:`chat`})),!b)return y.error&&!y.loading?(0,Y.jsx)(ht,{kind:`error`,title:s(`config:providerWorkbench.loadFailed`),description:y.error,action:(0,Y.jsx)(B,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void y.reload(),children:s(`common:pageTemplate.retry`)})}):(0,Y.jsx)(ht,{kind:`loading`,title:s(`config:configPage.loadingModelCatalog`),description:s(`config:configPage.readingProvidersAndAuthenticationStatus`)});let S=_??!1,C=yi(x.discovery),w=e=>{v(e),r.setItem(Ki,e?`1`:`0`)},T=e=>g(e);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ni,{config:b,notify:i,busy:!!(y.settingDefault||y.toggling),onConfigChanged:y.applyConfig,onSetDefaultModel:y.setDefaultChatModel}),(0,Y.jsx)(Ii,{config:b,notify:i,busy:!!(y.settingDefault||y.toggling),onConfigChanged:y.applyConfig}),(0,Y.jsx)(Ri,{notify:i}),(0,Y.jsx)(pi,{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,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,role:`status`,children:[x.discovering&&(0,Y.jsx)(z,{className:`size-3`}),x.discovering?s(`config:providerWorkbench.scanningLocal`):s(`config:providerWorkbench.localImportStatus`,{imported:x.autoImport.imported,skipped:x.autoImport.skipped})]})}),y.error&&(0,Y.jsx)(G,{children:y.error}),C>0&&(0,Y.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-2 gap-y-0 text-xs text-content-muted`,children:[(0,Y.jsx)(`span`,{children:s(`config:configPage.localProviderImportHint`,{count:C})}),(0,Y.jsx)(B,{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,Y.jsxs)(je,{open:S,onOpenChange:w,"data-config-card":`models-advanced`,children:[(0,Y.jsx)(Ae,{asChild:!0,children:(0,Y.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,Y.jsx)(D,{size:16,"aria-hidden":`true`,className:`shrink-0 text-content-muted transition-transform group-data-[state=closed]:-rotate-90`}),(0,Y.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-content`,children:s(`config:providerWorkbench.advanced`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:s(`config:providerWorkbench.advancedHint`)})]})}),(0,Y.jsxs)(ke,{id:`model-connection-management`,children:[(0,Y.jsx)(Ei,{discovery:x.discovery,discovering:x.discovering,error:x.error||x.operationError,importing:x.importing,forceVisible:u,onRefresh:x.refresh,onImport:x.importProvider}),(0,Y.jsx)(Gi,{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,Y.jsx)(Oi,{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,Y.jsx)(vi,{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 Yi=[`browser`,`feishu`,`weixin`,`qq`,`telegram`];function Xi(e){if(!e||typeof e!=`object`||Array.isArray(e))throw d();return e}function Zi(e,t){if(typeof e!=`string`||e.length>t)throw d();return e}function Qi(e){let t=Xi(e),n=Xi(t.browser);if(typeof n.enabled!=`boolean`||!Array.isArray(t.templates)||!Array.isArray(t.scopes))throw d();let r={},i=Xi(t.connections);for(let e of Yi){if(e===`browser`||i[e]===void 0)continue;let t=i[e];if(t===null){r[e]=null;continue}let n=Xi(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=Xi(e),n=Zi(t.id,200);if(!n||a.has(n)||typeof t.enabled!=`boolean`||!Array.isArray(t.variables))throw d();a.add(n);let r={},i=Xi(t.channels);for(let e of Yi){if(i[e]===void 0)continue;let t=Xi(i[e]);if(t.enabled!==void 0&&typeof t.enabled!=`boolean`)throw d();r[e]={content:Zi(t.content,12e3),...t.enabled===void 0?{}:{enabled:t.enabled}}}return{id:n,name:Zi(t.name,500),description:Zi(t.description,2e3),enabled:t.enabled,variables:t.variables.map(e=>Zi(e,200)),channels:r}}),s=t.scopes.map(e=>{let t=Xi(e);if(!Yi.includes(t.platform))throw d();return{...t,platform:t.platform}});return{browser:{enabled:n.enabled},connections:r,scopes:s,templates:o}}function $i(e){let t=Xi(e);if(typeof t.sent!=`number`||!Number.isInteger(t.sent)||t.sent<0)throw d();return{sent:t.sent,...t.title===void 0?{}:{title:Zi(t.title,2e3)},...t.body===void 0?{}:{body:Zi(t.body,12e3)},...t.preview===void 0?{}:{preview:Zi(t.preview,12e3)}}}function ea(e){return e.templates.length>0&&e.templates.every(e=>Yi.every(t=>typeof e.channels[t]?.enabled==`boolean`))}var ta=(e,t)=>`/api/settings/notifications/templates/${encodeURIComponent(e)}/${t}`,na=(e,t,n,r)=>u(ta(e,t),{method:`PUT`,body:n,...r,parse:Qi}),ra={load:(e={})=>u(`/api/settings/notifications`,{...e,parse:Qi}),setBrowserEnabled:(e,t={})=>u(`/api/settings/notifications/browser`,{method:`PATCH`,body:{enabled:e},...t,parse:Qi}),setEventEnabled:(e,t,n={})=>na(e,`browser`,{enabled:t},n),setChannelEnabled:async(e,t,n,r={})=>{let i=await na(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={})=>na(e,t,{content:n},r),testSavedTemplate:(e,t,n={})=>u(`${ta(e,t)}/test`,{method:`POST`,body:{},...n,parse:$i})},ia=e=>e instanceof Error?e.message:String(e),aa=(e,t)=>`${e}\0${t}`,oa=e=>e.kind===`browser`?`browser`:e.kind===`event`?`event:${e.event}`:`channel:${e.event}:${e.platform}`;function sa(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 ca(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 la(e){let[t,n]=(0,J.useState)(null),r=(0,J.useRef)(null),i=(0,J.useRef)(e);i.current=e;let[a,o]=(0,J.useState)(!0),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)({}),[f,p]=(0,J.useState)({}),m=(0,J.useRef)({}),[h,g]=(0,J.useState)({}),[_,v]=(0,J.useState)({}),y=(0,J.useRef)(!1),b=(0,J.useRef)(null),x=(0,J.useRef)(new Map),S=(0,J.useRef)(new Map),C=(0,J.useRef)(new Set),w=(0,J.useRef)(0),T=(0,J.useRef)(0),E=(0,J.useCallback)(e=>{r.current=e,T.current++,n(e),i.current?.(e)},[]),D=(0,J.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 ra.load({signal:e.signal});y.current&&!e.signal.aborted&&t===T.current&&E(n)}catch(t){y.current&&!e.signal.aborted&&c(ia(t))}finally{y.current&&!e.signal.aborted&&o(!1)}},[E]);(0,J.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=oa(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(sa(r.current,e)!==t.value||C.current.has(n)){let i={signal:a.signal},o=e.kind===`browser`?await ra.setBrowserEnabled(t.value,i):e.kind===`event`?await ra.setEventEnabled(e.event,t.value,i):await ra.setChannelEnabled(e.event,e.platform,t.value,i);if(!y.current||a.signal.aborted)return;E(ca(r.current,e,sa(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:ia(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=ca(k,e.target,e.value));let A=(e,t,n)=>{let r=aa(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=aa(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?ea(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=aa(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 ra.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:ia(e)}})),!1}finally{x.current.get(i)===o&&x.current.delete(i)}},testTemplate:async(e,t)=>{let n=aa(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 ra.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:ia(e)}}))}finally{x.current.get(r)===i&&x.current.delete(r)}}}}function ua(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,J.useRef)(!0),[f,p]=(0,J.useState)(``);(0,J.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let m=t.find(e=>e.id===n)||t[0];if(!m||!e.data)return(0,Y.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,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h2`,{className:`text-[15px] leading-6 font-medium text-content`,children:u(`config:notificationSettings.notificationTemplates`)}),(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[u(`config:notificationSettings.notificationEvent`),(0,Y.jsx)(q,{"aria-label":u(`config:notificationSettings.notificationEvent`),value:m.id,onChange:e=>i(e.target.value,r),children:t.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,Y.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[u(`config:notificationSettings.notificationChannel`),(0,Y.jsx)(q,{"aria-label":u(`config:notificationSettings.notificationChannel`),value:r,onChange:e=>{let t=Yi.find(t=>t===e.target.value);t&&i(m.id,t)},children:Yi.map(e=>(0,Y.jsx)(`option`,{value:e,children:a(e)},e))})]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-content-muted`,children:m.description}),(0,Y.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[u(`config:notificationSettings.messageContent`),(0,Y.jsx)(wt,{"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,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-content-muted`,children:[(0,Y.jsx)(`span`,{children:u(`config:notificationSettings.availableVariables`)}),m.variables.map(e=>(0,Y.jsx)(`code`,{className:`rounded-xs bg-inline-code px-1.5 py-0.5 font-mono text-content-secondary`,children:`{{${e}}}`},e))]}),(0,Y.jsxs)(`div`,{className:`rounded-md border border-stroke bg-code p-3`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-content-muted`,children:u(`config:notificationSettings.preview`)}),(0,Y.jsx)(`pre`,{className:`mt-2 font-sans text-sm break-words whitespace-pre-wrap text-content`,children:ua(h.content,u)})]}),(0,Y.jsx)(`p`,{className:`text-xs text-content-muted`,children:h.dirty?u(`config:notificationSettings.saveBeforeTest`):u(`config:notificationSettings.testUsesSavedTemplate`)}),!_&&(0,Y.jsx)(`p`,{role:`status`,className:`text-xs text-content-muted`,children:u(`config:notificationSettings.channelTestUnavailable`)}),(h.save.error||h.test.error||f)&&(0,Y.jsx)(Nt,{children:h.save.error||h.test.error||f}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,Y.jsx)(B,{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,Y.jsx)(B,{"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 fa(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 pa(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 ma(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 ha(){return typeof window<`u`&&window.pisperDesktop?.showNotification?window.pisperDesktop.getNotificationStatus?`checking`:`granted`:typeof window<`u`&&Zt()?`checking`:sn()}function ga(e,t){return t(e===`system-disabled`||e===`app-disabled`?`config:notificationSettings.systemNotificationsAreOffAllowPisperToSendNotificationsInYourOperatingSystemSettings`:e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.theOperatingSystemDidNotAcceptTheNotificationCheckYourSystemNotificationSettings`)}function _a(e){return e instanceof Error?e.message:String(e)}function va({notify:e,onBrowserNotificationChange:t}){let{t:r,language:i}=l(),a=(0,J.useRef)(!1);(0,J.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let o=la(t),{data:s,loading:c,loadError:u}=o,[d,f]=n(),p=!!window.pisperDesktop?.showNotification,m=Zt(),[h,g]=(0,J.useState)(ha),_=o.mutations.browser?.pending===!0,v=(0,J.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,J.useEffect)(()=>{if(!p)return;v();let e=()=>{v()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[p,v]);let y=(0,J.useCallback)(async()=>{if(!(p||!m))try{let e=await qt();if(!a.current)return;g(e===!0?`granted`:e===!1?`denied`:`default`)}catch{a.current&&g(`unsupported`)}},[p,m]);(0,J.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=ga(`system-disabled`,r);else if(!p&&m){let e=`denied`;try{let t=await qt()===!0?`granted`:await Yt();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 on();if(!a.current)return;if(g(e),e!==`granted`)n=r(e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`);else try{await an()}catch{n=r(`config:notificationSettings.theBrowserBackgroundNotificationServiceCouldNotBeRegistered`)}}}a.current&&(await o.setBrowserEnabled(t),n&&a.current&&e(n,`info`))},x=(0,J.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(ga(i.reason,r));return i}return m?(await Ht(e,t),{shown:!0,transport:`tauri`}):rn({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`?ga(`unsupported`,r):p?ga(`system-disabled`,r):r(`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`),`error`);return}try{await x(r(`config:notificationSettings.appNotificationTest`,{app:Se}),r(`config:notificationSettings.notificationsAreWorking`)),e(r(`config:notificationSettings.theTestNotificationWasSentCheckYourSystemNotificationCenter`),`info`)}catch(t){e(_a(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,Y.jsxs)(Lt,{children:[(0,Y.jsx)(z,{className:`size-6`}),(0,Y.jsx)(`h2`,{children:r(`config:notificationSettings.loadingNotificationSettings`)})]});if(!s)return(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(Nt,{children:u}),(0,Y.jsx)(B,{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:pa(e.id,e.name,r),description:ma(e.id,e.description,r)}));if(E)return(0,Y.jsxs)(`div`,{"data-config-card":`notifications-templates`,className:`space-y-4`,children:[(0,Y.jsxs)(B,{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,Y.jsx)(O,{size:16,"aria-hidden":`true`}),r(`config:notificationSettings.backToCategories`)]}),(0,Y.jsx)(da,{settings:o,templates:D,eventId:d.get(`event`)||``,platform:Yi.find(e=>e===d.get(`channel`))||`browser`,onSelectionChange:T,platformLabel:e=>fa(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,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[u&&(0,Y.jsx)(Nt,{children:u}),Object.entries(o.mutations).filter(([,e])=>e.error).map(([e,t])=>(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(Nt,{children:t.error}),(0,Y.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>void o.retryMutation(t),children:r(`common:pageTemplate.retry`)})]},e)),(0,Y.jsxs)(tr,{className:`browser-notification-card py-4`,"data-config-card":`notifications-browser`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:R(`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,Y.jsx)(C,{size:18}):(0,Y.jsx)(cn,{size:18})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium text-content`,children:r(`config:notificationSettings.systemNotificationChannel`)}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs leading-[1.45] text-content-muted`,children:r(`config:notificationSettings.pisperUsesTheCurrentPlatformNotificationSystemWhenAnAgentCompletesOrFails`)})]}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[(0,Y.jsx)(rr,{tone:A,children:k}),(0,Y.jsx)(ir,{ariaLabel:r(`config:notificationSettings.systemNotificationChannel`),value:s.browser.enabled,disabled:_||h===`checking`,onChange:b})]})]}),(0,Y.jsxs)(Mt,{children:[(0,Y.jsx)(he,{size:15}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{children:r(p?`config:notificationSettings.controlledByOperatingSystemNotificationSettings`:`config:notificationSettings.controlledByBrowserSitePermissions`)}),(0,Y.jsx)(`small`,{children:r(p?`config:notificationSettings.theDesktopAppUsesOperatingSystemNotificationsTurningThisOffDoesNotChangeTheOperatingSystemPermis`:`config:notificationSettings.theWebAppUsesBrowserSiteNotificationsTurningThisOffDoesNotChangeTheBrowserPermissionItself`)})]})]}),(0,Y.jsxs)(`div`,{className:`mt-4 flex gap-2 max-[650px]:flex-wrap`,children:[p&&h===`denied`&&(0,Y.jsxs)(B,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:w,children:[(0,Y.jsx)(he,{size:14}),r(`config:notificationSettings.openSystemNotificationSettings`)]}),(0,Y.jsxs)(B,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:!s.browser.enabled||_||h!==`granted`,onClick:S,children:[(0,Y.jsx)(C,{size:14}),r(`config:notificationSettings.sendTestNotification`)]})]})]}),(0,Y.jsxs)(Lr,{title:r(`config:notificationSettings.notificationCategories`),description:r(`config:notificationSettings.channelPreferenceHint`),action:(0,Y.jsx)(B,{variant:`ghost`,size:`sm`,className:`pointer-coarse:h-11`,onClick:()=>T(),children:r(`config:notificationSettings.editNotificationTemplates`)}),children:[!o.supportsChannels&&(0,Y.jsx)(`p`,{role:`status`,className:`py-2 text-sm text-content-muted`,children:r(`config:notificationSettings.channelPreferencesUnsupported`)}),D.length>0&&(0,Y.jsx)(ar,{children:D.map(e=>{let t=e.enabled?Yi.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,Y.jsx)(Rr,{"data-notification-event":e.id,title:e.name,description:e.description,control:(0,Y.jsxs)(Ve,{children:[(0,Y.jsx)(ze,{asChild:!0,children:(0,Y.jsx)(B,{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,Y.jsx)(`span`,{className:`max-w-64 truncate`,children:t.length?t.map(e=>fa(e,r)).join(i===`zh-CN`?`、`:`, `):r(`config:notificationSettings.channelsOff`)})})}),(0,Y.jsxs)(Be,{align:`end`,className:`max-w-[calc(100vw-40px)] min-w-56`,children:[(0,Y.jsx)(Re,{checked:e.enabled,onCheckedChange:t=>void o.setEventEnabled(e.id,t===!0),children:r(`config:notificationSettings.enableEvent`)}),(0,Y.jsx)(Ie,{}),Yi.map(t=>{let n=t===`browser`?s.browser.enabled:s.connections[t]?.enabled===!0&&s.scopes.some(e=>e.platform===t);return(0,Y.jsxs)(Re,{checked:e.channels[t]?.enabled!==!1,disabled:!o.supportsChannels,onCheckedChange:n=>void o.setChannelEnabled(e.id,t,n===!0),children:[(0,Y.jsx)(`span`,{children:fa(t,r)}),!n&&(0,Y.jsx)(`small`,{className:`ml-2 text-muted-foreground`,children:r(`config:notificationSettings.channelNeedsSetup`)})]},t)}),(0,Y.jsx)(Ie,{}),(0,Y.jsx)(Le,{onSelect:()=>T(e.id),children:r(`config:notificationSettings.editNotificationTemplates`)})]})]})},e.id)})}),!D.length&&(0,Y.jsx)(`p`,{role:`status`,className:`py-3 text-sm text-content-muted`,children:r(`config:notificationSettings.noNotificationEvents`)})]})]})}function ya({notify:e}){let{t}=l(),n=window.pisperDesktop,[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``);(0,J.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,Y.jsxs)(W,{"data-config-card":`updates-cli`,title:t(`config:cliSettings.title`),description:t(`config:cliSettings.description`),actions:(0,Y.jsx)(`span`,{className:`text-xs text-content-secondary`,children:m}),children:[r&&(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3 border-t border-stroke py-3`,children:[r.installed&&!r.needsRepair?(0,Y.jsx)(A,{className:`mt-0.5 shrink-0 text-content-muted`,size:16,"aria-hidden":`true`}):(0,Y.jsx)(wn,{className:`mt-0.5 shrink-0 text-content-muted`,size:16,"aria-hidden":`true`}),(0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-0.5`,children:[(0,Y.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,Y.jsx)(`small`,{className:`font-mono text-xs [overflow-wrap:anywhere] text-content-muted`,children:r.installPath}),r.installed&&(0,Y.jsx)(`small`,{className:`text-xs text-content-muted`,children:r.pathConfigured?t(`config:cliSettings.pathConfigured`):t(`config:cliSettings.pathNeedsRepair`)})]})]}),s&&(0,Y.jsx)(G,{children:s}),u&&(0,Y.jsxs)(`div`,{className:`mt-3 flex gap-2 max-[650px]:flex-wrap`,children:[r?.installed&&(0,Y.jsxs)(B,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:!!a,onClick:()=>void f(),children:[a===`uninstall`?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(ve,{size:14}),t(`config:cliSettings.uninstall`)]}),(!r?.installed||r.needsRepair)&&(0,Y.jsxs)(B,{type:`button`,className:`max-[650px]:h-11`,disabled:!!a||p||r?.supported===!1,onClick:()=>void d(),children:[a===`install`?(0,Y.jsx)(z,{className:`text-current`}):r?.needsRepair?(0,Y.jsx)(be,{size:14}):(0,Y.jsx)(N,{size:14}),r?.needsRepair?t(`config:cliSettings.repair`):t(`config:cliSettings.install`)]})]}),u&&(0,Y.jsx)(`small`,{className:`mt-2 block text-xs text-content-muted`,children:t(`config:cliSettings.restartTerminal`)})]})}var ba=`0.6.10`;function xa(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 Sa(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 Ca({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,J.useState)({version:ba,date:``,notes:``}),[f,p]=(0,J.useState)(``);(0,J.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,J.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,Y.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col`,children:[(0,Y.jsxs)(W,{"data-config-card":`updates-main`,className:`mt-6`,title:n(`config:updateSettings.pisperAppUpdates`),actions:(0,Y.jsx)(`span`,{"data-update-status":D,className:`text-xs text-content-secondary tabular-nums`,children:M}),children:[(0,Y.jsxs)(`dl`,{className:`grid border-y border-stroke max-sm:divide-y max-sm:divide-stroke-soft sm:grid-cols-3`,children:[(0,Y.jsxs)(`div`,{className:`py-3 sm:pr-4`,children:[(0,Y.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(c?`config:updateSettings.currentVersion`:`config:updateSettings.currentSource`)}),(0,Y.jsx)(`dd`,{className:`mt-1 font-mono text-[12.5px] font-medium text-content`,children:O})]}),(0,Y.jsxs)(`div`,{className:`py-3 sm:border-l sm:border-stroke-soft sm:px-4`,children:[(0,Y.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(`config:updateSettings.platform`)}),(0,Y.jsx)(`dd`,{className:`mt-1 text-sm font-medium text-content`,children:xa(i,n)})]}),(0,Y.jsxs)(`div`,{className:`py-3 sm:border-l sm:border-stroke-soft sm:pl-4`,children:[(0,Y.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(`config:updateSettings.updateChannel`)}),(0,Y.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,Y.jsx)(G,{children:a.message}):(0,Y.jsxs)(`p`,{className:`mt-4 flex items-start gap-2 text-sm text-content-secondary`,children:[(0,Y.jsx)(pn,{className:`mt-0.5 shrink-0 text-content-muted`,size:15,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0`,children:a.message})]})),C&&(0,Y.jsx)(`small`,{className:`mt-2 block text-xs text-content-muted`,children:n(`config:updateSettings.downloadedDataWasPreservedAndCanResumeFromTheInterruptionPoint`)}),E&&(0,Y.jsxs)(`div`,{className:`mt-4`,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between text-xs text-content-muted`,children:[(0,Y.jsx)(`span`,{children:n(`config:updateSettings.downloadProgress`)}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[Math.round(a.percent||0),`% · `,Sa(a.transferred,r),` /`,` `,Sa(a.total,r)]})]}),(0,Y.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-surface-active`,children:(0,Y.jsx)(`i`,{className:`block h-full bg-star transition-[width]`,style:{width:`${a.percent||0}%`}})})]}),(0,Y.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Y.jsxs)(B,{className:`max-[650px]:h-11`,disabled:T||E||!!f,onClick:w?v:S||C?_:m,children:[T||E?(0,Y.jsx)(z,{className:`text-current`}):w?(0,Y.jsx)(de,{size:14}):S||C?a.canDownload?(0,Y.jsx)(N,{size:14}):(0,Y.jsx)(F,{size:14}):(0,Y.jsx)(ue,{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,Y.jsxs)(B,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:h,children:[(0,Y.jsx)(F,{size:14}),c?`GitHub Releases`:`GitHub Compare`]}),o&&(0,Y.jsxs)(B,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:g,children:[(0,Y.jsx)(F,{size:14}),n(`config:updateSettings.viewUpdateDiagnosticLog`)]})]})]}),!s&&(0,Y.jsx)(W,{"data-config-card":`updates-components`,title:n(`config:updateSettings.appComponents`),children:(0,Y.jsx)(U,{children:j.map(e=>{let t=e.component===`desktop`?pn:e.component===`tui`?_e:dn,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,Y.jsx)(H,{icon:(0,Y.jsx)(t,{}),name:i,description:e.message||void 0,meta:(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono tabular-nums`,children:[(0,Y.jsxs)(`span`,{children:[`v`,e.currentVersion]}),e.availableVersion&&e.availableVersion!==e.currentVersion&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{size:12,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[`v`,e.availableVersion]})]}),e.size>0&&e.state===`available`&&(0,Y.jsx)(`span`,{className:`font-sans`,children:Sa(e.size,r)})]}),status:a},e.component)})})}),!s&&(0,Y.jsx)(ya,{notify:e}),(0,Y.jsx)(W,{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,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-xs text-content-muted`,children:[(0,Y.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,Y.jsx)(`div`,{className:`border-t border-stroke pt-3`,children:(0,Y.jsx)(kt,{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`about`:return e(`config:settingsShell.lede.about`);default:return e(`config:settingsShell.lede.models`)}}function Ta({notify:e,registerPrimaryAction:t,invokePrimaryAction:n,section:r,onBackToFeatures:i,onBrowserNotificationChange:a,requestConfirm:o,update:s,renderInterfaceSettings:c}){let{t:u}=l(),d=tt(r);if(r===`remote-access`||r===`mobile-server`||r===`desktop-pet`)return(0,Y.jsx)(Fr,{section:r,notify:e,requestConfirm:o,onBack:i});let f=re(r)?r:`models`,p;if(f===`notifications`)p=(0,Y.jsx)(va,{notify:e,onBrowserNotificationChange:a});else if(f===`interface`){let t=(0,Y.jsx)(Yr,{notify:e,defaultAdvancedExpanded:d?.expandGroup===`interface-advanced`,navigationKey:d?.navigationKey});p=c?c(t):t}else p=f===`shortcuts`?(0,Y.jsx)(Xr,{requestConfirm:o}):f===`updates`?(0,Y.jsx)(Ca,{notify:e,update:s}):f===`about`?(0,Y.jsx)(dr,{update:s,notify:e}):(0,Y.jsx)(Ji,{defaultAdvancedExpanded:d?.expandGroup===`models-advanced`,navigationKey:d?.navigationKey,notify:e,registerPrimaryAction:t,requestConfirm:o});let m=u(`navigation:pageHeader.quickSetup`);return(0,Y.jsx)(Dt,{"data-settings-page":f,title:ie(u,f),description:wa(u,f),toolbar:f===`models`?(0,Y.jsx)(Ot,{actions:(0,Y.jsxs)(B,{variant:`outline`,"data-settings-quick-setup":!0,onClick:n,children:[(0,Y.jsx)(le,{className:`size-4`,"aria-hidden":`true`}),m]})}):void 0,children:(0,Y.jsx)(`div`,{"data-config-card":nt,className:`mt-6 min-w-0 max-[650px]:mt-3`,children:p})})}export{Ta as ConfigPage};
5
+ `);b(Object.fromEntries(Pi.map((t,n)=>[t,e[n]]).filter(([,e])=>e)))},[v]),(0,J.useEffect)(()=>{let e=!0;return Fi.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:`${Tt(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 Fi.saveModelTiers(o)),t(i(`config:subagents.tiersSaved`))}catch(e){b(a),f(e instanceof Error?e.message:String(e))}finally{u(!1)}},w=p?.profiles||[],T=p?.errors||[];return(0,Y.jsxs)(`section`,{"aria-labelledby":`${s}-heading`,"aria-busy":c||void 0,"data-config-card":`models-subagents`,"data-config-target":`models-subagents`,className:`mt-6 min-w-0`,children:[(0,Y.jsx)(`h2`,{id:`${s}-heading`,className:`text-sm font-medium text-content`,children:i(`config:subagents.title`)}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-content-muted`,children:i(`config:subagents.hint`)}),(0,Y.jsx)(`div`,{className:`mt-3 border-t border-stroke`,children:Pi.map(e=>{let t=y[e]||``;return(0,Y.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,Y.jsxs)(`div`,{className:`min-w-[min(240px,100%)] flex-1`,children:[(0,Y.jsxs)(`div`,{id:`${s}-${e}`,className:`text-sm text-content`,children:[a(e),(0,Y.jsx)(`code`,{className:`ml-2 font-mono text-xs text-content-muted`,children:e})]}),(0,Y.jsx)(`p`,{id:`${s}-${e}-hint`,className:`mt-0.5 text-xs text-content-muted`,children:o(e)})]}),(0,Y.jsx)(`div`,{className:`w-[min(280px,100%)] min-w-0 max-[650px]:w-full`,children:(0,Y.jsxs)(q,{"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,Y.jsx)(`option`,{value:``,children:i(`config:subagents.followSession`)}),t&&!S.some(e=>e.value===t)&&(0,Y.jsx)(`option`,{value:t,children:t}),S.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})})]},e)})}),d&&(0,Y.jsx)(G,{children:d}),(0,Y.jsx)(`h3`,{className:`mt-5 text-[13px] font-medium text-content`,children:i(`config:subagents.globalDefinitions`)}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-content-muted`,children:i(`config:subagents.definitionsHint`)}),p===null?(0,Y.jsxs)(`p`,{role:`status`,className:`mt-3 flex items-center gap-2 text-xs text-content-muted`,children:[(0,Y.jsx)(z,{className:`size-3`}),i(`config:subagents.loading`)]}):w.length===0&&T.length===0?(0,Y.jsx)(`p`,{className:`mt-3 text-xs text-content-muted`,children:i(`config:subagents.empty`)}):(0,Y.jsxs)(`ul`,{className:`mt-3 flex min-w-0 flex-col border-t border-stroke`,children:[w.map(e=>(0,Y.jsxs)(`li`,{className:`min-w-0 border-b border-stroke py-2 text-[13px]`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`code`,{className:`shrink-0 font-mono text-content`,children:e.name}),(0,Y.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,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-content-secondary`,children:e.description})]},e.name)),T.map(e=>(0,Y.jsxs)(`li`,{className:`min-w-0 border-b border-stroke py-2 text-[13px]`,children:[(0,Y.jsx)(`code`,{className:`font-mono text-danger`,children:e.file||e.scope}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-danger`,children:e.message})]},`${e.scope}:${e.file}`))]}),h&&(0,Y.jsx)(G,{children:h})]})}function Li(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)||e}function Ri({notify:e}){let{t}=l(),n=(0,J.useId)(),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(!1),[u,d]=(0,J.useState)(`allow`),[f,p]=(0,J.useState)(`bash`),[m,h]=(0,J.useState)(``);(0,J.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,Y.jsxs)(`section`,{"aria-labelledby":`${n}-heading`,"data-config-card":`models-permission-rules`,"data-config-target":`models-permission-rules`,className:`mt-6 min-w-0`,children:[(0,Y.jsx)(`h2`,{id:`${n}-heading`,className:`text-sm font-medium text-content`,children:t(`config:permissionRules.title`)}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-content-muted`,children:t(`config:permissionRules.hint`)}),r===null?(0,Y.jsxs)(`p`,{role:`status`,className:`mt-3 flex items-center gap-2 text-xs text-content-muted`,children:[(0,Y.jsx)(z,{className:`size-3`}),t(`config:permissionRules.loading`)]}):r.length===0?(0,Y.jsx)(`p`,{className:`mt-3 text-xs text-content-muted`,children:t(`config:permissionRules.empty`)}):(0,Y.jsx)(`ul`,{className:`mt-3 flex min-w-0 flex-col border-t border-stroke`,children:r.map(e=>(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 border-b border-stroke py-2 text-[13px]`,children:[(0,Y.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,Y.jsx)(`span`,{className:`shrink-0 text-xs text-content-muted`,children:e.tool===`files`?t(`config:permissionRules.files`):t(`config:permissionRules.command`)}),(0,Y.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-content`,title:e.pattern,children:e.pattern}),(0,Y.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate text-xs text-content-muted`,title:e.cwd||void 0,children:e.cwd?Li(e.cwd):t(`config:permissionRules.global`)}),(0,Y.jsx)(B,{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,Y.jsx)(ve,{})})]},e.id))}),(0,Y.jsxs)(`form`,{className:`mt-3 flex min-w-0 flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,Y.jsxs)(q,{"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,Y.jsx)(`option`,{value:`allow`,children:t(`config:permissionRules.allow`)}),(0,Y.jsx)(`option`,{value:`deny`,children:t(`config:permissionRules.deny`)})]}),(0,Y.jsxs)(q,{"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,Y.jsx)(`option`,{value:`bash`,children:t(`config:permissionRules.command`)}),(0,Y.jsx)(`option`,{value:`files`,children:t(`config:permissionRules.files`)})]}),(0,Y.jsx)(V,{"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,Y.jsxs)(B,{type:`submit`,variant:`secondary`,disabled:s||!m.trim(),className:`max-[650px]:min-h-11`,children:[s&&(0,Y.jsx)(z,{className:`size-3`}),t(`config:permissionRules.add`)]})]}),a&&(0,Y.jsx)(G,{children:a})]})}function zi(e){return e instanceof Error?e.message:String(e)}function Bi({notify:e,requestConfirm:t,t:n}){let[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(!0),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(``),[d,p]=(0,J.useState)(``),[m,h]=(0,J.useState)(``),[g,_]=(0,J.useState)(``),v=(0,J.useRef)(0),y=(0,J.useRef)(!1);(0,J.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(zi(n)),o(!1))}),()=>{e=!1,y.current=!1,v.current+=1}},[]);let b=(0,J.useCallback)(e=>{v.current+=1,i(e),o(!1),c(``)},[]),x=(0,J.useCallback)(async()=>{let e=v.current,t=await f(`/api/config`);y.current&&v.current===e&&b(t)},[b]),S=(0,J.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(zi(e))}finally{u(``)}},[b,e,n]),C=(0,J.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(zi(e))}finally{p(``)}},[b,e,n]),w=(0,J.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(zi(e))}finally{h(``)}},[b,e,n]),T=(0,J.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(zi(e))}finally{p(``)}},[b,e,n]),E=(0,J.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(zi(e))}finally{y.current&&o(!1)}},[b]),D=(0,J.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 ni.deleteModel(r.id,i.id)),e(n(`providers:modelEditor.deleted`))}catch(e){c(zi(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,J.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(zi(e))}}},[b,e,t,n]),deleteModel:D}}function Vi({requestConfirm:e,onImported:t,onAutoImported:n,t:r}){let[i,a]=(0,J.useState)({providers:[],errors:[]}),[o,s]=(0,J.useState)(!0),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(``),[p,m]=(0,J.useState)(``),[h,g]=(0,J.useState)({imported:0,skipped:0}),_=(0,J.useRef)(0),v=(0,J.useRef)(n);v.current=n;let y=(0,J.useCallback)(async()=>{let e=++_.current;s(!0),l(``);try{let t=await ni.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(zi(t))}finally{e===_.current&&s(!1)}},[]);return(0,J.useEffect)(()=>(y(),()=>{_.current+=1}),[y]),{discovery:i,autoImport:h,discovering:o,error:c,operationError:u,importing:p,refresh:y,importProvider:(0,J.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(zi(e))}finally{m(``)}}},[t,e,r])}}function Hi({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,Y.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:p.map(e=>{let l=ti[e.id]||me,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,Y.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,Y.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,Y.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,Y.jsx)(l,{size:15})}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),p&&(0,Y.jsx)(jt,{variant:`accent`,children:f(`config:configPage.defaultBadge`)})]}),c&&e.models.some(e=>e.kind===`chat`)?(0,Y.jsxs)(`label`,{className:`grid min-w-0 gap-1 text-xs text-content-muted`,children:[f(`config:configPage.providerDefaultModel`),(0,Y.jsxs)(q,{"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,Y.jsx)(`option`,{value:e.defaultModel||``,disabled:!0,children:e.defaultModel||f(`config:configPage.selectModel`)}),e.models.filter(e=>e.kind===`chat`).map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}):e.defaultModel?(0,Y.jsxs)(`small`,{className:`truncate font-mono text-xs text-content-muted`,title:e.defaultModel,children:[f(`config:configPage.providerDefaultModel`),`: `,e.defaultModel]}):null,(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`small`,{className:`text-xs text-content-muted`,children:m}),(0,Y.jsxs)(`div`,{className:`flex flex-none items-center gap-1.5`,children:[s&&(0,Y.jsx)(B,{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,Y.jsx)(Sn,{size:13})}),(0,Y.jsx)(B,{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,Y.jsx)(M,{size:13})}),(0,Y.jsx)(ir,{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,Y.jsx)(B,{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,Y.jsx)(ve,{size:13})})]})]})]},e.id)})})}var Ui=`pisper.config.visualConnectionsOpen`,$={running:null,result:null,error:``};function Wi(){return r.getItem(Ui)===`1`}function Gi({config:e,notify:t,toggling:n,onToggleProvider:i,onDeleteProvider:a,onCloneProvider:o,onQuickSetup:s,onEditVisualProvider:c}){let{t:u}=l(),[d,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(!0),[g,_]=(0,J.useState)(``),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(null),[S,C]=(0,J.useState)(``),[w,T]=(0,J.useState)(Wi),O=(0,J.useCallback)(async()=>{try{p(await f(`/api/visual/models`)),C(``)}catch(e){C(e instanceof Error?e.message:String(e))}finally{h(!1)}},[]);(0,J.useEffect)(()=>{O()},[O,e]),(0,J.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)}},N=e=>{T(e),r.setItem(Ui,e?`1`:`0`)},P=e.providers.filter(e=>e.type===`visual`),F=P.filter(e=>e.configured||e.custom),ne=d?.imageModels||[],re=d?.videoModels||[];return(0,Y.jsxs)(`section`,{className:`mt-3`,children:[(0,Y.jsxs)(tr,{className:`mb-3 py-3.5`,"data-config-card":`models-visual`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:R(`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,Y.jsx)(ge,{size:18})}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-content-muted`,children:u(`config:configPage.currentVisualModel`)}),m?(0,Y.jsxs)(`span`,{role:`status`,className:`flex items-center gap-2 text-xs text-content-muted`,children:[(0,Y.jsx)(z,{className:`size-3.5`}),u(`config:configPage.loadingVisualStatus`)]}):d?.image?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`truncate text-sm font-medium text-content`,children:[d.image.providerName,` / `,d.image.name]}),(0,Y.jsxs)(rr,{tone:`green`,children:[(0,Y.jsx)(A,{size:11,className:`mr-[3px] inline`}),u(`config:configPage.authenticationReady`)]})]}),d.video&&(0,Y.jsxs)(`small`,{className:`text-xs text-content-muted [overflow-wrap:anywhere]`,children:[u(`config:configPage.visualVideoModel`),`:`,d.video.providerName,` /`,` `,d.video.name]})]}):(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-warning-strong`,children:[(0,Y.jsx)(k,{size:14,"aria-hidden":`true`}),u(`config:configPage.visualNoneConfigured`)]}),(0,Y.jsx)(`small`,{className:`text-xs text-content-muted`,children:u(`config:configPage.visualEmptyHint`)})]})]}),(0,Y.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,Y.jsxs)(B,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:v,onClick:()=>void M(),children:[v?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(ee,{size:13}),u(v?`config:configPage.testingGeneration`:`config:configPage.testGeneration`)]}),(0,Y.jsxs)(B,{className:`max-[650px]:h-11`,onClick:s,children:[(0,Y.jsx)(te,{size:13}),u(`config:configPage.visualQuickSetup`)]})]})]}),b&&(0,Y.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,Y.jsx)(`img`,{src:b.previewDataUrl,alt:b.modelName,className:`size-11 flex-none rounded-xs object-cover`}):(0,Y.jsx)(E,{size:16,className:`flex-none text-success`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-px text-xs`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-success-strong`,children:u(`config:configPage.testSucceeded`)}),(0,Y.jsxs)(`span`,{className:`truncate font-mono text-content-muted`,children:[b.providerName,` / `,b.modelName,` · `,b.path]})]})]})]}),(0,Y.jsxs)(je,{open:w,onOpenChange:N,children:[(0,Y.jsx)(Ae,{asChild:!0,children:(0,Y.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,Y.jsx)(D,{size:16,"aria-hidden":`true`,className:`flex-none text-content-muted transition-transform group-data-[state=closed]:-rotate-90`}),(0,Y.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-content`,children:u(`config:configPage.visualConnections`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:u(`config:configPage.visualConnectionsHint`)})]})}),(0,Y.jsx)(ke,{children:(0,Y.jsxs)(tr,{className:`mt-2 py-4`,children:[(0,Y.jsx)(Hi,{providers:P,toggling:n,onClone:o,onConfigure:e=>c(e.id),onToggle:i,onDelete:a}),F.length===0&&(0,Y.jsx)(`p`,{className:`text-xs text-content-muted`,children:u(`config:configPage.visualEmptyHint`)}),(ne.length>0||re.length>0)&&(0,Y.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 border-t border-stroke-soft pt-3`,children:[ne.length>0&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-16 flex-none text-xs text-content-muted`,children:u(`config:configPage.visualImageModel`)}),(0,Y.jsxs)(q,{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,Y.jsx)(`option`,{value:``,children:u(`config:configPage.visualAutoSelected`)}),ne.map(e=>(0,Y.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),re.length>0&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-16 flex-none text-xs text-content-muted`,children:u(`config:configPage.visualVideoModel`)}),(0,Y.jsxs)(q,{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,Y.jsx)(`option`,{value:``,children:u(`config:configPage.visualAutoSelected`)}),re.map(e=>(0,Y.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),(0,Y.jsx)(`small`,{className:`text-xs text-content-muted`,children:u(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]})]})})]}),S&&(0,Y.jsx)(`div`,{className:`mt-2.5`,children:(0,Y.jsxs)(Nt,{children:[(0,Y.jsx)(ye,{size:13}),S]})})]})}var Ki=`pisper.config.manageConnectionsOpen`;function qi(){let e=r.getItem(Ki);return e===`1`||e!==`0`&&null}function Ji({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,J.useState)(``),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(()=>u||e?!0:qi());(0,J.useEffect)(()=>{u&&v(!0)},[u]),(0,J.useEffect)(()=>{e&&v(!0)},[e,n]);let y=Bi({notify:i,requestConfirm:o,t:s}),{config:b}=y,x=Vi({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(Bt(a,()=>m({providerType:`chat`})),!b)return y.error&&!y.loading?(0,Y.jsx)(ht,{kind:`error`,title:s(`config:providerWorkbench.loadFailed`),description:y.error,action:(0,Y.jsx)(B,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void y.reload(),children:s(`common:pageTemplate.retry`)})}):(0,Y.jsx)(ht,{kind:`loading`,title:s(`config:configPage.loadingModelCatalog`),description:s(`config:configPage.readingProvidersAndAuthenticationStatus`)});let S=_??!1,C=yi(x.discovery),w=e=>{v(e),r.setItem(Ki,e?`1`:`0`)},T=e=>g(e);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ni,{config:b,notify:i,busy:!!(y.settingDefault||y.toggling),onConfigChanged:y.applyConfig,onSetDefaultModel:y.setDefaultChatModel}),(0,Y.jsx)(Ii,{config:b,notify:i,busy:!!(y.settingDefault||y.toggling),onConfigChanged:y.applyConfig}),(0,Y.jsx)(Ri,{notify:i}),(0,Y.jsx)(pi,{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,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,role:`status`,children:[x.discovering&&(0,Y.jsx)(z,{className:`size-3`}),x.discovering?s(`config:providerWorkbench.scanningLocal`):s(`config:providerWorkbench.localImportStatus`,{imported:x.autoImport.imported,skipped:x.autoImport.skipped})]})}),y.error&&(0,Y.jsx)(G,{children:y.error}),C>0&&(0,Y.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-2 gap-y-0 text-xs text-content-muted`,children:[(0,Y.jsx)(`span`,{children:s(`config:configPage.localProviderImportHint`,{count:C})}),(0,Y.jsx)(B,{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,Y.jsxs)(je,{open:S,onOpenChange:w,"data-config-card":`models-advanced`,children:[(0,Y.jsx)(Ae,{asChild:!0,children:(0,Y.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,Y.jsx)(D,{size:16,"aria-hidden":`true`,className:`shrink-0 text-content-muted transition-transform group-data-[state=closed]:-rotate-90`}),(0,Y.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-content`,children:s(`config:providerWorkbench.advanced`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:s(`config:providerWorkbench.advancedHint`)})]})}),(0,Y.jsxs)(ke,{id:`model-connection-management`,children:[(0,Y.jsx)(Ei,{discovery:x.discovery,discovering:x.discovering,error:x.error||x.operationError,importing:x.importing,forceVisible:u,onRefresh:x.refresh,onImport:x.importProvider}),(0,Y.jsx)(Gi,{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,Y.jsx)(Oi,{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,Y.jsx)(vi,{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 Yi=[`browser`,`feishu`,`weixin`,`qq`,`telegram`];function Xi(e){if(!e||typeof e!=`object`||Array.isArray(e))throw d();return e}function Zi(e,t){if(typeof e!=`string`||e.length>t)throw d();return e}function Qi(e){let t=Xi(e),n=Xi(t.browser);if(typeof n.enabled!=`boolean`||!Array.isArray(t.templates)||!Array.isArray(t.scopes))throw d();let r={},i=Xi(t.connections);for(let e of Yi){if(e===`browser`||i[e]===void 0)continue;let t=i[e];if(t===null){r[e]=null;continue}let n=Xi(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=Xi(e),n=Zi(t.id,200);if(!n||a.has(n)||typeof t.enabled!=`boolean`||!Array.isArray(t.variables))throw d();a.add(n);let r={},i=Xi(t.channels);for(let e of Yi){if(i[e]===void 0)continue;let t=Xi(i[e]);if(t.enabled!==void 0&&typeof t.enabled!=`boolean`)throw d();r[e]={content:Zi(t.content,12e3),...t.enabled===void 0?{}:{enabled:t.enabled}}}return{id:n,name:Zi(t.name,500),description:Zi(t.description,2e3),enabled:t.enabled,variables:t.variables.map(e=>Zi(e,200)),channels:r}}),s=t.scopes.map(e=>{let t=Xi(e);if(!Yi.includes(t.platform))throw d();return{...t,platform:t.platform}});return{browser:{enabled:n.enabled},connections:r,scopes:s,templates:o}}function $i(e){let t=Xi(e);if(typeof t.sent!=`number`||!Number.isInteger(t.sent)||t.sent<0)throw d();return{sent:t.sent,...t.title===void 0?{}:{title:Zi(t.title,2e3)},...t.body===void 0?{}:{body:Zi(t.body,12e3)},...t.preview===void 0?{}:{preview:Zi(t.preview,12e3)}}}function ea(e){return e.templates.length>0&&e.templates.every(e=>Yi.every(t=>typeof e.channels[t]?.enabled==`boolean`))}var ta=(e,t)=>`/api/settings/notifications/templates/${encodeURIComponent(e)}/${t}`,na=(e,t,n,r)=>u(ta(e,t),{method:`PUT`,body:n,...r,parse:Qi}),ra={load:(e={})=>u(`/api/settings/notifications`,{...e,parse:Qi}),setBrowserEnabled:(e,t={})=>u(`/api/settings/notifications/browser`,{method:`PATCH`,body:{enabled:e},...t,parse:Qi}),setEventEnabled:(e,t,n={})=>na(e,`browser`,{enabled:t},n),setChannelEnabled:async(e,t,n,r={})=>{let i=await na(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={})=>na(e,t,{content:n},r),testSavedTemplate:(e,t,n={})=>u(`${ta(e,t)}/test`,{method:`POST`,body:{},...n,parse:$i})},ia=e=>e instanceof Error?e.message:String(e),aa=(e,t)=>`${e}\0${t}`,oa=e=>e.kind===`browser`?`browser`:e.kind===`event`?`event:${e.event}`:`channel:${e.event}:${e.platform}`;function sa(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 ca(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 la(e){let[t,n]=(0,J.useState)(null),r=(0,J.useRef)(null),i=(0,J.useRef)(e);i.current=e;let[a,o]=(0,J.useState)(!0),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)({}),[f,p]=(0,J.useState)({}),m=(0,J.useRef)({}),[h,g]=(0,J.useState)({}),[_,v]=(0,J.useState)({}),y=(0,J.useRef)(!1),b=(0,J.useRef)(null),x=(0,J.useRef)(new Map),S=(0,J.useRef)(new Map),C=(0,J.useRef)(new Set),w=(0,J.useRef)(0),T=(0,J.useRef)(0),E=(0,J.useCallback)(e=>{r.current=e,T.current++,n(e),i.current?.(e)},[]),D=(0,J.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 ra.load({signal:e.signal});y.current&&!e.signal.aborted&&t===T.current&&E(n)}catch(t){y.current&&!e.signal.aborted&&c(ia(t))}finally{y.current&&!e.signal.aborted&&o(!1)}},[E]);(0,J.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=oa(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(sa(r.current,e)!==t.value||C.current.has(n)){let i={signal:a.signal},o=e.kind===`browser`?await ra.setBrowserEnabled(t.value,i):e.kind===`event`?await ra.setEventEnabled(e.event,t.value,i):await ra.setChannelEnabled(e.event,e.platform,t.value,i);if(!y.current||a.signal.aborted)return;E(ca(r.current,e,sa(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:ia(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=ca(k,e.target,e.value));let A=(e,t,n)=>{let r=aa(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=aa(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?ea(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=aa(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 ra.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:ia(e)}})),!1}finally{x.current.get(i)===o&&x.current.delete(i)}},testTemplate:async(e,t)=>{let n=aa(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 ra.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:ia(e)}}))}finally{x.current.get(r)===i&&x.current.delete(r)}}}}function ua(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,J.useRef)(!0),[f,p]=(0,J.useState)(``);(0,J.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let m=t.find(e=>e.id===n)||t[0];if(!m||!e.data)return(0,Y.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,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h2`,{className:`text-[15px] leading-6 font-medium text-content`,children:u(`config:notificationSettings.notificationTemplates`)}),(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[u(`config:notificationSettings.notificationEvent`),(0,Y.jsx)(q,{"aria-label":u(`config:notificationSettings.notificationEvent`),value:m.id,onChange:e=>i(e.target.value,r),children:t.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,Y.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[u(`config:notificationSettings.notificationChannel`),(0,Y.jsx)(q,{"aria-label":u(`config:notificationSettings.notificationChannel`),value:r,onChange:e=>{let t=Yi.find(t=>t===e.target.value);t&&i(m.id,t)},children:Yi.map(e=>(0,Y.jsx)(`option`,{value:e,children:a(e)},e))})]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-content-muted`,children:m.description}),(0,Y.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[u(`config:notificationSettings.messageContent`),(0,Y.jsx)(wt,{"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,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-content-muted`,children:[(0,Y.jsx)(`span`,{children:u(`config:notificationSettings.availableVariables`)}),m.variables.map(e=>(0,Y.jsx)(`code`,{className:`rounded-xs bg-inline-code px-1.5 py-0.5 font-mono text-content-secondary`,children:`{{${e}}}`},e))]}),(0,Y.jsxs)(`div`,{className:`rounded-md border border-stroke bg-code p-3`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-content-muted`,children:u(`config:notificationSettings.preview`)}),(0,Y.jsx)(`pre`,{className:`mt-2 font-sans text-sm break-words whitespace-pre-wrap text-content`,children:ua(h.content,u)})]}),(0,Y.jsx)(`p`,{className:`text-xs text-content-muted`,children:h.dirty?u(`config:notificationSettings.saveBeforeTest`):u(`config:notificationSettings.testUsesSavedTemplate`)}),!_&&(0,Y.jsx)(`p`,{role:`status`,className:`text-xs text-content-muted`,children:u(`config:notificationSettings.channelTestUnavailable`)}),(h.save.error||h.test.error||f)&&(0,Y.jsx)(Nt,{children:h.save.error||h.test.error||f}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,Y.jsx)(B,{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,Y.jsx)(B,{"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 fa(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 pa(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 ma(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 ha(){return typeof window<`u`&&window.pisperDesktop?.showNotification?window.pisperDesktop.getNotificationStatus?`checking`:`granted`:typeof window<`u`&&Zt()?`checking`:sn()}function ga(e,t){return t(e===`system-disabled`||e===`app-disabled`?`config:notificationSettings.systemNotificationsAreOffAllowPisperToSendNotificationsInYourOperatingSystemSettings`:e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.theOperatingSystemDidNotAcceptTheNotificationCheckYourSystemNotificationSettings`)}function _a(e){return e instanceof Error?e.message:String(e)}function va({notify:e,onBrowserNotificationChange:t}){let{t:r,language:i}=l(),a=(0,J.useRef)(!1);(0,J.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let o=la(t),{data:s,loading:c,loadError:u}=o,[d,f]=n(),p=!!window.pisperDesktop?.showNotification,m=Zt(),[h,g]=(0,J.useState)(ha),_=o.mutations.browser?.pending===!0,v=(0,J.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,J.useEffect)(()=>{if(!p)return;v();let e=()=>{v()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[p,v]);let y=(0,J.useCallback)(async()=>{if(!(p||!m))try{let e=await qt();if(!a.current)return;g(e===!0?`granted`:e===!1?`denied`:`default`)}catch{a.current&&g(`unsupported`)}},[p,m]);(0,J.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=ga(`system-disabled`,r);else if(!p&&m){let e=`denied`;try{let t=await qt()===!0?`granted`:await Yt();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 on();if(!a.current)return;if(g(e),e!==`granted`)n=r(e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`);else try{await an()}catch{n=r(`config:notificationSettings.theBrowserBackgroundNotificationServiceCouldNotBeRegistered`)}}}a.current&&(await o.setBrowserEnabled(t),n&&a.current&&e(n,`info`))},x=(0,J.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(ga(i.reason,r));return i}return m?(await Ht(e,t),{shown:!0,transport:`tauri`}):rn({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`?ga(`unsupported`,r):p?ga(`system-disabled`,r):r(`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`),`error`);return}try{await x(r(`config:notificationSettings.appNotificationTest`,{app:Se}),r(`config:notificationSettings.notificationsAreWorking`)),e(r(`config:notificationSettings.theTestNotificationWasSentCheckYourSystemNotificationCenter`),`info`)}catch(t){e(_a(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,Y.jsxs)(Lt,{children:[(0,Y.jsx)(z,{className:`size-6`}),(0,Y.jsx)(`h2`,{children:r(`config:notificationSettings.loadingNotificationSettings`)})]});if(!s)return(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(Nt,{children:u}),(0,Y.jsx)(B,{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:pa(e.id,e.name,r),description:ma(e.id,e.description,r)}));if(E)return(0,Y.jsxs)(`div`,{"data-config-card":`notifications-templates`,className:`space-y-4`,children:[(0,Y.jsxs)(B,{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,Y.jsx)(O,{size:16,"aria-hidden":`true`}),r(`config:notificationSettings.backToCategories`)]}),(0,Y.jsx)(da,{settings:o,templates:D,eventId:d.get(`event`)||``,platform:Yi.find(e=>e===d.get(`channel`))||`browser`,onSelectionChange:T,platformLabel:e=>fa(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,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[u&&(0,Y.jsx)(Nt,{children:u}),Object.entries(o.mutations).filter(([,e])=>e.error).map(([e,t])=>(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(Nt,{children:t.error}),(0,Y.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>void o.retryMutation(t),children:r(`common:pageTemplate.retry`)})]},e)),(0,Y.jsxs)(tr,{className:`browser-notification-card py-4`,"data-config-card":`notifications-browser`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:R(`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,Y.jsx)(C,{size:18}):(0,Y.jsx)(cn,{size:18})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium text-content`,children:r(`config:notificationSettings.systemNotificationChannel`)}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs leading-[1.45] text-content-muted`,children:r(`config:notificationSettings.pisperUsesTheCurrentPlatformNotificationSystemWhenAnAgentCompletesOrFails`)})]}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[(0,Y.jsx)(rr,{tone:A,children:k}),(0,Y.jsx)(ir,{ariaLabel:r(`config:notificationSettings.systemNotificationChannel`),value:s.browser.enabled,disabled:_||h===`checking`,onChange:b})]})]}),(0,Y.jsxs)(Mt,{children:[(0,Y.jsx)(he,{size:15}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{children:r(p?`config:notificationSettings.controlledByOperatingSystemNotificationSettings`:`config:notificationSettings.controlledByBrowserSitePermissions`)}),(0,Y.jsx)(`small`,{children:r(p?`config:notificationSettings.theDesktopAppUsesOperatingSystemNotificationsTurningThisOffDoesNotChangeTheOperatingSystemPermis`:`config:notificationSettings.theWebAppUsesBrowserSiteNotificationsTurningThisOffDoesNotChangeTheBrowserPermissionItself`)})]})]}),(0,Y.jsxs)(`div`,{className:`mt-4 flex gap-2 max-[650px]:flex-wrap`,children:[p&&h===`denied`&&(0,Y.jsxs)(B,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:w,children:[(0,Y.jsx)(he,{size:14}),r(`config:notificationSettings.openSystemNotificationSettings`)]}),(0,Y.jsxs)(B,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:!s.browser.enabled||_||h!==`granted`,onClick:S,children:[(0,Y.jsx)(C,{size:14}),r(`config:notificationSettings.sendTestNotification`)]})]})]}),(0,Y.jsxs)(Lr,{title:r(`config:notificationSettings.notificationCategories`),description:r(`config:notificationSettings.channelPreferenceHint`),action:(0,Y.jsx)(B,{variant:`ghost`,size:`sm`,className:`pointer-coarse:h-11`,onClick:()=>T(),children:r(`config:notificationSettings.editNotificationTemplates`)}),children:[!o.supportsChannels&&(0,Y.jsx)(`p`,{role:`status`,className:`py-2 text-sm text-content-muted`,children:r(`config:notificationSettings.channelPreferencesUnsupported`)}),D.length>0&&(0,Y.jsx)(ar,{children:D.map(e=>{let t=e.enabled?Yi.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,Y.jsx)(Rr,{"data-notification-event":e.id,title:e.name,description:e.description,control:(0,Y.jsxs)(Ve,{children:[(0,Y.jsx)(ze,{asChild:!0,children:(0,Y.jsx)(B,{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,Y.jsx)(`span`,{className:`max-w-64 truncate`,children:t.length?t.map(e=>fa(e,r)).join(i===`zh-CN`?`、`:`, `):r(`config:notificationSettings.channelsOff`)})})}),(0,Y.jsxs)(Be,{align:`end`,className:`max-w-[calc(100vw-40px)] min-w-56`,children:[(0,Y.jsx)(Re,{checked:e.enabled,onCheckedChange:t=>void o.setEventEnabled(e.id,t===!0),children:r(`config:notificationSettings.enableEvent`)}),(0,Y.jsx)(Ie,{}),Yi.map(t=>{let n=t===`browser`?s.browser.enabled:s.connections[t]?.enabled===!0&&s.scopes.some(e=>e.platform===t);return(0,Y.jsxs)(Re,{checked:e.channels[t]?.enabled!==!1,disabled:!o.supportsChannels,onCheckedChange:n=>void o.setChannelEnabled(e.id,t,n===!0),children:[(0,Y.jsx)(`span`,{children:fa(t,r)}),!n&&(0,Y.jsx)(`small`,{className:`ml-2 text-muted-foreground`,children:r(`config:notificationSettings.channelNeedsSetup`)})]},t)}),(0,Y.jsx)(Ie,{}),(0,Y.jsx)(Le,{onSelect:()=>T(e.id),children:r(`config:notificationSettings.editNotificationTemplates`)})]})]})},e.id)})}),!D.length&&(0,Y.jsx)(`p`,{role:`status`,className:`py-3 text-sm text-content-muted`,children:r(`config:notificationSettings.noNotificationEvents`)})]})]})}function ya({notify:e}){let{t}=l(),n=window.pisperDesktop,[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``);(0,J.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,Y.jsxs)(W,{"data-config-card":`updates-cli`,title:t(`config:cliSettings.title`),description:t(`config:cliSettings.description`),actions:(0,Y.jsx)(`span`,{className:`text-xs text-content-secondary`,children:m}),children:[r&&(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3 border-t border-stroke py-3`,children:[r.installed&&!r.needsRepair?(0,Y.jsx)(A,{className:`mt-0.5 shrink-0 text-content-muted`,size:16,"aria-hidden":`true`}):(0,Y.jsx)(wn,{className:`mt-0.5 shrink-0 text-content-muted`,size:16,"aria-hidden":`true`}),(0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-0.5`,children:[(0,Y.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,Y.jsx)(`small`,{className:`font-mono text-xs [overflow-wrap:anywhere] text-content-muted`,children:r.installPath}),r.installed&&(0,Y.jsx)(`small`,{className:`text-xs text-content-muted`,children:r.pathConfigured?t(`config:cliSettings.pathConfigured`):t(`config:cliSettings.pathNeedsRepair`)})]})]}),s&&(0,Y.jsx)(G,{children:s}),u&&(0,Y.jsxs)(`div`,{className:`mt-3 flex gap-2 max-[650px]:flex-wrap`,children:[r?.installed&&(0,Y.jsxs)(B,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:!!a,onClick:()=>void f(),children:[a===`uninstall`?(0,Y.jsx)(z,{className:`text-current`}):(0,Y.jsx)(ve,{size:14}),t(`config:cliSettings.uninstall`)]}),(!r?.installed||r.needsRepair)&&(0,Y.jsxs)(B,{type:`button`,className:`max-[650px]:h-11`,disabled:!!a||p||r?.supported===!1,onClick:()=>void d(),children:[a===`install`?(0,Y.jsx)(z,{className:`text-current`}):r?.needsRepair?(0,Y.jsx)(be,{size:14}):(0,Y.jsx)(N,{size:14}),r?.needsRepair?t(`config:cliSettings.repair`):t(`config:cliSettings.install`)]})]}),u&&(0,Y.jsx)(`small`,{className:`mt-2 block text-xs text-content-muted`,children:t(`config:cliSettings.restartTerminal`)})]})}var ba=`0.6.11`;function xa(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 Sa(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 Ca({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,J.useState)({version:ba,date:``,notes:``}),[f,p]=(0,J.useState)(``);(0,J.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,J.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,Y.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col`,children:[(0,Y.jsxs)(W,{"data-config-card":`updates-main`,className:`mt-6`,title:n(`config:updateSettings.pisperAppUpdates`),actions:(0,Y.jsx)(`span`,{"data-update-status":D,className:`text-xs text-content-secondary tabular-nums`,children:M}),children:[(0,Y.jsxs)(`dl`,{className:`grid border-y border-stroke max-sm:divide-y max-sm:divide-stroke-soft sm:grid-cols-3`,children:[(0,Y.jsxs)(`div`,{className:`py-3 sm:pr-4`,children:[(0,Y.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(c?`config:updateSettings.currentVersion`:`config:updateSettings.currentSource`)}),(0,Y.jsx)(`dd`,{className:`mt-1 font-mono text-[12.5px] font-medium text-content`,children:O})]}),(0,Y.jsxs)(`div`,{className:`py-3 sm:border-l sm:border-stroke-soft sm:px-4`,children:[(0,Y.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(`config:updateSettings.platform`)}),(0,Y.jsx)(`dd`,{className:`mt-1 text-sm font-medium text-content`,children:xa(i,n)})]}),(0,Y.jsxs)(`div`,{className:`py-3 sm:border-l sm:border-stroke-soft sm:pl-4`,children:[(0,Y.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(`config:updateSettings.updateChannel`)}),(0,Y.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,Y.jsx)(G,{children:a.message}):(0,Y.jsxs)(`p`,{className:`mt-4 flex items-start gap-2 text-sm text-content-secondary`,children:[(0,Y.jsx)(pn,{className:`mt-0.5 shrink-0 text-content-muted`,size:15,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0`,children:a.message})]})),C&&(0,Y.jsx)(`small`,{className:`mt-2 block text-xs text-content-muted`,children:n(`config:updateSettings.downloadedDataWasPreservedAndCanResumeFromTheInterruptionPoint`)}),E&&(0,Y.jsxs)(`div`,{className:`mt-4`,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between text-xs text-content-muted`,children:[(0,Y.jsx)(`span`,{children:n(`config:updateSettings.downloadProgress`)}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[Math.round(a.percent||0),`% · `,Sa(a.transferred,r),` /`,` `,Sa(a.total,r)]})]}),(0,Y.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-surface-active`,children:(0,Y.jsx)(`i`,{className:`block h-full bg-star transition-[width]`,style:{width:`${a.percent||0}%`}})})]}),(0,Y.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Y.jsxs)(B,{className:`max-[650px]:h-11`,disabled:T||E||!!f,onClick:w?v:S||C?_:m,children:[T||E?(0,Y.jsx)(z,{className:`text-current`}):w?(0,Y.jsx)(de,{size:14}):S||C?a.canDownload?(0,Y.jsx)(N,{size:14}):(0,Y.jsx)(F,{size:14}):(0,Y.jsx)(ue,{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,Y.jsxs)(B,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:h,children:[(0,Y.jsx)(F,{size:14}),c?`GitHub Releases`:`GitHub Compare`]}),o&&(0,Y.jsxs)(B,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:g,children:[(0,Y.jsx)(F,{size:14}),n(`config:updateSettings.viewUpdateDiagnosticLog`)]})]})]}),!s&&(0,Y.jsx)(W,{"data-config-card":`updates-components`,title:n(`config:updateSettings.appComponents`),children:(0,Y.jsx)(U,{children:j.map(e=>{let t=e.component===`desktop`?pn:e.component===`tui`?_e:dn,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,Y.jsx)(H,{icon:(0,Y.jsx)(t,{}),name:i,description:e.message||void 0,meta:(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono tabular-nums`,children:[(0,Y.jsxs)(`span`,{children:[`v`,e.currentVersion]}),e.availableVersion&&e.availableVersion!==e.currentVersion&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{size:12,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[`v`,e.availableVersion]})]}),e.size>0&&e.state===`available`&&(0,Y.jsx)(`span`,{className:`font-sans`,children:Sa(e.size,r)})]}),status:a},e.component)})})}),!s&&(0,Y.jsx)(ya,{notify:e}),(0,Y.jsx)(W,{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,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-xs text-content-muted`,children:[(0,Y.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,Y.jsx)(`div`,{className:`border-t border-stroke pt-3`,children:(0,Y.jsx)(kt,{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`about`:return e(`config:settingsShell.lede.about`);default:return e(`config:settingsShell.lede.models`)}}function Ta({notify:e,registerPrimaryAction:t,invokePrimaryAction:n,section:r,onBackToFeatures:i,onBrowserNotificationChange:a,requestConfirm:o,update:s,renderInterfaceSettings:c}){let{t:u}=l(),d=tt(r);if(r===`remote-access`||r===`mobile-server`||r===`desktop-pet`)return(0,Y.jsx)(Fr,{section:r,notify:e,requestConfirm:o,onBack:i});let f=re(r)?r:`models`,p;if(f===`notifications`)p=(0,Y.jsx)(va,{notify:e,onBrowserNotificationChange:a});else if(f===`interface`){let t=(0,Y.jsx)(Yr,{notify:e,defaultAdvancedExpanded:d?.expandGroup===`interface-advanced`,navigationKey:d?.navigationKey});p=c?c(t):t}else p=f===`shortcuts`?(0,Y.jsx)(Xr,{requestConfirm:o}):f===`updates`?(0,Y.jsx)(Ca,{notify:e,update:s}):f===`about`?(0,Y.jsx)(dr,{update:s,notify:e}):(0,Y.jsx)(Ji,{defaultAdvancedExpanded:d?.expandGroup===`models-advanced`,navigationKey:d?.navigationKey,notify:e,registerPrimaryAction:t,requestConfirm:o});let m=u(`navigation:pageHeader.quickSetup`);return(0,Y.jsx)(Dt,{"data-settings-page":f,title:ie(u,f),description:wa(u,f),toolbar:f===`models`?(0,Y.jsx)(Ot,{actions:(0,Y.jsxs)(B,{variant:`outline`,"data-settings-quick-setup":!0,onClick:n,children:[(0,Y.jsx)(le,{className:`size-4`,"aria-hidden":`true`}),m]})}):void 0,children:(0,Y.jsx)(`div`,{"data-config-card":nt,className:`mt-6 min-w-0 max-[650px]:mt-3`,children:p})})}export{Ta as ConfigPage};