pisper 0.6.44 → 0.6.45
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.
- package/package.json +6 -6
- package/web/.vite/manifest.json +691 -691
- package/web/assets/{AppDialog-BmhtqPq6.js → AppDialog-DNRcFofn.js} +1 -1
- package/web/assets/{AppOverlays-cyz0mMc9.js → AppOverlays-D1G4bRJ_.js} +1 -1
- package/web/assets/{AssetsPage-a_DNQXQF.js → AssetsPage-BxfXloqY.js} +1 -1
- package/web/assets/{AttachmentTray-Fx0RVdj2.js → AttachmentTray-ChMs2_F_.js} +1 -1
- package/web/assets/{BoardPage-CQF_701M.js → BoardPage-BWPe3aOh.js} +3 -3
- package/web/assets/{ChannelsPage-C4sSuXef.js → ChannelsPage-DIqDgADZ.js} +1 -1
- package/web/assets/{ChatAppearancePage-BA77E4RG.js → ChatAppearancePage-RMfIitpr.js} +1 -1
- package/web/assets/{ChatHistoryPage-Bo932avi.js → ChatHistoryPage-Dv2EeHAV.js} +1 -1
- package/web/assets/{ChatMessage-DyRMVDmJ.js → ChatMessage-CzJ7vm4B.js} +5 -5
- package/web/assets/{ChatPage-Bh2srQ5Q.js → ChatPage-Bz2V_NZ9.js} +5 -5
- package/web/assets/{ConfigPage-CRMPpPxz.js → ConfigPage-DXTFhwnY.js} +2 -2
- package/web/assets/{DesktopWindowControls-QTt7BkHB.js → DesktopWindowControls-iivqpiQx.js} +1 -1
- package/web/assets/{FeaturePage-DEjUrI25.js → FeaturePage-BOq1shgs.js} +1 -1
- package/web/assets/{FileAttachmentPreview-CU3DVCec.js → FileAttachmentPreview-DV6eqgRK.js} +1 -1
- package/web/assets/{FloatingWidgets-DsEUT3hG.js → FloatingWidgets-VZ-Qb-wN.js} +1 -1
- package/web/assets/FocusRuntimeControls-C8oD9nnP.js +2 -0
- package/web/assets/{GitDiffViewer-BFdi1mxr.js → GitDiffViewer-CAklMpA4.js} +1 -1
- package/web/assets/{ManageProjectsDialog-BpsBTKv5.js → ManageProjectsDialog-Cfv6AU2u.js} +1 -1
- package/web/assets/{MarkdownMessage-B9Bb9VQU.js → MarkdownMessage-C47P3anj.js} +1 -1
- package/web/assets/{McpPage-D1onf9RA.js → McpPage-CnBIWy5m.js} +1 -1
- package/web/assets/{MemoryEvolution-D4d8ELda.js → MemoryEvolution-BdhNE7KR.js} +1 -1
- package/web/assets/{MemoryPage-BxeQ1cdR.js → MemoryPage-Cs9Gw3yR.js} +2 -2
- package/web/assets/{MobileNavigation-DQcTpoYc.js → MobileNavigation-C-CAVhMP.js} +1 -1
- package/web/assets/{MorePage-DqfRiueD.js → MorePage-CLEkoAvi.js} +1 -1
- package/web/assets/{NewFolderDialog-dNstknkT.js → NewFolderDialog-GIqRGkVE.js} +1 -1
- package/web/assets/{PageHeader-Bn_vZ-th.js → PageHeader-DRXzRG34.js} +1 -1
- package/web/assets/{PhoneDrawer-BnWXS2P1.js → PhoneDrawer-WHEiWgs5.js} +1 -1
- package/web/assets/{PhoneMenuButton-Coocnsrf.js → PhoneMenuButton-BQSaB_4t.js} +1 -1
- package/web/assets/{PhoneTopBar-DUJ9aeM3.js → PhoneTopBar-BCRq9xao.js} +1 -1
- package/web/assets/{PluginsPage-Z7Fx-eAU.js → PluginsPage-xVXkgNsr.js} +1 -1
- package/web/assets/{SafeModePrompt-DaxOzv7_.js → SafeModePrompt-CV0e__Tp.js} +1 -1
- package/web/assets/{SchedulesPage-ZGP3g3Vt.js → SchedulesPage-Bsl7a3lS.js} +1 -1
- package/web/assets/{SessionBrowserPane-DeOqkbLQ.js → SessionBrowserPane-feS4xeee.js} +2 -2
- package/web/assets/{SessionContextPanel-Co419auw.js → SessionContextPanel-aH8brkyg.js} +2 -2
- package/web/assets/{SessionHome-3GRisRUv.js → SessionHome-DLPkN0jf.js} +1 -1
- package/web/assets/{SessionInspector-KjdRXk-P.js → SessionInspector-2ar9Ti-b.js} +1 -1
- package/web/assets/{SessionShell-DrMljmEy.js → SessionShell-FCFBi5iD.js} +1 -1
- package/web/assets/{SettingsSidebar-Bfgryx3X.js → SettingsSidebar-JH87Nmo2.js} +1 -1
- package/web/assets/{ShortcutHelpDialog-BEv4kDZo.js → ShortcutHelpDialog-BQlkmhTE.js} +1 -1
- package/web/assets/{ShortcutKeys-CFnZogMX.js → ShortcutKeys-CJB8XFeA.js} +1 -1
- package/web/assets/{SidebarUpdateStatus-BaQLz9Ha.js → SidebarUpdateStatus-DsInXdr3.js} +1 -1
- package/web/assets/{SkillsPage-DiBdvo55.js → SkillsPage-wekYWAdT.js} +1 -1
- package/web/assets/{TaskProcessesPane-CgzN0Oqf.js → TaskProcessesPane-nhAVkTPK.js} +1 -1
- package/web/assets/{TaskTerminalView-E0ZkafSN.js → TaskTerminalView-QMAxGYqP.js} +1 -1
- package/web/assets/{TerminalPanel-KwRTV-hb.js → TerminalPanel-CtwjsJfa.js} +1 -1
- package/web/assets/{WebDesktopPet-CGpI6-UL.js → WebDesktopPet-CA-YJQxv.js} +1 -1
- package/web/assets/{WorkflowsPage-BCfAr_BN.js → WorkflowsPage-Cd86btwf.js} +1 -1
- package/web/assets/{WorkspacePicker-DyL_8DP0.js → WorkspacePicker-BMvjJqVo.js} +1 -1
- package/web/assets/{api-D1flkoh7.js → api-DvJkDxm2.js} +1 -1
- package/web/assets/{app-update-DWy3AK8N.js → app-update-A3wZafCD.js} +1 -1
- package/web/assets/{approval-confirm-CDGLUuxy.js → approval-confirm-CryF68cs.js} +1 -1
- package/web/assets/{assets-api-BGMZsyC4.js → assets-api-CPakJhYf.js} +1 -1
- package/web/assets/{board-projects-DjGBcX8k.js → board-projects-jIIRo-OH.js} +1 -1
- package/web/assets/{bots-store-Ck_jncK7.js → bots-store-Dc07jUzl.js} +1 -1
- package/web/assets/{chat-api-BqA8nXly.js → chat-api-DrjHZunL.js} +1 -1
- package/web/assets/{client-store-e4OXhDNK.js → client-store-vgpSLnwK.js} +1 -1
- package/web/assets/command-Cf3AX_Nt.js +1 -0
- package/web/assets/{config-search-a0xjM1yz.js → config-search-DLwaZPQ0.js} +1 -1
- package/web/assets/{desktop-hosts-DsTa6yr4.js → desktop-hosts-0e3KPpOY.js} +1 -1
- package/web/assets/{dialog-DldLiTwf.js → dialog-Cfk77z7g.js} +1 -1
- package/web/assets/{event-stream-DRv0u06j.js → event-stream-Viv-Ob7U.js} +1 -1
- package/web/assets/{events-C8OUQmIW.js → events-Wogs03GD.js} +1 -1
- package/web/assets/{folder-paths-CfRbR0Ik.js → folder-paths-JS7ynXVP.js} +1 -1
- package/web/assets/{hosts-DbXwJrWt.js → hosts-BOC6FyGx.js} +1 -1
- package/web/assets/{http-response-DEs9jkgT.js → http-response-CSCIVa2S.js} +1 -1
- package/web/assets/{http-B-XVZUum.js → http-zidLhKOq.js} +1 -1
- package/web/assets/i18n-DojWxWRu.js +1 -0
- package/web/assets/{index-j6s460ui.css → index-CrtNFCj_.css} +1 -1
- package/web/assets/{index-CiyAfWLi.js → index-DfZr_SBB.js} +2 -2
- package/web/assets/{machine-messages-CKHf8pyL.js → machine-messages-BJSM1X90.js} +1 -1
- package/web/assets/{machines-api-BeimiMiu.js → machines-api-C_Mtpsx-.js} +1 -1
- package/web/assets/{memory-api-Cu3MEsQE.js → memory-api-Bgy-5-wQ.js} +1 -1
- package/web/assets/{mount-app-ISo-f47e.js → mount-app-G6kgCLuV.js} +2 -2
- package/web/assets/{permission-rules-api-bHINce43.js → permission-rules-api-B_E6IQKz.js} +1 -1
- package/web/assets/{pick-system-directory-D1GGkOTf.js → pick-system-directory-LTM6ma78.js} +1 -1
- package/web/assets/{placements-9_rV4h0k.js → placements-C9ibKMbf.js} +2 -2
- package/web/assets/{popover-DGWRnOht.js → popover-CJZagMlP.js} +1 -1
- package/web/assets/{public-B7wKOz_X.js → public-BoVk_M9e.js} +2 -2
- package/web/assets/{public-lAWjPSYc.js → public-DAyGFlph.js} +1 -1
- package/web/assets/{public-DRF_OfnY.js → public-EyctVdZl.js} +1 -1
- package/web/assets/{public-Dr8_scp5.js → public-RXIeJTl_.js} +2 -2
- package/web/assets/{public-components-by-7di2-.js → public-components-DUyD_N-P.js} +1 -1
- package/web/assets/public-diff-BHHFwd2h.js +1 -0
- package/web/assets/public-events-CF9LX0aU.js +1 -0
- package/web/assets/{public-flags-DHN44K2T.js → public-flags-DRJJOuZP.js} +1 -1
- package/web/assets/{public-folder-dialog-Gkbm4LRI.js → public-folder-dialog-BCVCXKem.js} +1 -1
- package/web/assets/{public-greeting-Bdpk4piS.js → public-greeting-BWAXeejh.js} +1 -1
- package/web/assets/{public-session-CtusCiv8.js → public-session-DS7Ggm0I.js} +1 -1
- package/web/assets/{public-sidebar-DmWVSBL3.js → public-sidebar-BscZFI63.js} +1 -1
- package/web/assets/{runtime-capabilities-store-MtXRlSIi.js → runtime-capabilities-store-Pf6H3F8g.js} +1 -1
- package/web/assets/{safe-mode-instance-CpOBP8Nz.js → safe-mode-instance-DW1In7Kt.js} +1 -1
- package/web/assets/safe-mode-sentinel-Dj3En0LX.js +1 -0
- package/web/assets/{session-change-summary-api-CAkw4_-l.js → session-change-summary-api-ytql-8Mb.js} +1 -1
- package/web/assets/{session-home-CJcIlNWK.js → session-home-CYMA_6K8.js} +1 -1
- package/web/assets/{session-inspector-store-C3BluNoW.js → session-inspector-store-C8XTJKcv.js} +1 -1
- package/web/assets/{session-questions-BPKyVhzp.js → session-questions-DODg4dBd.js} +1 -1
- package/web/assets/{session-scope-ddZfvpZE.js → session-scope-UGYN3ar9.js} +1 -1
- package/web/assets/{session-tree-actions-_YCQsWye.js → session-tree-actions-EtL6Nf5T.js} +1 -1
- package/web/assets/{session-tree-summary-BLsTrwUq.js → session-tree-summary-JM5v4ugd.js} +1 -1
- package/web/assets/{session-web-preview-DZOVkeBU.js → session-web-preview-BsCgxxv4.js} +1 -1
- package/web/assets/{shortcuts-C6ddcUau.js → shortcuts-DDY3WKNk.js} +1 -1
- package/web/assets/{side-chat-context-C7vwSBGo.js → side-chat-context-C2I0EzIE.js} +4 -4
- package/web/assets/{sidebar-B7HP3-3A.js → sidebar-BTaR7jH_.js} +1 -1
- package/web/assets/{sidebar-store-Bv_D4lVD.js → sidebar-store-Bmpse81N.js} +1 -1
- package/web/assets/{speech-session-DI3T3jpW.js → speech-session-DOQkdJHS.js} +1 -1
- package/web/assets/{startup-queries-B2k6wlnS.js → startup-queries-D3JCr4DY.js} +1 -1
- package/web/assets/{use-i18n-CsOCclo6.js → use-i18n-D7gqe3X9.js} +1 -1
- package/web/assets/{use-open-bot-BPSaOfrG.js → use-open-bot-CKhA9NsG.js} +1 -1
- package/web/assets/{use-studio-actions-Cvz4jiDa.js → use-studio-actions-CvFfWXni.js} +1 -1
- package/web/assets/{useCatalogProjects-D3mDdYej.js → useCatalogProjects-D4S7sSAX.js} +1 -1
- package/web/assets/{useMachines-BwvKcPVd.js → useMachines-CGhATQIK.js} +1 -1
- package/web/assets/{useNewProjectPicker-DfE1or_O.js → useNewProjectPicker-BhuGTAp2.js} +2 -2
- package/web/assets/{useNow-CuwOIh4H.js → useNow-BHuHuBZk.js} +1 -1
- package/web/assets/{usePhoneShell-e-CScTJH.js → usePhoneShell-O2Livo2-.js} +1 -1
- package/web/assets/{useSessionRowActions-DUufel_k.js → useSessionRowActions-a38hlfs2.js} +1 -1
- package/web/assets/{useSidebarModel-CShQi_Fw.js → useSidebarModel-CQwUXEO7.js} +1 -1
- package/web/assets/{workspace-folders-Dq7V_wOF.js → workspace-folders-BrFjAGZo.js} +1 -1
- package/web/assets/{workspace-order-store-PI98x5sR.js → workspace-order-store-DLX9fhcf.js} +1 -1
- package/web/index.html +2 -2
- package/web/assets/FocusRuntimeControls-CoxLbl8K.js +0 -2
- package/web/assets/command-LVPgEdXI.js +0 -1
- package/web/assets/i18n-DyMZgkZI.js +0 -1
- package/web/assets/public-diff-pNrf0LGG.js +0 -1
- package/web/assets/public-events-DmLE1dVC.js +0 -1
- package/web/assets/safe-mode-sentinel-BGslsjrl.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{l as t,m as n,u as r}from"./vendor-router-CSN_DGvx.js";import{t as i}from"./index-CiyAfWLi.js";import{i as a,r as o}from"./vendor-react-DwNgTV1j.js";import{n as s,p as c,u as l}from"./i18n-DyMZgkZI.js";import{t as u}from"./use-i18n-CsOCclo6.js";import{t as d}from"./http-response-DEs9jkgT.js";import{n as f}from"./http-B-XVZUum.js";import{t as p}from"./api-D1flkoh7.js";import{n as m}from"./runtime-capabilities-ChJVNwRz.js";import{t as h}from"./runtime-capabilities-store-MtXRlSIi.js";import{n as g}from"./client-store-e4OXhDNK.js";import{t as _}from"./createLucideIcon-Cd-3GVxJ.js";import{t as v}from"./activity-BCxvXCG3.js";import{t as y}from"./arrow-left-B8oVrQ2S.js";import{t as b}from"./arrow-right-DqLOhpA2.js";import{t as x}from"./arrow-up-right-B6l8qFZz.js";import{t as S}from"./bell-BjONAtgH.js";import{t as C}from"./bot-B3TaBp_T.js";import{t as w}from"./brain-qxhnKqYP.js";import{t as T}from"./check-2vYc6QaP.js";import{t as E}from"./chevron-down-CxtxIjiP.js";import{t as D}from"./chevron-left-BAtyp3_6.js";import{t as O}from"./chevron-up-D_ZcXjqr.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{i as I,o as L,s as ee}from"./settings-navigation-YxlR_1sv.js";import{t as te}from"./image-BY_c3FYU.js";import{t as ne}from"./info-DATxy0fb.js";import{n as R,t as re}from"./useMachines-BwvKcPVd.js";import{t as ie}from"./loader-circle-BOwQzHB-.js";import{t as z}from"./message-square-SKjZyY3v.js";import{t as ae}from"./monitor-smartphone-B1gIjItA.js";import{n as oe,r as se,t as ce}from"./zap-DZHw5afO.js";import{t as le}from"./pencil-U08v_vV9.js";import{t as ue}from"./play-DNDjDNGn.js";import{t as de}from"./plus-fQbSqB1n.js";import{t as fe}from"./refresh-cw-TbWxTY4K.js";import{t as pe}from"./rocket-BgLSjoHY.js";import{t as me}from"./rotate-ccw-C0v8V77_.js";import{t as he}from"./search-D0mqDaf_.js";import{t as ge}from"./server-BgNvmqwJ.js";import{t as _e}from"./shield-check-Gvek4RJ7.js";import{t as ve}from"./sliders-horizontal-Dryf1XyC.js";import{t as ye}from"./sparkles-S_eeuqn9.js";import{t as be}from"./trash-2-CNrPOoPR.js";import{t as xe}from"./triangle-alert-CE1q54ci.js";import{t as Se}from"./wrench-6pg6_bqI.js";import{t as Ce}from"./x-07u4-129.js";import{t as we}from"./brand-DIEc3fK8.js";import{a as Te}from"./dist-41X0pdUs.js";import{c as Ee,i as De,n as Oe,o as ke,s as Ae}from"./dist-BsRXXcSL.js";import{n as je,t as Me}from"./dist-DzGQ7sLi.js";import{a as Ne,i as Pe,n as Fe,o as Ie,r as Le,s as Re,t as ze}from"./collapsible-B-fc7n0u.js";import{t as Be}from"./dist-OB2r6Xsr.js";import{t as Ve}from"./checkbox-BrEHgFV0.js";import{n as He,r as Ue,t as We}from"./dist-BaBySQmo.js";import{c as Ge,i as Ke,n as qe,p as Je,r as Ye,t as Xe}from"./dropdown-menu-Ds0gD8S8.js";import{a as Ze,r as Qe,t as $e}from"./popover-DGWRnOht.js";import{a as et,i as tt,n as nt,r as rt,t as it}from"./select-DyBoNnz-.js";import{t as at}from"./separator-BPh_qxvc.js";import{t as ot}from"./slider-De8rWVNs.js";import{t as st}from"./switch-D_G8wFhs.js";import{t as ct}from"./segmented-control-xkrEOP_d.js";import{t as B}from"./utils-C8uzG5AZ.js";import{n as V,r as lt,t as H}from"./button-CCcCN8tE.js";import{n as ut,t as dt}from"./kbd-CAufZTkl.js";import{i as ft,t as pt}from"./config-search-a0xjM1yz.js";import{_ as mt,c as ht,d as gt,f as _t,h as vt,l as yt,m as bt,o as xt,p as St,t as Ct,u as wt}from"./shortcuts-C6ddcUau.js";import{a as Tt}from"./format-DMJQzoZ7.js";import{t as Et}from"./StatusGlyph-1KgitlUg.js";import{a as Dt,i as Ot,l as kt,o as At,s as jt,t as Mt}from"./dialog-DldLiTwf.js";import{t as U}from"./input-CPw-zkYh.js";import{t as Nt}from"./textarea-DmATpOqT.js";import{t as Pt}from"./model-display-kDwvtxrW.js";import{a as Ft,l as It,n as Lt,o as Rt,r as zt,s as Bt,t as Vt,u as Ht}from"./machines-api-BeimiMiu.js";import{n as Ut,r as Wt,t as Gt}from"./PageState-Cz6vFMXv.js";import{t as Kt}from"./useOverlayFocusReturn-NkxBSSjb.js";import{i as W,n as G,o as K,r as qt,s as Jt,t as q}from"./FeaturePage-DEjUrI25.js";import{n as J}from"./field-DoLEb0np.js";import{t as Yt}from"./MarkdownMessage-B9Bb9VQU.js";import{t as Y}from"./AppSelect-B15Hpk2W.js";import{n as Xt}from"./public-flags-DHN44K2T.js";import{n as Zt,t as X}from"./SettingsRow-CT0AZ7re.js";import{t as Qt}from"./BrandLogo-k3CvJjd4.js";import{t as $t}from"./badge-CWB3lj2H.js";import{a as en,i as tn,l as nn,n as rn,o as an,r as on,s as sn,t as cn}from"./app-primitives-BskZ4ZJj.js";import{r as ln}from"./session-inspector-store-C3BluNoW.js";import{t as un}from"./permission-rules-api-bHINce43.js";import{n as dn,t as fn}from"./machine-messages-CKHf8pyL.js";import{C as pn,_ as mn,a as hn,c as gn,d as _n,g as vn,i as yn,l as bn,o as xn,p as Sn,r as Cn,s as wn,v as Tn,x as En,y as Dn}from"./app-update-DWy3AK8N.js";import{a as On,n as kn,r as An,t as jn}from"./ShortcutKeys-CFnZogMX.js";import{a as Mn,i as Nn,n as Pn,r as Fn}from"./browser-notifications-CvHO-BlP.js";var In=_(`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=_(`blend`,[[`circle`,{cx:`9`,cy:`9`,r:`7`,key:`p2h5vp`}],[`circle`,{cx:`15`,cy:`15`,r:`7`,key:`19ennj`}]]),Rn=_(`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`}]]),zn=_(`fingerprint-pattern`,[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]]),Bn=_(`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`}]]),Vn=_(`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=_(`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`}]]),Un=_(`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`}]]),Wn=_(`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`}]]),Gn=_(`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`}]]),Kn=_(`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`}]]),qn=_(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Jn=_(`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`}]]),Yn=_(`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`}]]),Xn=_(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Zn=_(`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`}]]),Qn=_(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),Z=e(a(),1),Q=o(),$n=Object.defineProperty,er=(e,t)=>$n(e,`name`,{value:t,configurable:!0}),tr=`Accordion`,nr=[`Home`,`End`,`ArrowDown`,`ArrowUp`,`ArrowLeft`,`ArrowRight`],[rr,ir,ar]=je(tr),[or,sr]=Ae(tr,[ar,Re]),cr=Re(),lr=Z.forwardRef(er(function(e,t){let{type:n,...r}=e,i=r,a=r;return(0,Q.jsx)(rr.Provider,{scope:e.__scopeAccordion,children:n===`multiple`?(0,Q.jsx)(hr,{...a,ref:t}):(0,Q.jsx)(mr,{...i,ref:t})})},`Accordion`)),[ur,dr]=or(tr),[fr,pr]=or(tr,{collapsible:!1}),mr=Z.forwardRef(er(function(e,t){let{value:n,defaultValue:r,onValueChange:i=er(()=>{},`onValueChange`),collapsible:a=!1,...o}=e,[s,c]=De({prop:n,defaultProp:r??``,onChange:i,caller:tr});return(0,Q.jsx)(ur,{scope:e.__scopeAccordion,value:Z.useMemo(()=>s?[s]:[],[s]),onItemOpen:c,onItemClose:Z.useCallback(()=>a&&c(``),[a,c]),children:(0,Q.jsx)(fr,{scope:e.__scopeAccordion,collapsible:a,children:(0,Q.jsx)(vr,{...o,ref:t})})})},`AccordionImplSingle`)),hr=Z.forwardRef(er(function(e,t){let{value:n,defaultValue:r,onValueChange:i=er(()=>{},`onValueChange`),...a}=e,[o,s]=De({prop:n,defaultProp:r??[],onChange:i,caller:tr}),c=Z.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=Z.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,Q.jsx)(ur,{scope:e.__scopeAccordion,value:o,onItemOpen:c,onItemClose:l,children:(0,Q.jsx)(fr,{scope:e.__scopeAccordion,collapsible:!0,children:(0,Q.jsx)(vr,{...a,ref:t})})})},`AccordionImplMultiple`)),[gr,_r]=or(tr),vr=Z.forwardRef(er(function(e,t){let{__scopeAccordion:n,disabled:r,dir:i,orientation:a=`vertical`,...o}=e,s=Z.useRef(null),c=Te(s,t),l=ir(n),u=Me(i)===`ltr`,d=ke(e.onKeyDown,e=>{if(!nr.includes(e.key))return;let t=e.target,n=l().filter(e=>!e.ref.current?.disabled),r=n.findIndex(e=>e.ref.current===t),i=n.length;if(r===-1)return;e.preventDefault();let o=r,s=i-1,c=er(()=>{o=r+1,o>s&&(o=0)},`moveNext`),d=er(()=>{o=r-1,o<0&&(o=s)},`movePrev`);switch(e.key){case`Home`:o=0;break;case`End`:o=s;break;case`ArrowRight`:a===`horizontal`&&(u?c():d());break;case`ArrowDown`:a===`vertical`&&c();break;case`ArrowLeft`:a===`horizontal`&&(u?d():c());break;case`ArrowUp`:a===`vertical`&&d()}n[o%i].ref.current?.focus()});return(0,Q.jsx)(gr,{scope:n,disabled:r,direction:i,orientation:a,children:(0,Q.jsx)(rr.Slot,{scope:n,children:(0,Q.jsx)(Ee.div,{...o,"data-orientation":a,ref:c,onKeyDown:r?void 0:d})})})},`AccordionImpl`)),yr=`AccordionItem`,[br,xr]=or(yr),Sr=Z.forwardRef(er(function(e,t){let{__scopeAccordion:n,value:r,...i}=e,a=_r(yr,n),o=dr(yr,n),s=cr(n),c=Oe(),l=r&&o.value.includes(r)||!1,u=a.disabled||e.disabled;return(0,Q.jsx)(br,{scope:n,open:l,disabled:u,triggerId:c,children:(0,Q.jsx)(Ne,{"data-orientation":a.orientation,"data-state":kr(l),...s,...i,ref:t,disabled:u,open:l,onOpenChange:e=>{e?o.onItemOpen(r):o.onItemClose(r)}})})},`AccordionItem`)),Cr=`AccordionHeader`,wr=Z.forwardRef(er(function(e,t){let{__scopeAccordion:n,...r}=e,i=_r(tr,n),a=xr(Cr,n);return(0,Q.jsx)(Ee.h3,{"data-orientation":i.orientation,"data-state":kr(a.open),"data-disabled":a.disabled?``:void 0,...r,ref:t})},`AccordionHeader`)),Tr=`AccordionTrigger`,Er=Z.forwardRef(er(function(e,t){let{__scopeAccordion:n,...r}=e,i=_r(tr,n),a=xr(Tr,n),o=pr(Tr,n),s=cr(n);return(0,Q.jsx)(rr.ItemSlot,{scope:n,children:(0,Q.jsx)(Ie,{"aria-disabled":a.open&&!o.collapsible||void 0,"data-orientation":i.orientation,id:a.triggerId,...s,...r,ref:t})})},`AccordionTrigger`)),Dr=`AccordionContent`,Or=Z.forwardRef(er(function(e,t){let{__scopeAccordion:n,...r}=e,i=_r(tr,n),a=xr(Dr,n),o=cr(n);return(0,Q.jsx)(Pe,{role:`region`,"aria-labelledby":a.triggerId,"data-orientation":i.orientation,...o,...r,ref:t,style:{"--radix-accordion-content-height":`var(--radix-collapsible-content-height)`,"--radix-accordion-content-width":`var(--radix-collapsible-content-width)`,...e.style}})},`AccordionContent`));function kr(e){return e?`open`:`closed`}er(kr,`getState`);var Ar=lr,jr=Sr,Mr=wr,Nr=Er,Pr=Or,Fr=Object.defineProperty,Ir=(e,t)=>Fr(e,`name`,{value:t,configurable:!0}),Lr=`Radio`,[Rr,zr]=Ae(Lr),[Br,Vr]=Rr(Lr);function Hr(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]=Z.useState(null),[p,m]=Z.useState(null),h=Z.useRef(!1),[g,_]=Z.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:Ir(()=>s?.(),`onCheck`)};return(0,Q.jsx)(Br,{scope:t,...v,children:qr(u)?u(v):r})}Ir(Hr,`RadioProvider`);var Ur=`RadioTrigger`,Wr=Z.forwardRef(Ir(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}=Vr(Ur,e),p=Te(r,s);return(0,Q.jsx)(Ee.button,{type:`button`,role:`radio`,"aria-checked":i,"data-state":Jr(i),"data-disabled":a?``:void 0,disabled:a,value:o,...n,ref:p,onClick:ke(t,e=>{i||(u(),c()),f&&d&&(l.current=e.isPropagationStopped(),l.current||e.stopPropagation())})})},`RadioTrigger`)),Gr=`RadioBubbleInput`,Kr=Z.forwardRef(Ir(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}=Vr(Gr,e),h=Te(r,f),g=Be(i),_=Z.useRef(!1),v=Z.useRef(a),y=Z.useRef(m);Z.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=Z.useRef(a);return(0,Q.jsx)(Ee.input,{type:`radio`,"aria-hidden":!0,defaultChecked:b.current,required:o,disabled:s,name:c,value:l,form:u,...n,tabIndex:-1,ref:h,onClick:ke(t,e=>{_.current&&e.stopPropagation()}),style:{...n.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`RadioBubbleInput`));function qr(e){return typeof e==`function`}Ir(qr,`isFunction`);function Jr(e){return e?`checked`:`unchecked`}Ir(Jr,`getState`);var Yr=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`],Xr=`RadioGroup`,[Zr,Qr]=Ae(Xr,[Ue,zr]),$r=Ue(),ei=zr(),[ti,ni]=Zr(Xr),ri=Z.forwardRef(Ir(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=$r(n),h=Me(u),[g,_]=De({prop:o,defaultProp:a??null,onChange:f,caller:Xr}),[v,y]=Z.useState(null),b=Te(t,y),x=Z.useRef(g);return Z.useEffect(()=>{let e=i?v?.ownerDocument.getElementById(i):v?.closest(`form`);if(e instanceof HTMLFormElement){let t=Ir(()=>_(x.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[v,i,_]),(0,Q.jsx)(ti,{scope:n,name:r,form:i,required:s,disabled:c,value:g,onValueChange:_,children:(0,Q.jsx)(He,{asChild:!0,...m,orientation:l,dir:h,loop:d,children:(0,Q.jsx)(Ee.div,{role:`radiogroup`,"aria-required":s,"aria-orientation":l,"data-disabled":c?``:void 0,dir:h,...p,ref:b})})})},`RadioGroup`)),ii=`RadioGroupItemProvider`,ai=`RadioGroupItemTrigger`;function oi(e){let{__scopeRadioGroup:t,value:n,disabled:r,children:i,internal_do_not_use_render:a}=e,o=ni(ii,t),s=ei(t),c=o.disabled||r;return(0,Q.jsx)(Hr,{...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})}Ir(oi,`RadioGroupItemProvider`);var si=Z.forwardRef(Ir(function(e,t){let{__scopeRadioGroup:n,...r}=e,i=$r(n),a=ei(n),{checked:o,disabled:s}=Vr(ai,a.__scopeRadio),c=Z.useRef(null),l=Te(t,c),u=Z.useRef(!1);return Z.useEffect(()=>{let e=Ir(e=>{Yr.includes(e.key)&&(u.current=!0)},`handleKeyDown`),t=Ir(()=>u.current=!1,`handleKeyUp`);return document.addEventListener(`keydown`,e),document.addEventListener(`keyup`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`keyup`,t)}},[]),(0,Q.jsx)(We,{asChild:!0,...i,focusable:!s,active:o,children:(0,Q.jsx)(Wr,{...a,...r,ref:l,onKeyDown:ke(r.onKeyDown,e=>{e.key===`Enter`&&e.preventDefault()}),onFocus:ke(r.onFocus,()=>{u.current&&c.current?.click()})})})},`RadioGroupItemTrigger`)),ci=Z.forwardRef(Ir(function(e,t){let{__scopeRadioGroup:n,value:r,disabled:i,...a}=e;return(0,Q.jsx)(oi,{__scopeRadioGroup:n,value:r,disabled:i,internal_do_not_use_render:({isFormControl:e})=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(si,{...a,ref:t,__scopeRadioGroup:n}),e&&(0,Q.jsx)(li,{__scopeRadioGroup:n})]})})},`RadioGroupItem`)),li=Z.forwardRef(Ir(function(e,t){let{__scopeRadioGroup:n,...r}=e,i=ei(n);return(0,Q.jsx)(Kr,{...i,...r,ref:t})},`RadioGroupItemBubbleInput`));l.addResourceBundle(`zh-CN`,`labs`,{notice:`实验功能还在开发中,可能不稳定,也可能在之后的版本里调整或移除。每项单独开关,随时可以关掉;遇到问题请点「反馈」告诉我们。`,listTitle:`可试用的功能`,loading:`正在读取实验功能…`,loadFailed:`没能读取实验功能:{error}`,retry:`重试`,emptyTitle:`目前没有实验功能`,emptyDescription:`有新功能进入测试时,会出现在这里。`,"stage.experimental":`实验中`,"stage.preview":`即将毕业`,whenOffPrefix:`关掉后:`,feedback:`反馈`,toggleLabel:`开启或关闭“{name}”`,"saving.on":`正在开启…`,"saving.off":`正在关闭…`,enabledNow:`已开启,立即生效`,saveFailed:`没能保存:{error}。开关已恢复。`,"unavailable.runtime":`当前连接的 Runtime 不支持这个功能。升级那台机器上的 Pisper 后即可开启。`,openLinkFailed:`没能打开链接。`,"feature.bots.title":`Bots`,"feature.bots.description":`新建多个常驻的 Bot,在对话里交代事情;它们在自己的电脑上干活,改代码时用独立分支,改完交给你确认。`,"feature.bots.whenOff":`Bots 和它们的会话都不再显示;记录都保留,重新打开就回来。正在运行的任务会跑完。`}),l.addResourceBundle(`en-US`,`labs`,{notice:`Labs features are still in development. They may be unstable and may change or be removed in later versions. Each one has its own switch and can be turned off at any time; use Feedback to tell us about problems.`,listTitle:`Available to try`,loading:`Loading Labs features…`,loadFailed:`Couldn't load Labs features: {error}`,retry:`Retry`,emptyTitle:`No Labs features right now`,emptyDescription:`New features appear here when they enter testing.`,"stage.experimental":`Experimental`,"stage.preview":`Graduating soon`,whenOffPrefix:`When turned off: `,feedback:`Feedback`,toggleLabel:`Turn “{name}” on or off`,"saving.on":`Turning on…`,"saving.off":`Turning off…`,enabledNow:`On, effective immediately`,saveFailed:`Couldn't save: {error}. The switch was restored.`,"unavailable.runtime":`The connected Runtime doesn't support this feature. Update Pisper on that machine to turn it on.`,openLinkFailed:`Couldn't open the link.`,"feature.bots.title":`Bots`,"feature.bots.description":`Create several always-on Bots and tell them what to do in a chat. They work on their own computer, use a separate branch for code changes and hand the result to you to confirm.`,"feature.bots.whenOff":`Bots and their sessions are hidden everywhere; nothing is deleted, and turning it back on brings them back. Running tasks finish.`});function ui(e,t){if(typeof window>`u`||!window.__PISPER_MOBILE_APP__)return null;e.preventDefault();let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(`mobile_open_external_url`,{url:t}):Promise.reject(Error(`移动端原生桥不可用。`))}var di={bots:e=>({title:e(`labs:feature.bots.title`),description:e(`labs:feature.bots.description`),whenOff:e(`labs:feature.bots.whenOff`)})};function fi(e,t){return di[t]?.(e)??{title:t,description:``,whenOff:``}}function pi(e,t){return e(t===`preview`?`labs:stage.preview`:`labs:stage.experimental`)}function mi({notify:e}){let{t}=u(),n=Xt(e=>e.features),r=Xt(e=>e.status),i=Xt(e=>e.error),a=Xt(e=>e.pending),o=Xt(e=>e.rowErrors),s=Xt(e=>e.load),c=Xt(e=>e.setEnabled),[l,d]=(0,Z.useState)(()=>new Set);(0,Z.useEffect)(()=>{s()},[s]);let f=async(e,t)=>{await c(e,t);let n=Xt.getState(),r=!n.rowErrors[e]&&n.features.some(n=>n.id===e&&n.enabled===t);d(n=>{let i=new Set(n);return r&&t?i.add(e):i.delete(e),i})},p=n=>{ui(n,n.currentTarget.href)?.catch(()=>e(t(`labs:openLinkFailed`),`error`))},m;return m=r===`loading`&&n.length===0?(0,Q.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 py-6 text-sm text-content-muted`,children:[(0,Q.jsx)(lt,{"aria-hidden":`true`}),t(`labs:loading`)]}):n.length===0?r===`error`?null:(0,Q.jsx)(Gt,{compact:!0,icon:ee,title:t(`labs:emptyTitle`),description:t(`labs:emptyDescription`)}):(0,Q.jsx)(G,{children:n.map(e=>{let n=fi(t,e.id),r=a[e.id]===!0,i=o[e.id];return(0,Q.jsx)(W,{"data-beta-feature":e.id,"data-enabled":e.enabled,icon:(0,Q.jsx)(ee,{}),name:n.title,status:(0,Q.jsx)($t,{variant:`outline`,children:pi(t,e.stage)}),description:n.description||void 0,actions:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[r&&(0,Q.jsxs)(`span`,{role:`status`,className:`flex items-center gap-1.5 text-xs text-content-muted`,children:[(0,Q.jsx)(lt,{"aria-hidden":`true`}),e.enabled?t(`labs:saving.on`):t(`labs:saving.off`)]}),(0,Q.jsx)(st,{checked:e.enabled,disabled:r||!e.available,"aria-busy":r,"aria-label":t(`labs:toggleLabel`,{name:n.title}),onCheckedChange:t=>void f(e.id,t)})]}),detail:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5 pb-3 text-xs leading-relaxed text-content-muted`,children:[n.whenOff&&(0,Q.jsxs)(`p`,{children:[t(`labs:whenOffPrefix`),n.whenOff]}),e.feedbackUrl&&(0,Q.jsxs)(`a`,{className:`inline-flex w-fit items-center gap-1 text-content-secondary underline decoration-stroke-strong underline-offset-3 hover:text-content`,href:e.feedbackUrl,target:`_blank`,rel:`noopener noreferrer`,"data-web-preview":`external`,onClick:p,children:[t(`labs:feedback`),(0,Q.jsx)(F,{className:`size-3.5`,"aria-hidden":`true`})]}),!e.available&&(0,Q.jsxs)(`p`,{className:`flex items-start gap-1.5 text-content-secondary`,children:[(0,Q.jsx)(ne,{className:`mt-[3px] size-3.5 flex-none`,"aria-hidden":`true`}),t(`labs:unavailable.runtime`)]}),e.enabled&&l.has(e.id)&&!r&&(0,Q.jsxs)(`p`,{role:`status`,className:`flex items-center gap-1.5 text-content-secondary`,children:[(0,Q.jsx)(T,{className:`size-3.5 flex-none`,"aria-hidden":`true`}),t(`labs:enabledNow`)]}),i&&(0,Q.jsx)(q,{className:`mt-1`,children:(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[t(`labs:saveFailed`,{error:i.message}),(0,Q.jsx)(H,{size:`sm`,variant:`outline`,onClick:()=>void f(e.id,i.desired),children:t(`labs:retry`)})]})})]})},e.id)})}),(0,Q.jsxs)(`div`,{"data-labs-settings":!0,className:`flex min-w-0 flex-col`,children:[(0,Q.jsxs)(`p`,{role:`note`,className:`flex items-start gap-2 rounded-[var(--r-md)] bg-surface-subtle px-3 py-2.5 text-[13px] leading-relaxed text-content-secondary`,children:[(0,Q.jsx)(ee,{className:`mt-[3px] size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),t(`labs:notice`)]}),r===`error`&&(0,Q.jsx)(q,{children:(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[t(`labs:loadFailed`,{error:i}),(0,Q.jsx)(H,{size:`sm`,variant:`outline`,onClick:()=>void s(),children:t(`labs:retry`)})]})}),(0,Q.jsx)(K,{title:t(`labs:listTitle`),count:n.length||void 0,children:m})]})}function hi({className:e,...t}){return(0,Q.jsx)(cn,{"data-settings-card":!0,className:B(`rounded-none border-x-0 border-t border-b-0 border-stroke-soft bg-transparent px-0`,e),...t})}var gi=an,_i=nn;function vi(e){return(0,Q.jsx)(sn,{density:`compact`,...e})}function yi({className:e,...t}){return(0,Q.jsx)(`div`,{"data-settings-group":!0,className:B(`@container/card min-w-0 divide-y divide-stroke-soft border-y border-stroke-soft`,e),...t})}function bi({label:e,help:t,htmlFor:n,labelId:r,helpId:i,children:a,className:o}){return(0,Q.jsxs)(`div`,{className:B(`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,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`label`,{id:r,htmlFor:n,className:`text-sm font-medium text-content`,children:e}),t&&(0,Q.jsx)(`p`,{id:i,className:`mt-0.5 text-xs text-content-muted`,children:t})]}),(0,Q.jsx)(`div`,{className:`min-w-0 @min-[480px]/card:max-w-[460px]`,children:a})]})}var xi=`0.6.41`,Si=`https://github.com/ling-kong-ran/pisper`,Ci=`${Si}/blob/release/LICENSE`;function wi({href:e,icon:t,label:n,value:r,onClick:i}){return(0,Q.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,Q.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,Q.jsx)(t,{size:16,"aria-hidden":`true`})}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-content`,children:n}),(0,Q.jsx)(`span`,{className:`mt-0.5 block truncate font-mono text-xs text-content-muted`,children:r})]}),(0,Q.jsx)(F,{"aria-hidden":`true`,className:`text-content-muted transition-colors group-hover:text-content`,size:14})]})}function Ti({update:e,notify:t}){let{t:n}=u(),r=e.info?.version||xi,i=e=>{ui(e,e.currentTarget.href)?.catch(()=>t(n(`config:aboutSettings.openLinkFailed`),`error`))};return(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 rounded-[15px] shadow-raise`,children:(0,Q.jsx)(Qt,{size:56})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-[length:calc(var(--ui-font-size)*10/7)] leading-[1.3] font-semibold tracking-[-.015em] text-content`,children:`Pisper`}),(0,Q.jsxs)(_i,{tone:`gray`,className:`font-mono`,children:[`v`,r]})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-content-muted`,children:n(`config:aboutSettings.description`)})]})]}),(0,Q.jsxs)(`section`,{"data-config-card":`about-project`,children:[(0,Q.jsx)(gi,{title:n(`config:aboutSettings.projectInformation`),className:`mb-3 text-[15px] leading-6 font-medium text-content`}),(0,Q.jsxs)(yi,{children:[(0,Q.jsx)(wi,{href:Si,icon:j,label:n(`config:aboutSettings.sourceCode`),value:`github.com/ling-kong-ran/pisper`,onClick:i}),(0,Q.jsx)(wi,{href:Ci,icon:Gn,label:n(`config:aboutSettings.license`),value:`MIT License`,onClick:i})]})]}),(0,Q.jsx)(hi,{className:`py-4`,"data-config-card":`about-support`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 max-[540px]:flex-col max-[540px]:items-stretch`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(gi,{title:n(`config:aboutSettings.supportPisper`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 max-w-[520px] text-xs leading-5 text-content-muted`,children:n(`config:aboutSettings.supportDescription`)})]}),(0,Q.jsx)(H,{asChild:!0,className:`max-[650px]:h-11 max-[540px]:w-full`,children:(0,Q.jsxs)(`a`,{href:Si,target:`_blank`,rel:`noopener noreferrer`,"data-web-preview":`external`,onClick:i,children:[(0,Q.jsx)(Jn,{size:15}),n(`config:aboutSettings.starOnGitHub`)]})})]})}),(0,Q.jsx)(`p`,{className:`text-center text-xs text-content-muted`,children:n(`config:aboutSettings.copyright`)})]})}function Ei(e){window.dispatchEvent(new CustomEvent(`pisper:desktop-pet-changed`,{detail:e}))}function Di({notify:e,requestConfirm:t}){let{t:n}=u(),r=window.pisperDesktop,i=(0,Z.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:()=>p(`/api/desktop-pet`),setEnabled:e=>p(`/api/desktop-pet/enabled`,{method:`POST`,body:{enabled:e}}),setOpacity:e=>p(`/api/desktop-pet/opacity`,{method:`POST`,body:{opacity:e}}),search:e=>p(`/api/desktop-pet/catalog?query=${encodeURIComponent(e)}`),install:e=>p(`/api/desktop-pet/install`,{method:`POST`,body:{slug:e}}),select:e=>p(`/api/desktop-pet/select`,{method:`POST`,body:{slug:e}}),remove:e=>p(`/api/desktop-pet/${encodeURIComponent(e)}`,{method:`DELETE`}),openCatalog:()=>window.open(`https://petdex.dev`,`_blank`,`noopener,noreferrer`)},[r]),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(``),[l,d]=(0,Z.useState)([]),[f,m]=(0,Z.useState)(100),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),y=(0,Z.useCallback)(e=>{o(e),m(Math.round((e.opacity??1)*100))},[]),b=(0,Z.useCallback)(async()=>{try{v(``),y(await i.getStatus())}catch(e){v(e instanceof Error?e.message:String(e))}},[y,i]),x=(0,Z.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,Z.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),Ei(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),Ei(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),Ei(r),e(n(`config:desktopPetSettings.petInstalled`,{name:r.selectedName||t}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(``)}}},E=async t=>{if(t!==a?.selectedSlug){g(`select:${t}`);try{v(``);let r=await i.select(t);y(r),Ei(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),Ei(t),e(n(`config:desktopPetSettings.petRemoved`,{name:r.name}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(``)}}};return(0,Q.jsxs)(Q.Fragment,{children:[_&&(0,Q.jsx)(q,{children:_}),(0,Q.jsx)(K,{title:n(`config:desktopPetSettings.displayTitle`),"data-config-card":`desktop-pet-settings`,children:a?(0,Q.jsxs)(G,{children:[(0,Q.jsx)(W,{icon:(0,Q.jsx)(Rn,{}),name:n(`config:desktopPetSettings.showOnDesktop`),description:a.selectedName?n(`config:desktopPetSettings.currentPet`,{name:a.selectedName}):n(`config:desktopPetSettings.installBeforeEnabling`),status:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[a.running&&(0,Q.jsx)(Et,{status:`done`,className:`size-3.5`}),a.running?n(`config:desktopPetSettings.running`):n(`config:desktopPetSettings.stopped`)]}),actions:(0,Q.jsx)(st,{checked:a.enabled,disabled:!!h||!a.installed.length,onCheckedChange:e=>void S(e),"aria-label":n(`config:desktopPetSettings.showOnDesktop`)})}),(0,Q.jsx)(W,{icon:(0,Q.jsx)(Ln,{}),name:n(`config:desktopPetSettings.opacity`),nameMeta:`${f}%`,actions:(0,Q.jsx)(ot,{value:[f],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,Q.jsx)(Ut,{kind:`loading`,title:n(`config:desktopPetSettings.loading`)})}),(0,Q.jsxs)(K,{title:n(`config:desktopPetSettings.installTitle`),"data-config-card":`desktop-pet-install`,description:n(`config:desktopPetSettings.installDescription`),actions:(0,Q.jsxs)(H,{variant:`ghost`,size:`sm`,onClick:i.openCatalog,children:[(0,Q.jsx)(F,{}),n(`config:desktopPetSettings.browsePetdex`)]}),children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex gap-2`,children:[(0,Q.jsx)(U,{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,Q.jsxs)(H,{variant:`secondary`,className:`h-9 shrink-0 pointer-coarse:h-11 max-[650px]:h-11`,disabled:h===`search`,onClick:x,children:[h===`search`?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(he,{}),n(`config:desktopPetSettings.search`)]})]}),l.length>0&&(0,Q.jsx)(G,{children:l.map(e=>{let t=a?.installed.some(t=>t.slug===e.slug);return(0,Q.jsx)(W,{"data-pet-catalog":e.slug,icon:(0,Q.jsx)(Rn,{}),name:e.displayName,nameMeta:e.slug,status:t?n(`config:desktopPetSettings.installed`):void 0,actions:(0,Q.jsxs)(H,{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?E(e.slug):w(e.slug)),children:[t?(0,Q.jsx)(T,{}):(0,Q.jsx)(N,{}),n(t?`config:desktopPetSettings.use`:`config:desktopPetSettings.install`)]})},e.slug)})})]}),a&&a.installed.length>0&&(0,Q.jsx)(K,{title:n(`config:desktopPetSettings.installedTitle`),count:a.installed.length,"data-config-card":`desktop-pet-installed`,description:n(`config:desktopPetSettings.installedDescription`),children:(0,Q.jsx)(G,{children:a.installed.map(e=>{let t=e.slug===a.selectedSlug;return(0,Q.jsx)(W,{"data-pet-installed":e.slug,"data-selected":t||void 0,className:B(`relative`,t&&`after:absolute after:inset-y-3 after:-left-3 after:w-[3px] after:rounded-full after:bg-star`),icon:(0,Q.jsx)(Rn,{}),name:e.name,nameMeta:`${e.slug} · ${e.source===`pisper`?`Pisper`:`Petdex`}`,status:t?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,Q.jsx)(Et,{status:`done`,className:`size-3.5`}),n(`config:desktopPetSettings.inUse`)]}):void 0,actions:(0,Q.jsxs)(Q.Fragment,{children:[!t&&(0,Q.jsx)(H,{size:`sm`,variant:`ghost`,disabled:!!h,"aria-label":`${n(`config:desktopPetSettings.use`)}: ${e.name}`,onClick:()=>void E(e.slug),children:n(`config:desktopPetSettings.use`)}),e.source===`pisper`&&(0,Q.jsx)(H,{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,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(be,{})})]})},`${e.source}:${e.slug}`)})})})]})}function $(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 Oi(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 ki,Ai,ji,Mi,Ni,Pi,Fi=`__TAURI_TO_IPC_KEY__`;function Ii(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}var Li=class{constructor(e){ki.add(this),Ai.set(this,void 0),ji.set(this,0),Mi.set(this,[]),Ni.set(this,void 0),Oi(this,Ai,e||(()=>{}),`f`),this.id=Ii(e=>{let t=e.index;if(`end`in e){t==$(this,ji,`f`)?this.cleanupCallback():Oi(this,Ni,t,`f`);return}let n=e.message;if(t==$(this,ji,`f`)){for($(this,ki,`m`,Pi).call(this,n),Oi(this,ji,$(this,ji,`f`)+1,`f`);$(this,ji,`f`)in $(this,Mi,`f`);){let e=$(this,Mi,`f`)[$(this,ji,`f`)];$(this,ki,`m`,Pi).call(this,e),delete $(this,Mi,`f`)[$(this,ji,`f`)],Oi(this,ji,$(this,ji,`f`)+1,`f`)}$(this,ji,`f`)===$(this,Ni,`f`)&&this.cleanupCallback()}else $(this,Mi,`f`)[t]=n})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){Oi(this,Ai,e,`f`)}get onmessage(){return $(this,Ai,`f`)}[(Ai=new WeakMap,ji=new WeakMap,Mi=new WeakMap,Ni=new WeakMap,ki=new WeakSet,Pi=function(e){try{$(this,Ai,`f`).call(this,e)}catch(e){queueMicrotask(()=>{throw e})}},Fi)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[Fi]()}};function Ri(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function zi(e,t){return Ri(`plugin:barcode-scanner|${e}`,t)}function Bi(e){return e instanceof Error?e.message:String(e)}function Vi(e){return/cancel(?:led|ed)/i.test(Bi(e))}function Hi(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function Ui(e){return Array.isArray(e)?new TextDecoder().decode(Uint8Array.from(e)):``}function Wi(e){if(!e.isActive||!e.port)return null;let t=Ui(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=Ui(e.txt.name)||e.name||`Pisper Desktop`,a=`https://${r}:${e.port}`;return{id:`${e.fullName}:${a}`,name:i,url:a,fingerprint:t}}function Gi(e){return new Promise(t=>window.setTimeout(t,e))}function Ki({open:e,onOpenChange:t}){let{t:n}=u(),r=Kt(e),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)([]),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),b=(0,Z.useRef)(!1),x=(0,Z.useRef)(!1),S=(0,Z.useRef)(!1),C=(0,Z.useRef)(0),w=(0,Z.useRef)(``),T=(0,Z.useCallback)(e=>{b.current=e,s(e)},[]),E=(0,Z.useCallback)(async()=>{x.current=!0,b.current&&await zi(`cancel`).catch(()=>void 0),T(!1),a(null)},[T]);(0,Z.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,Z.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,Z.useCallback)(async()=>{let e=++C.current;f(!0),m(``),l([]);let t=new Li;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){l(e=>e.filter(e=>!e.id.startsWith(`${t.service?.fullName}:`)));return}let r=Wi(t.service);r&&l(e=>[...e.filter(e=>e.fingerprint!==r.fingerprint),r])};let r=null;try{await Ri(`mobile_ensure_local_network_permission`),r=(await Ri(`plugin:dns-sd|browse_start`,{options:{service:{type:`pisper`,protocol:`tcp`,domain:`local`},timeoutMs:4e3},channel:t})).browseId,await Gi(4300)}catch(t){C.current===e&&m(Bi(t).includes(`local_network_permission_denied`)?n(`config:mobileServer.localNetworkDenied`):n(`config:mobileServer.discoveryFailed`))}finally{r!==null&&await Ri(`plugin:dns-sd|browse_stop`,{browseId:r}).catch(()=>void 0),C.current===e&&f(!1)}},[n]);(0,Z.useEffect)(()=>{if(!(!e||o))return O(),()=>{C.current+=1}},[O,e,o]);let k=(0,Z.useCallback)(async()=>{let e=w.current;w.current=``,e&&await Ri(`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 Ri(`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(Bi(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 zi(`check_permissions`);if(e.camera!==`granted`&&(e=await zi(`request_permissions`)),e.camera!==`granted`)throw Error(n(`config:mobileServer.cameraDenied`));if(x.current||(T(!0),await Hi(),x.current))return;let t=await zi(`scan`,{windowed:!0,formats:[]});if(!t.content)throw Error(n(`config:mobileServer.scanFailed`));S.current=!0,D(await Ri(`mobile_pair`,{payloadJson:t.content,deviceName:null}))}catch(e){!x.current&&!Vi(e)&&v(Bi(e))}finally{T(!1),a(null),x.current=!1}};return(0,Q.jsx)(Mt,{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,Q.jsx)(Ot,{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,Q.jsxs)(`div`,{className:`flex h-dvh w-screen flex-col overflow-hidden`,children:[(0,Q.jsxs)(jt,{className:`sr-only`,children:[(0,Q.jsx)(kt,{children:n(`config:mobileServer.scanTitle`)}),(0,Q.jsx)(Dt,{children:n(`config:mobileServer.scanHint`)})]}),(0,Q.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,Q.jsxs)(H,{variant:`ghost`,className:`h-10 bg-black/40 px-3 text-white hover:bg-black/70 hover:text-white`,onClick:()=>void E(),children:[(0,Q.jsx)(y,{}),n(`config:mobileServer.cancelScan`)]}),(0,Q.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium`,children:n(`config:mobileServer.scanTitle`)}),(0,Q.jsx)(`div`,{className:`w-[88px]`,"aria-hidden":`true`})]}),(0,Q.jsx)(`main`,{className:`grid min-h-0 flex-1 place-items-center p-6`,children:(0,Q.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,Q.jsx)(Kn,{className:`absolute top-1/2 left-1/2 size-10 -translate-x-1/2 -translate-y-1/2 text-white/75`})})}),(0,Q.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,Q.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-white/90`,children:n(`config:mobileServer.scanHint`)}),(0,Q.jsx)(H,{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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(jt,{children:[(0,Q.jsx)(kt,{children:n(`config:mobileServer.addServer`)}),(0,Q.jsx)(Dt,{children:n(`config:mobileServer.discoverDescription`)})]}),(0,Q.jsxs)(`section`,{className:`grid gap-2`,"aria-live":`polite`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Q.jsx)(Wn,{className:`size-4`}),n(`config:mobileServer.nearby`)]}),(0,Q.jsx)(H,{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,Q.jsx)(fe,{className:d?`animate-spin`:void 0})})]}),c.length?(0,Q.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,Q.jsxs)(`li`,{className:`flex min-h-12 items-center justify-between gap-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(ge,{className:`size-4 flex-none text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`truncate text-sm`,children:e.name}),(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.url})]})]}),(0,Q.jsxs)(H,{size:`sm`,className:`pointer-coarse:min-h-11`,disabled:i!==null,onClick:()=>void A(e),children:[t?(0,Q.jsx)(ie,{className:`animate-spin`}):null,n(`config:mobileServer.requestConnect`)]})]},e.id)})}):(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:n(d?`config:mobileServer.discovering`:`config:mobileServer.noNearby`)}),p?(0,Q.jsx)(`p`,{role:`alert`,className:`text-xs leading-relaxed text-content-secondary`,children:p}):null,h?(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-[var(--r-md)] bg-surface-subtle px-3 py-2`,children:[(0,Q.jsx)(`p`,{role:`status`,className:`text-xs leading-relaxed`,children:h}),(0,Q.jsx)(H,{size:`sm`,variant:`outline`,className:`pointer-coarse:min-h-11`,onClick:()=>void k(),children:n(`config:mobileServer.cancelRequest`)})]}):null]}),(0,Q.jsxs)(`div`,{className:`relative py-1`,children:[(0,Q.jsx)(at,{}),(0,Q.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,Q.jsxs)(H,{className:`w-full pointer-coarse:min-h-11`,disabled:i!==null,onClick:()=>void j(),children:[i===`scan`?(0,Q.jsx)(ie,{className:`animate-spin`}):(0,Q.jsx)(Un,{}),n(`config:mobileServer.scan`)]}),_?(0,Q.jsx)(`p`,{role:`alert`,className:`text-xs leading-relaxed text-content-secondary`,children:_}):null]})})})}function qi(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function Ji({requestConfirm:e}){let{t}=u(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),d=(0,Z.useCallback)(async()=>{try{r(await qi(`mobile_state`)),a(``)}catch{a(t(`config:mobileServer.loadFailed`))}},[t]);(0,Z.useEffect)(()=>{d()},[d]);let f=async(e,t,n=``)=>{s(n||e);try{r(await qi(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 qi(`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,Q.jsxs)(Q.Fragment,{children:[(0,Q.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,Q.jsx)(Et,{status:`done`,className:`size-3.5`}):(0,Q.jsx)(k,{className:`size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:v}),n?.activeTransport?(0,Q.jsx)(`span`,{className:`flex-none font-mono text-xs text-content-muted`,children:y(n.activeTransport)}):null]}),(0,Q.jsx)(Ki,{open:c,onOpenChange:l}),i?(0,Q.jsx)(q,{className:`mt-3`,children:i}):null,(0,Q.jsx)(K,{title:t(`config:mobileServer.localTitle`),"data-config-card":`mobile-server-local`,children:(0,Q.jsx)(G,{children:(0,Q.jsx)(W,{icon:(0,Q.jsx)(qn,{}),name:t(`config:mobileServer.localTitle`),description:t(`config:mobileServer.localDescription`),status:h?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,Q.jsx)(Et,{status:`done`,className:`size-3.5`}),t(`config:mobileServer.currentLocal`)]}):void 0,actions:h?void 0:(0,Q.jsx)(H,{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 qi(`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,Q.jsx)(K,{title:t(`config:mobileServer.title`),count:n?.servers?.length??0,"data-config-card":`mobile-server-main`,description:t(`config:mobileServer.description`),actions:(0,Q.jsxs)(H,{size:`sm`,onClick:()=>l(!0),children:[(0,Q.jsx)(de,{}),t(`config:mobileServer.addServer`)]}),children:n?.servers?.length?(0,Q.jsx)(G,{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,Q.jsx)(W,{"data-mobile-server":e.id,icon:(0,Q.jsx)(ge,{}),name:e.name,nameMeta:t(i&&a?`config:mobileServer.transportLanP2p`:a?`config:mobileServer.transportP2p`:`config:mobileServer.transportLan`),description:(0,Q.jsx)(`span`,{className:`font-mono`,children:s}),status:r?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,Q.jsx)(Et,{status:`done`,className:`size-3.5`}),n.activeTransport?t(`config:mobileServer.activeTransport`,{transport:y(n.activeTransport)}):t(`config:mobileServer.current`)]}):void 0,actions:(0,Q.jsxs)(Q.Fragment,{children:[r?null:(0,Q.jsx)(H,{size:`sm`,variant:`ghost`,disabled:o===e.id,onClick:()=>void m(e.id),children:t(`config:mobileServer.connect`)}),(0,Q.jsx)(H,{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,Q.jsx)(be,{})})]})},e.id)})}):(0,Q.jsx)(Gt,{compact:!0,title:t(`config:mobileServer.empty`)})})]})}l.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 服务器地址`}),l.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 Yi({notify:e}){let{t,language:n}=u(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)([]),[l,d]=(0,Z.useState)([]),[f,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(``),E=(0,Z.useCallback)(async()=>{try{let[e,t,n,r]=await Promise.all([p(`/api/remote/status`),p(`/api/remote/devices`),p(`/api/remote/pairing-requests`).catch(()=>({requests:[]})),p(`/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,Z.useEffect)(()=>{E()},[E]),(0,Z.useEffect)(()=>{if(!r?.listening)return;let e=window.setInterval(()=>void E(),2e3);return()=>window.clearInterval(e)},[E,r?.listening]);let D=async n=>{S(!0);try{await p(`/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 E()}catch(n){e(t(`config:remoteAccess.toggleFailed`,{message:String(n)}),`error`)}finally{S(!1)}},O=async()=>{S(!0);try{await p(`/api/remote/firewall/retry`,{method:`POST`,body:{},timeout:15e4}),await E()}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 p(`/api/remote/pairing-code`,{method:`POST`});if(!e?.code||!e?.expiresAt)throw Error(t(`config:remoteAccess.qrUnavailable`));e.connectionInfo=await p(`/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 p(`/api/remote/pairing-requests/${encodeURIComponent(n.id)}/decision`,{method:`POST`,body:{approved:r}}),await E()}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 p(`/api/remote/devices/${encodeURIComponent(n.id)}/revoke`,{method:`POST`}),await E()}catch(n){e(t(`config:remoteAccess.revokeFailed`,{message:String(n)}),`error`)}};if(C&&!r)return(0,Q.jsx)(Ut,{kind:`error`,title:t(`config:remoteAccess.loadFailed`),action:(0,Q.jsxs)(H,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void E(),children:[(0,Q.jsx)(fe,{}),t(`config:remoteAccess.refresh`)]})});if(!r)return(0,Q.jsx)(Ut,{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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Mt,{open:h&&f!==null,onOpenChange:g,children:(0,Q.jsxs)(Ot,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(jt,{children:[(0,Q.jsx)(kt,{children:t(`config:remoteAccess.pairingQrTitle`)}),(0,Q.jsx)(Dt,{children:t(`config:remoteAccess.scanQrDescription`)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-2`,"aria-live":`polite`,children:[f?.qrDataUrl?(0,Q.jsx)(`img`,{src:f.qrDataUrl,alt:t(`config:remoteAccess.qrAlt`),className:`size-64 max-w-full rounded-sm border border-stroke bg-white p-2`}):null,_?(0,Q.jsx)(`p`,{role:`alert`,className:`text-center text-xs leading-relaxed text-content-secondary`,children:_}):null,f?(0,Q.jsxs)(`div`,{className:`text-center`,children:[(0,Q.jsx)(`div`,{className:`font-mono text-[20px] font-medium tracking-[0.2em] text-content`,children:f.code}),(0,Q.jsx)(`div`,{className:`mt-1 text-xs text-content-muted tabular-nums`,children:t(`config:remoteAccess.codeExpiresAt`,{time:Tt(f.expiresAt,n)})})]}):null]}),f?.connectionInfo&&(0,Q.jsxs)(`details`,{className:`min-w-0 rounded-md border border-stroke px-3 py-2 text-sm`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-content-secondary`,children:t(`remote-workspace:manualConnection`)}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-2 text-xs text-content-muted`,children:[(0,Q.jsx)(`div`,{children:t(`remote-workspace:serverAddress`)}),f.connectionInfo.endpoints.map(e=>(0,Q.jsx)(`code`,{className:`block font-mono break-all text-content select-all`,children:e.url},e.url)),(0,Q.jsx)(`div`,{children:t(`remote-workspace:fingerprint`)}),(0,Q.jsx)(`code`,{className:`block font-mono break-all text-content select-all`,children:f.connectionInfo.fingerprint})]})]}),(0,Q.jsx)(At,{children:(0,Q.jsxs)(H,{disabled:x,onClick:()=>void j(),children:[x?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(fe,{}),t(x?`config:remoteAccess.generatingQr`:`config:remoteAccess.regenerate`)]})})]})}),C&&(0,Q.jsx)(q,{children:C}),(0,Q.jsx)(K,{title:t(`config:remoteAccess.thisComputer`),"data-config-card":`remote-access-main`,children:(0,Q.jsxs)(G,{children:[(0,Q.jsx)(W,{icon:(0,Q.jsx)(ae,{}),name:t(`config:remoteAccess.allowConnections`),description:t(`config:remoteAccess.description`),status:(0,Q.jsx)(Xi,{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,Q.jsx)(st,{checked:r.enabled,disabled:x,onCheckedChange:e=>void D(e),"aria-label":t(`config:remoteAccess.title`)}),detail:r.error?(0,Q.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,Q.jsx)(W,{"aria-live":`polite`,icon:(0,Q.jsx)(_e,{}),name:t(`config:remoteAccess.firewallTitle`),description:a.busy?t(`config:remoteAccess.firewallWorking`):k[a.state],status:a.busy?(0,Q.jsx)(Xi,{glyph:`run`,children:t(`config:remoteAccess.firewallChecking`)}):F?(0,Q.jsx)(Xi,{attention:!0,children:t(`config:remoteAccess.firewallNeedsYou`)}):void 0,actions:r.enabled||a.state===`cleanup_pending`?(0,Q.jsxs)(H,{size:`sm`,variant:`secondary`,disabled:x||a.busy,onClick:()=>void O(),children:[x||a.busy?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(fe,{}),r.enabled?t(`config:remoteAccess.firewallRetry`):t(`config:remoteAccess.firewallRetryCleanup`)]}):void 0,detail:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-xs leading-relaxed text-content-muted`,children:[a.reason&&A[a.reason]?(0,Q.jsx)(`p`,{className:`text-content-secondary`,children:A[a.reason]}):null,r.enabled?(0,Q.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,Q.jsx)(`p`,{children:t(`config:remoteAccess.firewallReachability`)}),a.checkedAt?(0,Q.jsx)(`p`,{className:`tabular-nums`,children:t(`config:remoteAccess.firewallCheckedAt`,{time:Tt(a.checkedAt,n)})}):null]})}):null]})}),r.listening&&l.length?(0,Q.jsx)(K,{"aria-live":`polite`,title:t(`config:remoteAccess.pendingApprovals`),count:l.length,meta:(0,Q.jsx)(`span`,{className:`font-medium text-st-attn`,children:t(`config:remoteAccess.waitingForYou`)}),description:t(`config:remoteAccess.pendingApprovalsDescription`),children:(0,Q.jsx)(G,{children:l.map(e=>(0,Q.jsx)(W,{"data-pairing-request":e.id,icon:(0,Q.jsx)(qn,{}),name:e.deviceName,description:(0,Q.jsx)(`span`,{className:`font-mono`,children:t(`config:remoteAccess.requestSource`,{ip:e.ip})}),meta:t(`config:remoteAccess.requestedAt`,{time:Tt(e.requestedAt,n)}),actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(H,{size:`sm`,variant:`ghost`,disabled:y===e.id,onClick:()=>void M(e,!1),children:[(0,Q.jsx)(Ce,{}),t(`config:remoteAccess.reject`)]}),(0,Q.jsxs)(H,{size:`sm`,disabled:y===e.id,onClick:()=>void M(e,!0),children:[y===e.id?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(T,{}),t(`config:remoteAccess.approve`)]})]})},e.id))})}):null,r.listening?(0,Q.jsx)(K,{title:t(`config:remoteAccess.pairing`),"data-config-card":`remote-access-pairing`,children:(0,Q.jsx)(G,{children:(0,Q.jsx)(W,{icon:(0,Q.jsx)(Un,{}),name:t(`config:remoteAccess.pairWithPhone`),description:t(`config:remoteAccess.pairingDescription`),actions:(0,Q.jsxs)(H,{size:`sm`,disabled:x,onClick:()=>void j(),children:[x?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(Un,{}),t(x?`config:remoteAccess.generatingQr`:`config:remoteAccess.generateQr`)]}),detail:_&&!h?(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-content-secondary`,"aria-live":`polite`,children:_}):void 0})})}):null,(0,Q.jsx)(K,{title:t(`config:remoteAccess.devices`),count:s.length,"data-config-card":`remote-access-devices`,actions:(0,Q.jsx)(H,{size:`icon-sm`,variant:`ghost`,className:`pointer-coarse:size-11 max-[650px]:size-11`,onClick:()=>void E(),"aria-label":t(`config:remoteAccess.refresh`),title:t(`config:remoteAccess.refresh`),children:(0,Q.jsx)(fe,{})}),children:s.length===0?(0,Q.jsx)(Gt,{compact:!0,title:t(`config:remoteAccess.noDevices`)}):(0,Q.jsx)(G,{children:s.map(e=>(0,Q.jsx)(W,{icon:(0,Q.jsx)(qn,{}),name:e.name,nameMeta:e.current?t(`config:remoteAccess.currentDevice`):void 0,description:t(`config:remoteAccess.lastSeen`,{time:Tt(e.lastSeenAt,n)}),actions:(0,Q.jsx)(H,{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 Xi({attention:e=!1,glyph:t=null,children:n}){let r=e?`attention`:t;return(0,Q.jsxs)(`span`,{className:B(`inline-flex min-w-0 items-center gap-1.5 whitespace-nowrap`,e?`font-medium text-st-attn`:`text-content-secondary`),children:[r&&(0,Q.jsx)(Et,{status:r,className:`size-3.5`}),n]})}function Zi({requestConfirm:e}){let{t}=u(),n=window.pisperDesktop?.remoteWorkspaces,[r,i]=(0,Z.useState)([]),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),[l,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(``),v=(0,Z.useCallback)(async()=>{n&&i(await n.list())},[n]);(0,Z.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,Q.jsx)(K,{title:t(`config:remoteWorkspace.title`),"data-config-card":`remote-workspaces`,children:(0,Q.jsx)(G,{children:(0,Q.jsx)(W,{icon:(0,Q.jsx)(ge,{}),name:t(`remote-workspace:activeTitle`),description:t(`remote-workspace:activeDescription`),detail:(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:t(`remote-workspace:isolation`)})})})}):n?(0,Q.jsxs)(K,{title:t(`config:remoteWorkspace.title`),count:r.length,"data-config-card":`remote-workspaces`,description:t(`remote-workspace:description`),actions:(0,Q.jsx)(H,{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,Q.jsx)(fe,{className:`size-3.5`})}),children:[r.length>0&&(0,Q.jsx)(G,{children:r.map(r=>(0,Q.jsx)(W,{icon:(0,Q.jsx)(ge,{}),name:r.name,description:(0,Q.jsx)(`span`,{className:`font-mono`,children:r.address}),actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(H,{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,Q.jsx)(x,{className:`size-3.5`})]}),(0,Q.jsx)(H,{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,Q.jsx)(be,{className:`size-3.5`})})]})},r.id))}),(0,Q.jsxs)(`div`,{className:`@container/card mt-3 rounded-[var(--r-md)] border border-stroke px-3 pt-2 pb-1`,children:[(0,Q.jsx)(`p`,{className:`py-1.5 text-xs leading-relaxed text-content-secondary`,children:t(`remote-workspace:instructions`)}),(0,Q.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:l,code:f});p(``),await v(),await n.open(e),await v()})},children:[(0,Q.jsx)(bi,{label:t(`remote-workspace:name`),htmlFor:`remote-workspace-name`,children:(0,Q.jsx)(U,{id:`remote-workspace-name`,value:a,maxLength:160,disabled:m,placeholder:`Linux`,onChange:e=>o(e.target.value)})}),(0,Q.jsx)(bi,{label:t(`remote-workspace:address`),htmlFor:`remote-workspace-address`,children:(0,Q.jsx)(U,{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,Q.jsx)(bi,{label:t(`remote-workspace:fingerprint`),htmlFor:`remote-workspace-fingerprint`,children:(0,Q.jsx)(U,{id:`remote-workspace-fingerprint`,value:l,required:!0,disabled:m,placeholder:`SHA256:…`,autoComplete:`off`,spellCheck:!1,className:`font-mono text-xs`,onChange:e=>d(e.target.value)})}),(0,Q.jsx)(bi,{label:t(`remote-workspace:code`),htmlFor:`remote-workspace-code`,children:(0,Q.jsx)(U,{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,Q.jsx)(`div`,{className:`flex justify-end py-3`,children:(0,Q.jsxs)(H,{type:`submit`,className:`max-[650px]:h-11`,disabled:m,children:[m?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(x,{className:`size-3.5`}),t(`remote-workspace:pair`)]})})]})]}),g&&(0,Q.jsx)(q,{className:`mt-3`,children:g}),(0,Q.jsx)(`p`,{className:`mt-3 text-xs leading-relaxed text-content-muted`,children:t(`remote-workspace:isolation`)})]}):null}function Qi(e){let t=e.lastIndexOf(`@`);return t<0?{user:``,host:e}:{user:e.slice(0,t),host:e.slice(t+1)}}function $i(e){let t=e.system?.name?` · ${e.system.name}`:``;return e.kind===`node`?e.roots.join(` · `)+t:(e.port?`${e.target}:${e.port}`:e.target)+t}function ea({machine:e,onDone:t,onCancel:n}){let{t:r}=u(),i=(0,Z.useId)(),[a,o]=(0,Z.useState)(e?.name??``),[s,c]=(0,Z.useState)(()=>Qi(e?.target??``).host),[l,d]=(0,Z.useState)(()=>Qi(e?.target??``).user),f=l.trim()?`${l.trim()}@${s.trim()}`:s.trim(),[p,m]=(0,Z.useState)(e?.port?String(e.port):``),[h,g]=(0,Z.useState)(e?.defaultCwd??``),[_,v]=(0,Z.useState)(e?.auth??`key`),[y,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(``),D=!!e&&(f!==e?.target||(p.trim()?Number(p.trim()):null)!==(e?.port??null)),O=!!e?.passwordSet&&e?.auth===`password`,[k,A]=(0,Z.useState)(null),[j,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)(``),ee=e?.auth===`password`&&!D?e.hostKey??null:null,te=k??ee,ne=!!k&&(!ee||ee.fingerprint!==k?.fingerprint),R=O&&!D&&!ne,re=_===`password`&&!y&&!R,ie=_===`password`&&!l.trim(),z=_!==`password`||(k?j:!!ee),ae=!s.trim()||ie||re||!z,oe=()=>({target:f,port:p.trim()?Number(p.trim()):null}),se=()=>({...oe(),auth:_,..._===`password`&&y?{password:y}:{},..._===`password`&&k&&j?{hostKey:{type:k.type,key:k.key}}:{}}),ce=()=>{A(null),N(!1),L(``),w(null)},le=async()=>{F(!0),L(``),N(!1);try{let e=await Ft(oe());e.ok?A(e.hostKey):(A(null),L(dn(r,e.code,e.message)))}catch(e){A(null),L(dn(r,Rt(e),e instanceof Error?e.message:``))}finally{F(!1)}},ue=e=>E(dn(r,Rt(e),e instanceof Error?e.message:``,{auth:_})),de=async()=>{S(`test`),E(``),w(null);try{w(await It({...se(),...e?{id:e.id}:{}}))}catch(e){ue(e)}finally{S(``)}},fe=async n=>{if(n.preventDefault(),!ae){S(`save`),E(``);try{let n={name:a.trim(),...se(),defaultCwd:h.trim()},r=e?await Ht(e.id,n):await zt(n);await Vt(r.id).catch(()=>void 0),b(``),t()}catch(e){ue(e)}finally{S(``)}}};return(0,Q.jsxs)(`form`,{onSubmit:e=>void fe(e),"data-machine-ssh-form":e?`edit`:`add`,"aria-label":e?r(`machines:edit`,{name:e.name}):r(`machines:addSsh`),className:`mt-3 grid gap-3 rounded-[var(--r-md)] border border-stroke bg-surface-subtle p-3`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_7rem]`,children:[(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[r(`machines:form.target`),(0,Q.jsx)(U,{id:`${i}-target`,required:!0,autoFocus:!0,spellCheck:!1,value:s,className:`font-mono text-xs`,placeholder:r(`machines:form.targetPlaceholder`),"data-machine-target":!0,onChange:e=>{let t=Qi(e.target.value);c(t.host),t.user&&d(t.user),ce()}})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[r(`machines:form.port`),(0,Q.jsx)(U,{inputMode:`numeric`,value:p,className:`font-mono text-xs`,placeholder:`22`,"data-machine-port":!0,onChange:e=>{m(e.target.value),ce()}})]})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[r(`machines:form.user`),(0,Q.jsx)(U,{spellCheck:!1,autoCapitalize:`off`,autoComplete:`username`,value:l,required:_===`password`,className:`font-mono text-xs`,placeholder:r(_===`password`?`machines:form.userPlaceholder`:`machines:form.userPlaceholderKey`),"data-machine-user":!0,onChange:e=>{d(e.target.value),ce()}})]}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[(0,Q.jsx)(`span`,{id:`${i}-auth`,children:r(`machines:form.auth`)}),(0,Q.jsx)(ct,{"aria-labelledby":`${i}-auth`,value:_,onValueChange:e=>{v(e),w(null)},options:[{value:`key`,label:r(`machines:form.authKey`)},{value:`password`,label:r(`machines:form.authPassword`)}],"data-machine-auth":!0})]}),_===`password`&&(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[r(`machines:form.password`),(0,Q.jsx)(U,{type:`password`,autoComplete:`new-password`,spellCheck:!1,value:y,required:!R,placeholder:R?r(`machines:form.passwordKeep`):``,"aria-describedby":`${i}-password-hint`,"data-machine-password":!0,onChange:e=>b(e.target.value)})]}),_===`password`&&(0,Q.jsxs)(`section`,{"aria-labelledby":`${i}-host-key`,"data-machine-host-key":z?`confirmed`:te?`shown`:`missing`,className:`grid gap-2 rounded-[var(--r-md)] border border-stroke bg-surface-raised p-3 text-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`span`,{id:`${i}-host-key`,className:`inline-flex items-center gap-1.5 font-medium text-content-secondary`,children:[(0,Q.jsx)(zn,{className:`size-3.5`,"aria-hidden":`true`}),r(`machines:form.hostKey`)]}),(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsxs)(H,{type:`button`,variant:`outline`,size:`sm`,disabled:P||!s.trim(),"data-machine-host-key-fetch":!0,onClick:()=>void le(),children:[P&&(0,Q.jsx)(V,{className:`size-3.5`}),r(te?`machines:form.hostKeyRefetch`:`machines:form.hostKeyFetch`)]})]}),te?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(`code`,{className:`min-w-0 flex-1 rounded-[var(--r-sm)] bg-surface-subtle px-2 py-1.5 font-mono break-all text-content select-all`,"data-machine-host-key-fingerprint":!0,children:[te.type,` `,te.fingerprint]}),(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":r(`machines:form.hostKeyCopy`),title:r(`machines:form.hostKeyCopy`),onClick:()=>void navigator.clipboard?.writeText(`${te.type} ${te.fingerprint}`).catch(()=>void 0),children:(0,Q.jsx)(M,{className:`size-3.5`})})]}),k?(0,Q.jsxs)(`label`,{htmlFor:`${i}-host-key-confirm`,className:`flex items-start gap-2 text-content-secondary`,children:[(0,Q.jsx)(Ve,{id:`${i}-host-key-confirm`,checked:j,"data-machine-host-key-confirm":!0,onCheckedChange:e=>{N(e===!0),w(null)}}),(0,Q.jsx)(`span`,{children:ee&&ee.fingerprint!==k.fingerprint?r(`machines:form.hostKeyConfirmChanged`):r(`machines:form.hostKeyConfirm`)})]}):(0,Q.jsx)(`p`,{className:`m-0 text-content-muted`,children:r(`machines:form.hostKeySaved`)})]}):(0,Q.jsx)(`p`,{className:`m-0 text-content-muted`,children:r(`machines:form.hostKeyMissing`)}),(0,Q.jsx)(`p`,{className:`m-0 text-content-muted`,children:r(`machines:form.hostKeyHint`)}),I&&(0,Q.jsx)(q,{className:`mt-0`,children:I})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[r(`machines:form.name`),(0,Q.jsx)(U,{value:a,placeholder:r(`machines:form.namePlaceholder`),"data-machine-name":!0,onChange:e=>o(e.target.value)})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[r(`machines:form.defaultCwd`),(0,Q.jsx)(U,{spellCheck:!1,value:h,className:`font-mono text-xs`,placeholder:`~`,onChange:e=>g(e.target.value)})]})]}),(0,Q.jsxs)(`p`,{id:`${i}-password-hint`,className:`m-0 text-xs text-content-muted`,children:[_===`password`&&O&&D&&(0,Q.jsxs)(`span`,{"data-machine-password-again":!0,children:[r(`machines:form.passwordAgain`),` `]}),_===`password`&&O&&!D&&ne&&(0,Q.jsxs)(`span`,{"data-machine-password-again":`host-key`,children:[r(`machines:form.passwordAgainHostKey`),` `]}),r(_===`password`?`machines:form.passwordHint`:`machines:form.keyHint`)]}),C?.ok&&(0,Q.jsx)(`p`,{role:`status`,className:`m-0 text-xs text-success`,"data-machine-test-ok":!0,children:r(`machines:form.testOk`,{platform:C.platform,home:C.home})}),C&&!C.ok&&(0,Q.jsx)(q,{className:`mt-0`,"data-machine-test-failed":!0,children:dn(r,C.code,C.message,{auth:_})}),T&&(0,Q.jsx)(q,{className:`mt-0`,children:T}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,Q.jsx)(H,{type:`button`,variant:`ghost`,onClick:n,children:r(`machines:form.cancel`)}),(0,Q.jsxs)(H,{type:`button`,variant:`outline`,disabled:!!x||ae,"data-machine-test":!0,onClick:()=>void de(),children:[x===`test`&&(0,Q.jsx)(V,{className:`size-3.5`}),r(x===`test`?`machines:form.testing`:`machines:form.test`)]}),(0,Q.jsx)(H,{type:`submit`,disabled:!!x||ae,"data-machine-save":!0,children:r(`machines:form.save`)})]})]})}function ta({pairing:e,onDone:t}){let{t:n}=u(),[r,i]=(0,Z.useState)(!1),a=fn(e,{brain:n(`machines:pair.brainPlaceholder`),fingerprint:`SHA256:…`,root:n(`machines:pair.rootPlaceholder`)}),o=async()=>{try{await navigator.clipboard.writeText(a.join(`
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{l as t,m as n,u as r}from"./vendor-router-CSN_DGvx.js";import{t as i}from"./index-DfZr_SBB.js";import{i as a,r as o}from"./vendor-react-DwNgTV1j.js";import{n as s,p as c,u as l}from"./i18n-DojWxWRu.js";import{t as u}from"./use-i18n-D7gqe3X9.js";import{t as d}from"./http-response-CSCIVa2S.js";import{n as f}from"./http-zidLhKOq.js";import{t as p}from"./api-DvJkDxm2.js";import{n as m}from"./runtime-capabilities-ChJVNwRz.js";import{t as h}from"./runtime-capabilities-store-Pf6H3F8g.js";import{n as g}from"./client-store-vgpSLnwK.js";import{t as _}from"./createLucideIcon-Cd-3GVxJ.js";import{t as v}from"./activity-BCxvXCG3.js";import{t as y}from"./arrow-left-B8oVrQ2S.js";import{t as b}from"./arrow-right-DqLOhpA2.js";import{t as x}from"./arrow-up-right-B6l8qFZz.js";import{t as S}from"./bell-BjONAtgH.js";import{t as C}from"./bot-B3TaBp_T.js";import{t as w}from"./brain-qxhnKqYP.js";import{t as T}from"./check-2vYc6QaP.js";import{t as E}from"./chevron-down-CxtxIjiP.js";import{t as D}from"./chevron-left-BAtyp3_6.js";import{t as O}from"./chevron-up-D_ZcXjqr.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{i as I,o as L,s as ee}from"./settings-navigation-YxlR_1sv.js";import{t as te}from"./image-BY_c3FYU.js";import{t as ne}from"./info-DATxy0fb.js";import{n as R,t as re}from"./useMachines-CGhATQIK.js";import{t as ie}from"./loader-circle-BOwQzHB-.js";import{t as z}from"./message-square-SKjZyY3v.js";import{t as ae}from"./monitor-smartphone-B1gIjItA.js";import{n as oe,r as se,t as ce}from"./zap-DZHw5afO.js";import{t as le}from"./pencil-U08v_vV9.js";import{t as ue}from"./play-DNDjDNGn.js";import{t as de}from"./plus-fQbSqB1n.js";import{t as fe}from"./refresh-cw-TbWxTY4K.js";import{t as pe}from"./rocket-BgLSjoHY.js";import{t as me}from"./rotate-ccw-C0v8V77_.js";import{t as he}from"./search-D0mqDaf_.js";import{t as ge}from"./server-BgNvmqwJ.js";import{t as _e}from"./shield-check-Gvek4RJ7.js";import{t as ve}from"./sliders-horizontal-Dryf1XyC.js";import{t as ye}from"./sparkles-S_eeuqn9.js";import{t as be}from"./trash-2-CNrPOoPR.js";import{t as xe}from"./triangle-alert-CE1q54ci.js";import{t as Se}from"./wrench-6pg6_bqI.js";import{t as Ce}from"./x-07u4-129.js";import{t as we}from"./brand-DIEc3fK8.js";import{a as Te}from"./dist-41X0pdUs.js";import{c as Ee,i as De,n as Oe,o as ke,s as Ae}from"./dist-BsRXXcSL.js";import{n as je,t as Me}from"./dist-DzGQ7sLi.js";import{a as Ne,i as Pe,n as Fe,o as Ie,r as Le,s as Re,t as ze}from"./collapsible-B-fc7n0u.js";import{t as Be}from"./dist-OB2r6Xsr.js";import{t as Ve}from"./checkbox-BrEHgFV0.js";import{n as He,r as Ue,t as We}from"./dist-BaBySQmo.js";import{c as Ge,i as Ke,n as qe,p as Je,r as Ye,t as Xe}from"./dropdown-menu-Ds0gD8S8.js";import{a as Ze,r as Qe,t as $e}from"./popover-CJZagMlP.js";import{a as et,i as tt,n as nt,r as rt,t as it}from"./select-DyBoNnz-.js";import{t as at}from"./separator-BPh_qxvc.js";import{t as ot}from"./slider-De8rWVNs.js";import{t as st}from"./switch-D_G8wFhs.js";import{t as ct}from"./segmented-control-xkrEOP_d.js";import{t as B}from"./utils-C8uzG5AZ.js";import{n as V,r as lt,t as H}from"./button-CCcCN8tE.js";import{n as ut,t as dt}from"./kbd-CAufZTkl.js";import{i as ft,t as pt}from"./config-search-DLwaZPQ0.js";import{_ as mt,c as ht,d as gt,f as _t,h as vt,l as yt,m as bt,o as xt,p as St,t as Ct,u as wt}from"./shortcuts-DDY3WKNk.js";import{a as Tt}from"./format-DMJQzoZ7.js";import{t as Et}from"./StatusGlyph-1KgitlUg.js";import{a as Dt,i as Ot,l as kt,o as At,s as jt,t as Mt}from"./dialog-Cfk77z7g.js";import{t as U}from"./input-CPw-zkYh.js";import{t as Nt}from"./textarea-DmATpOqT.js";import{t as Pt}from"./model-display-kDwvtxrW.js";import{a as Ft,l as It,n as Lt,o as Rt,r as zt,s as Bt,t as Vt,u as Ht}from"./machines-api-C_Mtpsx-.js";import{n as Ut,r as Wt,t as Gt}from"./PageState-Cz6vFMXv.js";import{t as Kt}from"./useOverlayFocusReturn-NkxBSSjb.js";import{i as W,n as G,o as K,r as qt,s as Jt,t as q}from"./FeaturePage-BOq1shgs.js";import{n as J}from"./field-DoLEb0np.js";import{t as Yt}from"./MarkdownMessage-C47P3anj.js";import{t as Y}from"./AppSelect-B15Hpk2W.js";import{n as Xt}from"./public-flags-DRJJOuZP.js";import{n as Zt,t as X}from"./SettingsRow-CT0AZ7re.js";import{t as Qt}from"./BrandLogo-k3CvJjd4.js";import{t as $t}from"./badge-CWB3lj2H.js";import{a as en,i as tn,l as nn,n as rn,o as an,r as on,s as sn,t as cn}from"./app-primitives-BskZ4ZJj.js";import{r as ln}from"./session-inspector-store-C8XTJKcv.js";import{t as un}from"./permission-rules-api-B_E6IQKz.js";import{n as dn,t as fn}from"./machine-messages-BJSM1X90.js";import{C as pn,_ as mn,a as hn,c as gn,d as _n,g as vn,i as yn,l as bn,o as xn,p as Sn,r as Cn,s as wn,v as Tn,x as En,y as Dn}from"./app-update-A3wZafCD.js";import{a as On,n as kn,r as An,t as jn}from"./ShortcutKeys-CJB8XFeA.js";import{a as Mn,i as Nn,n as Pn,r as Fn}from"./browser-notifications-CvHO-BlP.js";var In=_(`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=_(`blend`,[[`circle`,{cx:`9`,cy:`9`,r:`7`,key:`p2h5vp`}],[`circle`,{cx:`15`,cy:`15`,r:`7`,key:`19ennj`}]]),Rn=_(`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`}]]),zn=_(`fingerprint-pattern`,[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]]),Bn=_(`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`}]]),Vn=_(`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=_(`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`}]]),Un=_(`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`}]]),Wn=_(`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`}]]),Gn=_(`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`}]]),Kn=_(`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`}]]),qn=_(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Jn=_(`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`}]]),Yn=_(`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`}]]),Xn=_(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Zn=_(`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`}]]),Qn=_(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),Z=e(a(),1),Q=o(),$n=Object.defineProperty,er=(e,t)=>$n(e,`name`,{value:t,configurable:!0}),tr=`Accordion`,nr=[`Home`,`End`,`ArrowDown`,`ArrowUp`,`ArrowLeft`,`ArrowRight`],[rr,ir,ar]=je(tr),[or,sr]=Ae(tr,[ar,Re]),cr=Re(),lr=Z.forwardRef(er(function(e,t){let{type:n,...r}=e,i=r,a=r;return(0,Q.jsx)(rr.Provider,{scope:e.__scopeAccordion,children:n===`multiple`?(0,Q.jsx)(hr,{...a,ref:t}):(0,Q.jsx)(mr,{...i,ref:t})})},`Accordion`)),[ur,dr]=or(tr),[fr,pr]=or(tr,{collapsible:!1}),mr=Z.forwardRef(er(function(e,t){let{value:n,defaultValue:r,onValueChange:i=er(()=>{},`onValueChange`),collapsible:a=!1,...o}=e,[s,c]=De({prop:n,defaultProp:r??``,onChange:i,caller:tr});return(0,Q.jsx)(ur,{scope:e.__scopeAccordion,value:Z.useMemo(()=>s?[s]:[],[s]),onItemOpen:c,onItemClose:Z.useCallback(()=>a&&c(``),[a,c]),children:(0,Q.jsx)(fr,{scope:e.__scopeAccordion,collapsible:a,children:(0,Q.jsx)(vr,{...o,ref:t})})})},`AccordionImplSingle`)),hr=Z.forwardRef(er(function(e,t){let{value:n,defaultValue:r,onValueChange:i=er(()=>{},`onValueChange`),...a}=e,[o,s]=De({prop:n,defaultProp:r??[],onChange:i,caller:tr}),c=Z.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=Z.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,Q.jsx)(ur,{scope:e.__scopeAccordion,value:o,onItemOpen:c,onItemClose:l,children:(0,Q.jsx)(fr,{scope:e.__scopeAccordion,collapsible:!0,children:(0,Q.jsx)(vr,{...a,ref:t})})})},`AccordionImplMultiple`)),[gr,_r]=or(tr),vr=Z.forwardRef(er(function(e,t){let{__scopeAccordion:n,disabled:r,dir:i,orientation:a=`vertical`,...o}=e,s=Z.useRef(null),c=Te(s,t),l=ir(n),u=Me(i)===`ltr`,d=ke(e.onKeyDown,e=>{if(!nr.includes(e.key))return;let t=e.target,n=l().filter(e=>!e.ref.current?.disabled),r=n.findIndex(e=>e.ref.current===t),i=n.length;if(r===-1)return;e.preventDefault();let o=r,s=i-1,c=er(()=>{o=r+1,o>s&&(o=0)},`moveNext`),d=er(()=>{o=r-1,o<0&&(o=s)},`movePrev`);switch(e.key){case`Home`:o=0;break;case`End`:o=s;break;case`ArrowRight`:a===`horizontal`&&(u?c():d());break;case`ArrowDown`:a===`vertical`&&c();break;case`ArrowLeft`:a===`horizontal`&&(u?d():c());break;case`ArrowUp`:a===`vertical`&&d()}n[o%i].ref.current?.focus()});return(0,Q.jsx)(gr,{scope:n,disabled:r,direction:i,orientation:a,children:(0,Q.jsx)(rr.Slot,{scope:n,children:(0,Q.jsx)(Ee.div,{...o,"data-orientation":a,ref:c,onKeyDown:r?void 0:d})})})},`AccordionImpl`)),yr=`AccordionItem`,[br,xr]=or(yr),Sr=Z.forwardRef(er(function(e,t){let{__scopeAccordion:n,value:r,...i}=e,a=_r(yr,n),o=dr(yr,n),s=cr(n),c=Oe(),l=r&&o.value.includes(r)||!1,u=a.disabled||e.disabled;return(0,Q.jsx)(br,{scope:n,open:l,disabled:u,triggerId:c,children:(0,Q.jsx)(Ne,{"data-orientation":a.orientation,"data-state":kr(l),...s,...i,ref:t,disabled:u,open:l,onOpenChange:e=>{e?o.onItemOpen(r):o.onItemClose(r)}})})},`AccordionItem`)),Cr=`AccordionHeader`,wr=Z.forwardRef(er(function(e,t){let{__scopeAccordion:n,...r}=e,i=_r(tr,n),a=xr(Cr,n);return(0,Q.jsx)(Ee.h3,{"data-orientation":i.orientation,"data-state":kr(a.open),"data-disabled":a.disabled?``:void 0,...r,ref:t})},`AccordionHeader`)),Tr=`AccordionTrigger`,Er=Z.forwardRef(er(function(e,t){let{__scopeAccordion:n,...r}=e,i=_r(tr,n),a=xr(Tr,n),o=pr(Tr,n),s=cr(n);return(0,Q.jsx)(rr.ItemSlot,{scope:n,children:(0,Q.jsx)(Ie,{"aria-disabled":a.open&&!o.collapsible||void 0,"data-orientation":i.orientation,id:a.triggerId,...s,...r,ref:t})})},`AccordionTrigger`)),Dr=`AccordionContent`,Or=Z.forwardRef(er(function(e,t){let{__scopeAccordion:n,...r}=e,i=_r(tr,n),a=xr(Dr,n),o=cr(n);return(0,Q.jsx)(Pe,{role:`region`,"aria-labelledby":a.triggerId,"data-orientation":i.orientation,...o,...r,ref:t,style:{"--radix-accordion-content-height":`var(--radix-collapsible-content-height)`,"--radix-accordion-content-width":`var(--radix-collapsible-content-width)`,...e.style}})},`AccordionContent`));function kr(e){return e?`open`:`closed`}er(kr,`getState`);var Ar=lr,jr=Sr,Mr=wr,Nr=Er,Pr=Or,Fr=Object.defineProperty,Ir=(e,t)=>Fr(e,`name`,{value:t,configurable:!0}),Lr=`Radio`,[Rr,zr]=Ae(Lr),[Br,Vr]=Rr(Lr);function Hr(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]=Z.useState(null),[p,m]=Z.useState(null),h=Z.useRef(!1),[g,_]=Z.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:Ir(()=>s?.(),`onCheck`)};return(0,Q.jsx)(Br,{scope:t,...v,children:qr(u)?u(v):r})}Ir(Hr,`RadioProvider`);var Ur=`RadioTrigger`,Wr=Z.forwardRef(Ir(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}=Vr(Ur,e),p=Te(r,s);return(0,Q.jsx)(Ee.button,{type:`button`,role:`radio`,"aria-checked":i,"data-state":Jr(i),"data-disabled":a?``:void 0,disabled:a,value:o,...n,ref:p,onClick:ke(t,e=>{i||(u(),c()),f&&d&&(l.current=e.isPropagationStopped(),l.current||e.stopPropagation())})})},`RadioTrigger`)),Gr=`RadioBubbleInput`,Kr=Z.forwardRef(Ir(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}=Vr(Gr,e),h=Te(r,f),g=Be(i),_=Z.useRef(!1),v=Z.useRef(a),y=Z.useRef(m);Z.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=Z.useRef(a);return(0,Q.jsx)(Ee.input,{type:`radio`,"aria-hidden":!0,defaultChecked:b.current,required:o,disabled:s,name:c,value:l,form:u,...n,tabIndex:-1,ref:h,onClick:ke(t,e=>{_.current&&e.stopPropagation()}),style:{...n.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`RadioBubbleInput`));function qr(e){return typeof e==`function`}Ir(qr,`isFunction`);function Jr(e){return e?`checked`:`unchecked`}Ir(Jr,`getState`);var Yr=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`],Xr=`RadioGroup`,[Zr,Qr]=Ae(Xr,[Ue,zr]),$r=Ue(),ei=zr(),[ti,ni]=Zr(Xr),ri=Z.forwardRef(Ir(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=$r(n),h=Me(u),[g,_]=De({prop:o,defaultProp:a??null,onChange:f,caller:Xr}),[v,y]=Z.useState(null),b=Te(t,y),x=Z.useRef(g);return Z.useEffect(()=>{let e=i?v?.ownerDocument.getElementById(i):v?.closest(`form`);if(e instanceof HTMLFormElement){let t=Ir(()=>_(x.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[v,i,_]),(0,Q.jsx)(ti,{scope:n,name:r,form:i,required:s,disabled:c,value:g,onValueChange:_,children:(0,Q.jsx)(He,{asChild:!0,...m,orientation:l,dir:h,loop:d,children:(0,Q.jsx)(Ee.div,{role:`radiogroup`,"aria-required":s,"aria-orientation":l,"data-disabled":c?``:void 0,dir:h,...p,ref:b})})})},`RadioGroup`)),ii=`RadioGroupItemProvider`,ai=`RadioGroupItemTrigger`;function oi(e){let{__scopeRadioGroup:t,value:n,disabled:r,children:i,internal_do_not_use_render:a}=e,o=ni(ii,t),s=ei(t),c=o.disabled||r;return(0,Q.jsx)(Hr,{...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})}Ir(oi,`RadioGroupItemProvider`);var si=Z.forwardRef(Ir(function(e,t){let{__scopeRadioGroup:n,...r}=e,i=$r(n),a=ei(n),{checked:o,disabled:s}=Vr(ai,a.__scopeRadio),c=Z.useRef(null),l=Te(t,c),u=Z.useRef(!1);return Z.useEffect(()=>{let e=Ir(e=>{Yr.includes(e.key)&&(u.current=!0)},`handleKeyDown`),t=Ir(()=>u.current=!1,`handleKeyUp`);return document.addEventListener(`keydown`,e),document.addEventListener(`keyup`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`keyup`,t)}},[]),(0,Q.jsx)(We,{asChild:!0,...i,focusable:!s,active:o,children:(0,Q.jsx)(Wr,{...a,...r,ref:l,onKeyDown:ke(r.onKeyDown,e=>{e.key===`Enter`&&e.preventDefault()}),onFocus:ke(r.onFocus,()=>{u.current&&c.current?.click()})})})},`RadioGroupItemTrigger`)),ci=Z.forwardRef(Ir(function(e,t){let{__scopeRadioGroup:n,value:r,disabled:i,...a}=e;return(0,Q.jsx)(oi,{__scopeRadioGroup:n,value:r,disabled:i,internal_do_not_use_render:({isFormControl:e})=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(si,{...a,ref:t,__scopeRadioGroup:n}),e&&(0,Q.jsx)(li,{__scopeRadioGroup:n})]})})},`RadioGroupItem`)),li=Z.forwardRef(Ir(function(e,t){let{__scopeRadioGroup:n,...r}=e,i=ei(n);return(0,Q.jsx)(Kr,{...i,...r,ref:t})},`RadioGroupItemBubbleInput`));l.addResourceBundle(`zh-CN`,`labs`,{notice:`实验功能还在开发中,可能不稳定,也可能在之后的版本里调整或移除。每项单独开关,随时可以关掉;遇到问题请点「反馈」告诉我们。`,listTitle:`可试用的功能`,loading:`正在读取实验功能…`,loadFailed:`没能读取实验功能:{error}`,retry:`重试`,emptyTitle:`目前没有实验功能`,emptyDescription:`有新功能进入测试时,会出现在这里。`,"stage.experimental":`实验中`,"stage.preview":`即将毕业`,whenOffPrefix:`关掉后:`,feedback:`反馈`,toggleLabel:`开启或关闭“{name}”`,"saving.on":`正在开启…`,"saving.off":`正在关闭…`,enabledNow:`已开启,立即生效`,saveFailed:`没能保存:{error}。开关已恢复。`,"unavailable.runtime":`当前连接的 Runtime 不支持这个功能。升级那台机器上的 Pisper 后即可开启。`,openLinkFailed:`没能打开链接。`,"feature.bots.title":`Bots`,"feature.bots.description":`新建多个常驻的 Bot,在对话里交代事情;它们在自己的电脑上干活,改代码时用独立分支,改完交给你确认。`,"feature.bots.whenOff":`Bots 和它们的会话都不再显示;记录都保留,重新打开就回来。正在运行的任务会跑完。`}),l.addResourceBundle(`en-US`,`labs`,{notice:`Labs features are still in development. They may be unstable and may change or be removed in later versions. Each one has its own switch and can be turned off at any time; use Feedback to tell us about problems.`,listTitle:`Available to try`,loading:`Loading Labs features…`,loadFailed:`Couldn't load Labs features: {error}`,retry:`Retry`,emptyTitle:`No Labs features right now`,emptyDescription:`New features appear here when they enter testing.`,"stage.experimental":`Experimental`,"stage.preview":`Graduating soon`,whenOffPrefix:`When turned off: `,feedback:`Feedback`,toggleLabel:`Turn “{name}” on or off`,"saving.on":`Turning on…`,"saving.off":`Turning off…`,enabledNow:`On, effective immediately`,saveFailed:`Couldn't save: {error}. The switch was restored.`,"unavailable.runtime":`The connected Runtime doesn't support this feature. Update Pisper on that machine to turn it on.`,openLinkFailed:`Couldn't open the link.`,"feature.bots.title":`Bots`,"feature.bots.description":`Create several always-on Bots and tell them what to do in a chat. They work on their own computer, use a separate branch for code changes and hand the result to you to confirm.`,"feature.bots.whenOff":`Bots and their sessions are hidden everywhere; nothing is deleted, and turning it back on brings them back. Running tasks finish.`});function ui(e,t){if(typeof window>`u`||!window.__PISPER_MOBILE_APP__)return null;e.preventDefault();let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(`mobile_open_external_url`,{url:t}):Promise.reject(Error(`移动端原生桥不可用。`))}var di={bots:e=>({title:e(`labs:feature.bots.title`),description:e(`labs:feature.bots.description`),whenOff:e(`labs:feature.bots.whenOff`)})};function fi(e,t){return di[t]?.(e)??{title:t,description:``,whenOff:``}}function pi(e,t){return e(t===`preview`?`labs:stage.preview`:`labs:stage.experimental`)}function mi({notify:e}){let{t}=u(),n=Xt(e=>e.features),r=Xt(e=>e.status),i=Xt(e=>e.error),a=Xt(e=>e.pending),o=Xt(e=>e.rowErrors),s=Xt(e=>e.load),c=Xt(e=>e.setEnabled),[l,d]=(0,Z.useState)(()=>new Set);(0,Z.useEffect)(()=>{s()},[s]);let f=async(e,t)=>{await c(e,t);let n=Xt.getState(),r=!n.rowErrors[e]&&n.features.some(n=>n.id===e&&n.enabled===t);d(n=>{let i=new Set(n);return r&&t?i.add(e):i.delete(e),i})},p=n=>{ui(n,n.currentTarget.href)?.catch(()=>e(t(`labs:openLinkFailed`),`error`))},m;return m=r===`loading`&&n.length===0?(0,Q.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 py-6 text-sm text-content-muted`,children:[(0,Q.jsx)(lt,{"aria-hidden":`true`}),t(`labs:loading`)]}):n.length===0?r===`error`?null:(0,Q.jsx)(Gt,{compact:!0,icon:ee,title:t(`labs:emptyTitle`),description:t(`labs:emptyDescription`)}):(0,Q.jsx)(G,{children:n.map(e=>{let n=fi(t,e.id),r=a[e.id]===!0,i=o[e.id];return(0,Q.jsx)(W,{"data-beta-feature":e.id,"data-enabled":e.enabled,icon:(0,Q.jsx)(ee,{}),name:n.title,status:(0,Q.jsx)($t,{variant:`outline`,children:pi(t,e.stage)}),description:n.description||void 0,actions:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[r&&(0,Q.jsxs)(`span`,{role:`status`,className:`flex items-center gap-1.5 text-xs text-content-muted`,children:[(0,Q.jsx)(lt,{"aria-hidden":`true`}),e.enabled?t(`labs:saving.on`):t(`labs:saving.off`)]}),(0,Q.jsx)(st,{checked:e.enabled,disabled:r||!e.available,"aria-busy":r,"aria-label":t(`labs:toggleLabel`,{name:n.title}),onCheckedChange:t=>void f(e.id,t)})]}),detail:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5 pb-3 text-xs leading-relaxed text-content-muted`,children:[n.whenOff&&(0,Q.jsxs)(`p`,{children:[t(`labs:whenOffPrefix`),n.whenOff]}),e.feedbackUrl&&(0,Q.jsxs)(`a`,{className:`inline-flex w-fit items-center gap-1 text-content-secondary underline decoration-stroke-strong underline-offset-3 hover:text-content`,href:e.feedbackUrl,target:`_blank`,rel:`noopener noreferrer`,"data-web-preview":`external`,onClick:p,children:[t(`labs:feedback`),(0,Q.jsx)(F,{className:`size-3.5`,"aria-hidden":`true`})]}),!e.available&&(0,Q.jsxs)(`p`,{className:`flex items-start gap-1.5 text-content-secondary`,children:[(0,Q.jsx)(ne,{className:`mt-[3px] size-3.5 flex-none`,"aria-hidden":`true`}),t(`labs:unavailable.runtime`)]}),e.enabled&&l.has(e.id)&&!r&&(0,Q.jsxs)(`p`,{role:`status`,className:`flex items-center gap-1.5 text-content-secondary`,children:[(0,Q.jsx)(T,{className:`size-3.5 flex-none`,"aria-hidden":`true`}),t(`labs:enabledNow`)]}),i&&(0,Q.jsx)(q,{className:`mt-1`,children:(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[t(`labs:saveFailed`,{error:i.message}),(0,Q.jsx)(H,{size:`sm`,variant:`outline`,onClick:()=>void f(e.id,i.desired),children:t(`labs:retry`)})]})})]})},e.id)})}),(0,Q.jsxs)(`div`,{"data-labs-settings":!0,className:`flex min-w-0 flex-col`,children:[(0,Q.jsxs)(`p`,{role:`note`,className:`flex items-start gap-2 rounded-[var(--r-md)] bg-surface-subtle px-3 py-2.5 text-[13px] leading-relaxed text-content-secondary`,children:[(0,Q.jsx)(ee,{className:`mt-[3px] size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),t(`labs:notice`)]}),r===`error`&&(0,Q.jsx)(q,{children:(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[t(`labs:loadFailed`,{error:i}),(0,Q.jsx)(H,{size:`sm`,variant:`outline`,onClick:()=>void s(),children:t(`labs:retry`)})]})}),(0,Q.jsx)(K,{title:t(`labs:listTitle`),count:n.length||void 0,children:m})]})}function hi({className:e,...t}){return(0,Q.jsx)(cn,{"data-settings-card":!0,className:B(`rounded-none border-x-0 border-t border-b-0 border-stroke-soft bg-transparent px-0`,e),...t})}var gi=an,_i=nn;function vi(e){return(0,Q.jsx)(sn,{density:`compact`,...e})}function yi({className:e,...t}){return(0,Q.jsx)(`div`,{"data-settings-group":!0,className:B(`@container/card min-w-0 divide-y divide-stroke-soft border-y border-stroke-soft`,e),...t})}function bi({label:e,help:t,htmlFor:n,labelId:r,helpId:i,children:a,className:o}){return(0,Q.jsxs)(`div`,{className:B(`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,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`label`,{id:r,htmlFor:n,className:`text-sm font-medium text-content`,children:e}),t&&(0,Q.jsx)(`p`,{id:i,className:`mt-0.5 text-xs text-content-muted`,children:t})]}),(0,Q.jsx)(`div`,{className:`min-w-0 @min-[480px]/card:max-w-[460px]`,children:a})]})}var xi=`0.6.43`,Si=`https://github.com/ling-kong-ran/pisper`,Ci=`${Si}/blob/release/LICENSE`;function wi({href:e,icon:t,label:n,value:r,onClick:i}){return(0,Q.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,Q.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,Q.jsx)(t,{size:16,"aria-hidden":`true`})}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-content`,children:n}),(0,Q.jsx)(`span`,{className:`mt-0.5 block truncate font-mono text-xs text-content-muted`,children:r})]}),(0,Q.jsx)(F,{"aria-hidden":`true`,className:`text-content-muted transition-colors group-hover:text-content`,size:14})]})}function Ti({update:e,notify:t}){let{t:n}=u(),r=e.info?.version||xi,i=e=>{ui(e,e.currentTarget.href)?.catch(()=>t(n(`config:aboutSettings.openLinkFailed`),`error`))};return(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 rounded-[15px] shadow-raise`,children:(0,Q.jsx)(Qt,{size:56})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-[length:calc(var(--ui-font-size)*10/7)] leading-[1.3] font-semibold tracking-[-.015em] text-content`,children:`Pisper`}),(0,Q.jsxs)(_i,{tone:`gray`,className:`font-mono`,children:[`v`,r]})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-content-muted`,children:n(`config:aboutSettings.description`)})]})]}),(0,Q.jsxs)(`section`,{"data-config-card":`about-project`,children:[(0,Q.jsx)(gi,{title:n(`config:aboutSettings.projectInformation`),className:`mb-3 text-[15px] leading-6 font-medium text-content`}),(0,Q.jsxs)(yi,{children:[(0,Q.jsx)(wi,{href:Si,icon:j,label:n(`config:aboutSettings.sourceCode`),value:`github.com/ling-kong-ran/pisper`,onClick:i}),(0,Q.jsx)(wi,{href:Ci,icon:Gn,label:n(`config:aboutSettings.license`),value:`MIT License`,onClick:i})]})]}),(0,Q.jsx)(hi,{className:`py-4`,"data-config-card":`about-support`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 max-[540px]:flex-col max-[540px]:items-stretch`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(gi,{title:n(`config:aboutSettings.supportPisper`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 max-w-[520px] text-xs leading-5 text-content-muted`,children:n(`config:aboutSettings.supportDescription`)})]}),(0,Q.jsx)(H,{asChild:!0,className:`max-[650px]:h-11 max-[540px]:w-full`,children:(0,Q.jsxs)(`a`,{href:Si,target:`_blank`,rel:`noopener noreferrer`,"data-web-preview":`external`,onClick:i,children:[(0,Q.jsx)(Jn,{size:15}),n(`config:aboutSettings.starOnGitHub`)]})})]})}),(0,Q.jsx)(`p`,{className:`text-center text-xs text-content-muted`,children:n(`config:aboutSettings.copyright`)})]})}function Ei(e){window.dispatchEvent(new CustomEvent(`pisper:desktop-pet-changed`,{detail:e}))}function Di({notify:e,requestConfirm:t}){let{t:n}=u(),r=window.pisperDesktop,i=(0,Z.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:()=>p(`/api/desktop-pet`),setEnabled:e=>p(`/api/desktop-pet/enabled`,{method:`POST`,body:{enabled:e}}),setOpacity:e=>p(`/api/desktop-pet/opacity`,{method:`POST`,body:{opacity:e}}),search:e=>p(`/api/desktop-pet/catalog?query=${encodeURIComponent(e)}`),install:e=>p(`/api/desktop-pet/install`,{method:`POST`,body:{slug:e}}),select:e=>p(`/api/desktop-pet/select`,{method:`POST`,body:{slug:e}}),remove:e=>p(`/api/desktop-pet/${encodeURIComponent(e)}`,{method:`DELETE`}),openCatalog:()=>window.open(`https://petdex.dev`,`_blank`,`noopener,noreferrer`)},[r]),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(``),[l,d]=(0,Z.useState)([]),[f,m]=(0,Z.useState)(100),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),y=(0,Z.useCallback)(e=>{o(e),m(Math.round((e.opacity??1)*100))},[]),b=(0,Z.useCallback)(async()=>{try{v(``),y(await i.getStatus())}catch(e){v(e instanceof Error?e.message:String(e))}},[y,i]),x=(0,Z.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,Z.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),Ei(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),Ei(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),Ei(r),e(n(`config:desktopPetSettings.petInstalled`,{name:r.selectedName||t}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(``)}}},E=async t=>{if(t!==a?.selectedSlug){g(`select:${t}`);try{v(``);let r=await i.select(t);y(r),Ei(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),Ei(t),e(n(`config:desktopPetSettings.petRemoved`,{name:r.name}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(``)}}};return(0,Q.jsxs)(Q.Fragment,{children:[_&&(0,Q.jsx)(q,{children:_}),(0,Q.jsx)(K,{title:n(`config:desktopPetSettings.displayTitle`),"data-config-card":`desktop-pet-settings`,children:a?(0,Q.jsxs)(G,{children:[(0,Q.jsx)(W,{icon:(0,Q.jsx)(Rn,{}),name:n(`config:desktopPetSettings.showOnDesktop`),description:a.selectedName?n(`config:desktopPetSettings.currentPet`,{name:a.selectedName}):n(`config:desktopPetSettings.installBeforeEnabling`),status:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[a.running&&(0,Q.jsx)(Et,{status:`done`,className:`size-3.5`}),a.running?n(`config:desktopPetSettings.running`):n(`config:desktopPetSettings.stopped`)]}),actions:(0,Q.jsx)(st,{checked:a.enabled,disabled:!!h||!a.installed.length,onCheckedChange:e=>void S(e),"aria-label":n(`config:desktopPetSettings.showOnDesktop`)})}),(0,Q.jsx)(W,{icon:(0,Q.jsx)(Ln,{}),name:n(`config:desktopPetSettings.opacity`),nameMeta:`${f}%`,actions:(0,Q.jsx)(ot,{value:[f],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,Q.jsx)(Ut,{kind:`loading`,title:n(`config:desktopPetSettings.loading`)})}),(0,Q.jsxs)(K,{title:n(`config:desktopPetSettings.installTitle`),"data-config-card":`desktop-pet-install`,description:n(`config:desktopPetSettings.installDescription`),actions:(0,Q.jsxs)(H,{variant:`ghost`,size:`sm`,onClick:i.openCatalog,children:[(0,Q.jsx)(F,{}),n(`config:desktopPetSettings.browsePetdex`)]}),children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex gap-2`,children:[(0,Q.jsx)(U,{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,Q.jsxs)(H,{variant:`secondary`,className:`h-9 shrink-0 pointer-coarse:h-11 max-[650px]:h-11`,disabled:h===`search`,onClick:x,children:[h===`search`?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(he,{}),n(`config:desktopPetSettings.search`)]})]}),l.length>0&&(0,Q.jsx)(G,{children:l.map(e=>{let t=a?.installed.some(t=>t.slug===e.slug);return(0,Q.jsx)(W,{"data-pet-catalog":e.slug,icon:(0,Q.jsx)(Rn,{}),name:e.displayName,nameMeta:e.slug,status:t?n(`config:desktopPetSettings.installed`):void 0,actions:(0,Q.jsxs)(H,{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?E(e.slug):w(e.slug)),children:[t?(0,Q.jsx)(T,{}):(0,Q.jsx)(N,{}),n(t?`config:desktopPetSettings.use`:`config:desktopPetSettings.install`)]})},e.slug)})})]}),a&&a.installed.length>0&&(0,Q.jsx)(K,{title:n(`config:desktopPetSettings.installedTitle`),count:a.installed.length,"data-config-card":`desktop-pet-installed`,description:n(`config:desktopPetSettings.installedDescription`),children:(0,Q.jsx)(G,{children:a.installed.map(e=>{let t=e.slug===a.selectedSlug;return(0,Q.jsx)(W,{"data-pet-installed":e.slug,"data-selected":t||void 0,className:B(`relative`,t&&`after:absolute after:inset-y-3 after:-left-3 after:w-[3px] after:rounded-full after:bg-star`),icon:(0,Q.jsx)(Rn,{}),name:e.name,nameMeta:`${e.slug} · ${e.source===`pisper`?`Pisper`:`Petdex`}`,status:t?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,Q.jsx)(Et,{status:`done`,className:`size-3.5`}),n(`config:desktopPetSettings.inUse`)]}):void 0,actions:(0,Q.jsxs)(Q.Fragment,{children:[!t&&(0,Q.jsx)(H,{size:`sm`,variant:`ghost`,disabled:!!h,"aria-label":`${n(`config:desktopPetSettings.use`)}: ${e.name}`,onClick:()=>void E(e.slug),children:n(`config:desktopPetSettings.use`)}),e.source===`pisper`&&(0,Q.jsx)(H,{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,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(be,{})})]})},`${e.source}:${e.slug}`)})})})]})}function $(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 Oi(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 ki,Ai,ji,Mi,Ni,Pi,Fi=`__TAURI_TO_IPC_KEY__`;function Ii(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}var Li=class{constructor(e){ki.add(this),Ai.set(this,void 0),ji.set(this,0),Mi.set(this,[]),Ni.set(this,void 0),Oi(this,Ai,e||(()=>{}),`f`),this.id=Ii(e=>{let t=e.index;if(`end`in e){t==$(this,ji,`f`)?this.cleanupCallback():Oi(this,Ni,t,`f`);return}let n=e.message;if(t==$(this,ji,`f`)){for($(this,ki,`m`,Pi).call(this,n),Oi(this,ji,$(this,ji,`f`)+1,`f`);$(this,ji,`f`)in $(this,Mi,`f`);){let e=$(this,Mi,`f`)[$(this,ji,`f`)];$(this,ki,`m`,Pi).call(this,e),delete $(this,Mi,`f`)[$(this,ji,`f`)],Oi(this,ji,$(this,ji,`f`)+1,`f`)}$(this,ji,`f`)===$(this,Ni,`f`)&&this.cleanupCallback()}else $(this,Mi,`f`)[t]=n})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){Oi(this,Ai,e,`f`)}get onmessage(){return $(this,Ai,`f`)}[(Ai=new WeakMap,ji=new WeakMap,Mi=new WeakMap,Ni=new WeakMap,ki=new WeakSet,Pi=function(e){try{$(this,Ai,`f`).call(this,e)}catch(e){queueMicrotask(()=>{throw e})}},Fi)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[Fi]()}};function Ri(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function zi(e,t){return Ri(`plugin:barcode-scanner|${e}`,t)}function Bi(e){return e instanceof Error?e.message:String(e)}function Vi(e){return/cancel(?:led|ed)/i.test(Bi(e))}function Hi(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function Ui(e){return Array.isArray(e)?new TextDecoder().decode(Uint8Array.from(e)):``}function Wi(e){if(!e.isActive||!e.port)return null;let t=Ui(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=Ui(e.txt.name)||e.name||`Pisper Desktop`,a=`https://${r}:${e.port}`;return{id:`${e.fullName}:${a}`,name:i,url:a,fingerprint:t}}function Gi(e){return new Promise(t=>window.setTimeout(t,e))}function Ki({open:e,onOpenChange:t}){let{t:n}=u(),r=Kt(e),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)([]),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),b=(0,Z.useRef)(!1),x=(0,Z.useRef)(!1),S=(0,Z.useRef)(!1),C=(0,Z.useRef)(0),w=(0,Z.useRef)(``),T=(0,Z.useCallback)(e=>{b.current=e,s(e)},[]),E=(0,Z.useCallback)(async()=>{x.current=!0,b.current&&await zi(`cancel`).catch(()=>void 0),T(!1),a(null)},[T]);(0,Z.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,Z.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,Z.useCallback)(async()=>{let e=++C.current;f(!0),m(``),l([]);let t=new Li;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){l(e=>e.filter(e=>!e.id.startsWith(`${t.service?.fullName}:`)));return}let r=Wi(t.service);r&&l(e=>[...e.filter(e=>e.fingerprint!==r.fingerprint),r])};let r=null;try{await Ri(`mobile_ensure_local_network_permission`),r=(await Ri(`plugin:dns-sd|browse_start`,{options:{service:{type:`pisper`,protocol:`tcp`,domain:`local`},timeoutMs:4e3},channel:t})).browseId,await Gi(4300)}catch(t){C.current===e&&m(Bi(t).includes(`local_network_permission_denied`)?n(`config:mobileServer.localNetworkDenied`):n(`config:mobileServer.discoveryFailed`))}finally{r!==null&&await Ri(`plugin:dns-sd|browse_stop`,{browseId:r}).catch(()=>void 0),C.current===e&&f(!1)}},[n]);(0,Z.useEffect)(()=>{if(!(!e||o))return O(),()=>{C.current+=1}},[O,e,o]);let k=(0,Z.useCallback)(async()=>{let e=w.current;w.current=``,e&&await Ri(`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 Ri(`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(Bi(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 zi(`check_permissions`);if(e.camera!==`granted`&&(e=await zi(`request_permissions`)),e.camera!==`granted`)throw Error(n(`config:mobileServer.cameraDenied`));if(x.current||(T(!0),await Hi(),x.current))return;let t=await zi(`scan`,{windowed:!0,formats:[]});if(!t.content)throw Error(n(`config:mobileServer.scanFailed`));S.current=!0,D(await Ri(`mobile_pair`,{payloadJson:t.content,deviceName:null}))}catch(e){!x.current&&!Vi(e)&&v(Bi(e))}finally{T(!1),a(null),x.current=!1}};return(0,Q.jsx)(Mt,{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,Q.jsx)(Ot,{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,Q.jsxs)(`div`,{className:`flex h-dvh w-screen flex-col overflow-hidden`,children:[(0,Q.jsxs)(jt,{className:`sr-only`,children:[(0,Q.jsx)(kt,{children:n(`config:mobileServer.scanTitle`)}),(0,Q.jsx)(Dt,{children:n(`config:mobileServer.scanHint`)})]}),(0,Q.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,Q.jsxs)(H,{variant:`ghost`,className:`h-10 bg-black/40 px-3 text-white hover:bg-black/70 hover:text-white`,onClick:()=>void E(),children:[(0,Q.jsx)(y,{}),n(`config:mobileServer.cancelScan`)]}),(0,Q.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium`,children:n(`config:mobileServer.scanTitle`)}),(0,Q.jsx)(`div`,{className:`w-[88px]`,"aria-hidden":`true`})]}),(0,Q.jsx)(`main`,{className:`grid min-h-0 flex-1 place-items-center p-6`,children:(0,Q.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,Q.jsx)(Kn,{className:`absolute top-1/2 left-1/2 size-10 -translate-x-1/2 -translate-y-1/2 text-white/75`})})}),(0,Q.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,Q.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-white/90`,children:n(`config:mobileServer.scanHint`)}),(0,Q.jsx)(H,{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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(jt,{children:[(0,Q.jsx)(kt,{children:n(`config:mobileServer.addServer`)}),(0,Q.jsx)(Dt,{children:n(`config:mobileServer.discoverDescription`)})]}),(0,Q.jsxs)(`section`,{className:`grid gap-2`,"aria-live":`polite`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Q.jsx)(Wn,{className:`size-4`}),n(`config:mobileServer.nearby`)]}),(0,Q.jsx)(H,{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,Q.jsx)(fe,{className:d?`animate-spin`:void 0})})]}),c.length?(0,Q.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,Q.jsxs)(`li`,{className:`flex min-h-12 items-center justify-between gap-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(ge,{className:`size-4 flex-none text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`truncate text-sm`,children:e.name}),(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.url})]})]}),(0,Q.jsxs)(H,{size:`sm`,className:`pointer-coarse:min-h-11`,disabled:i!==null,onClick:()=>void A(e),children:[t?(0,Q.jsx)(ie,{className:`animate-spin`}):null,n(`config:mobileServer.requestConnect`)]})]},e.id)})}):(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:n(d?`config:mobileServer.discovering`:`config:mobileServer.noNearby`)}),p?(0,Q.jsx)(`p`,{role:`alert`,className:`text-xs leading-relaxed text-content-secondary`,children:p}):null,h?(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-[var(--r-md)] bg-surface-subtle px-3 py-2`,children:[(0,Q.jsx)(`p`,{role:`status`,className:`text-xs leading-relaxed`,children:h}),(0,Q.jsx)(H,{size:`sm`,variant:`outline`,className:`pointer-coarse:min-h-11`,onClick:()=>void k(),children:n(`config:mobileServer.cancelRequest`)})]}):null]}),(0,Q.jsxs)(`div`,{className:`relative py-1`,children:[(0,Q.jsx)(at,{}),(0,Q.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,Q.jsxs)(H,{className:`w-full pointer-coarse:min-h-11`,disabled:i!==null,onClick:()=>void j(),children:[i===`scan`?(0,Q.jsx)(ie,{className:`animate-spin`}):(0,Q.jsx)(Un,{}),n(`config:mobileServer.scan`)]}),_?(0,Q.jsx)(`p`,{role:`alert`,className:`text-xs leading-relaxed text-content-secondary`,children:_}):null]})})})}function qi(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function Ji({requestConfirm:e}){let{t}=u(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),d=(0,Z.useCallback)(async()=>{try{r(await qi(`mobile_state`)),a(``)}catch{a(t(`config:mobileServer.loadFailed`))}},[t]);(0,Z.useEffect)(()=>{d()},[d]);let f=async(e,t,n=``)=>{s(n||e);try{r(await qi(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 qi(`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,Q.jsxs)(Q.Fragment,{children:[(0,Q.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,Q.jsx)(Et,{status:`done`,className:`size-3.5`}):(0,Q.jsx)(k,{className:`size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:v}),n?.activeTransport?(0,Q.jsx)(`span`,{className:`flex-none font-mono text-xs text-content-muted`,children:y(n.activeTransport)}):null]}),(0,Q.jsx)(Ki,{open:c,onOpenChange:l}),i?(0,Q.jsx)(q,{className:`mt-3`,children:i}):null,(0,Q.jsx)(K,{title:t(`config:mobileServer.localTitle`),"data-config-card":`mobile-server-local`,children:(0,Q.jsx)(G,{children:(0,Q.jsx)(W,{icon:(0,Q.jsx)(qn,{}),name:t(`config:mobileServer.localTitle`),description:t(`config:mobileServer.localDescription`),status:h?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,Q.jsx)(Et,{status:`done`,className:`size-3.5`}),t(`config:mobileServer.currentLocal`)]}):void 0,actions:h?void 0:(0,Q.jsx)(H,{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 qi(`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,Q.jsx)(K,{title:t(`config:mobileServer.title`),count:n?.servers?.length??0,"data-config-card":`mobile-server-main`,description:t(`config:mobileServer.description`),actions:(0,Q.jsxs)(H,{size:`sm`,onClick:()=>l(!0),children:[(0,Q.jsx)(de,{}),t(`config:mobileServer.addServer`)]}),children:n?.servers?.length?(0,Q.jsx)(G,{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,Q.jsx)(W,{"data-mobile-server":e.id,icon:(0,Q.jsx)(ge,{}),name:e.name,nameMeta:t(i&&a?`config:mobileServer.transportLanP2p`:a?`config:mobileServer.transportP2p`:`config:mobileServer.transportLan`),description:(0,Q.jsx)(`span`,{className:`font-mono`,children:s}),status:r?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,Q.jsx)(Et,{status:`done`,className:`size-3.5`}),n.activeTransport?t(`config:mobileServer.activeTransport`,{transport:y(n.activeTransport)}):t(`config:mobileServer.current`)]}):void 0,actions:(0,Q.jsxs)(Q.Fragment,{children:[r?null:(0,Q.jsx)(H,{size:`sm`,variant:`ghost`,disabled:o===e.id,onClick:()=>void m(e.id),children:t(`config:mobileServer.connect`)}),(0,Q.jsx)(H,{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,Q.jsx)(be,{})})]})},e.id)})}):(0,Q.jsx)(Gt,{compact:!0,title:t(`config:mobileServer.empty`)})})]})}l.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 服务器地址`}),l.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 Yi({notify:e}){let{t,language:n}=u(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)([]),[l,d]=(0,Z.useState)([]),[f,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(``),E=(0,Z.useCallback)(async()=>{try{let[e,t,n,r]=await Promise.all([p(`/api/remote/status`),p(`/api/remote/devices`),p(`/api/remote/pairing-requests`).catch(()=>({requests:[]})),p(`/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,Z.useEffect)(()=>{E()},[E]),(0,Z.useEffect)(()=>{if(!r?.listening)return;let e=window.setInterval(()=>void E(),2e3);return()=>window.clearInterval(e)},[E,r?.listening]);let D=async n=>{S(!0);try{await p(`/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 E()}catch(n){e(t(`config:remoteAccess.toggleFailed`,{message:String(n)}),`error`)}finally{S(!1)}},O=async()=>{S(!0);try{await p(`/api/remote/firewall/retry`,{method:`POST`,body:{},timeout:15e4}),await E()}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 p(`/api/remote/pairing-code`,{method:`POST`});if(!e?.code||!e?.expiresAt)throw Error(t(`config:remoteAccess.qrUnavailable`));e.connectionInfo=await p(`/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 p(`/api/remote/pairing-requests/${encodeURIComponent(n.id)}/decision`,{method:`POST`,body:{approved:r}}),await E()}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 p(`/api/remote/devices/${encodeURIComponent(n.id)}/revoke`,{method:`POST`}),await E()}catch(n){e(t(`config:remoteAccess.revokeFailed`,{message:String(n)}),`error`)}};if(C&&!r)return(0,Q.jsx)(Ut,{kind:`error`,title:t(`config:remoteAccess.loadFailed`),action:(0,Q.jsxs)(H,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void E(),children:[(0,Q.jsx)(fe,{}),t(`config:remoteAccess.refresh`)]})});if(!r)return(0,Q.jsx)(Ut,{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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Mt,{open:h&&f!==null,onOpenChange:g,children:(0,Q.jsxs)(Ot,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(jt,{children:[(0,Q.jsx)(kt,{children:t(`config:remoteAccess.pairingQrTitle`)}),(0,Q.jsx)(Dt,{children:t(`config:remoteAccess.scanQrDescription`)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-2`,"aria-live":`polite`,children:[f?.qrDataUrl?(0,Q.jsx)(`img`,{src:f.qrDataUrl,alt:t(`config:remoteAccess.qrAlt`),className:`size-64 max-w-full rounded-sm border border-stroke bg-white p-2`}):null,_?(0,Q.jsx)(`p`,{role:`alert`,className:`text-center text-xs leading-relaxed text-content-secondary`,children:_}):null,f?(0,Q.jsxs)(`div`,{className:`text-center`,children:[(0,Q.jsx)(`div`,{className:`font-mono text-[20px] font-medium tracking-[0.2em] text-content`,children:f.code}),(0,Q.jsx)(`div`,{className:`mt-1 text-xs text-content-muted tabular-nums`,children:t(`config:remoteAccess.codeExpiresAt`,{time:Tt(f.expiresAt,n)})})]}):null]}),f?.connectionInfo&&(0,Q.jsxs)(`details`,{className:`min-w-0 rounded-md border border-stroke px-3 py-2 text-sm`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-content-secondary`,children:t(`remote-workspace:manualConnection`)}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-2 text-xs text-content-muted`,children:[(0,Q.jsx)(`div`,{children:t(`remote-workspace:serverAddress`)}),f.connectionInfo.endpoints.map(e=>(0,Q.jsx)(`code`,{className:`block font-mono break-all text-content select-all`,children:e.url},e.url)),(0,Q.jsx)(`div`,{children:t(`remote-workspace:fingerprint`)}),(0,Q.jsx)(`code`,{className:`block font-mono break-all text-content select-all`,children:f.connectionInfo.fingerprint})]})]}),(0,Q.jsx)(At,{children:(0,Q.jsxs)(H,{disabled:x,onClick:()=>void j(),children:[x?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(fe,{}),t(x?`config:remoteAccess.generatingQr`:`config:remoteAccess.regenerate`)]})})]})}),C&&(0,Q.jsx)(q,{children:C}),(0,Q.jsx)(K,{title:t(`config:remoteAccess.thisComputer`),"data-config-card":`remote-access-main`,children:(0,Q.jsxs)(G,{children:[(0,Q.jsx)(W,{icon:(0,Q.jsx)(ae,{}),name:t(`config:remoteAccess.allowConnections`),description:t(`config:remoteAccess.description`),status:(0,Q.jsx)(Xi,{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,Q.jsx)(st,{checked:r.enabled,disabled:x,onCheckedChange:e=>void D(e),"aria-label":t(`config:remoteAccess.title`)}),detail:r.error?(0,Q.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,Q.jsx)(W,{"aria-live":`polite`,icon:(0,Q.jsx)(_e,{}),name:t(`config:remoteAccess.firewallTitle`),description:a.busy?t(`config:remoteAccess.firewallWorking`):k[a.state],status:a.busy?(0,Q.jsx)(Xi,{glyph:`run`,children:t(`config:remoteAccess.firewallChecking`)}):F?(0,Q.jsx)(Xi,{attention:!0,children:t(`config:remoteAccess.firewallNeedsYou`)}):void 0,actions:r.enabled||a.state===`cleanup_pending`?(0,Q.jsxs)(H,{size:`sm`,variant:`secondary`,disabled:x||a.busy,onClick:()=>void O(),children:[x||a.busy?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(fe,{}),r.enabled?t(`config:remoteAccess.firewallRetry`):t(`config:remoteAccess.firewallRetryCleanup`)]}):void 0,detail:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-xs leading-relaxed text-content-muted`,children:[a.reason&&A[a.reason]?(0,Q.jsx)(`p`,{className:`text-content-secondary`,children:A[a.reason]}):null,r.enabled?(0,Q.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,Q.jsx)(`p`,{children:t(`config:remoteAccess.firewallReachability`)}),a.checkedAt?(0,Q.jsx)(`p`,{className:`tabular-nums`,children:t(`config:remoteAccess.firewallCheckedAt`,{time:Tt(a.checkedAt,n)})}):null]})}):null]})}),r.listening&&l.length?(0,Q.jsx)(K,{"aria-live":`polite`,title:t(`config:remoteAccess.pendingApprovals`),count:l.length,meta:(0,Q.jsx)(`span`,{className:`font-medium text-st-attn`,children:t(`config:remoteAccess.waitingForYou`)}),description:t(`config:remoteAccess.pendingApprovalsDescription`),children:(0,Q.jsx)(G,{children:l.map(e=>(0,Q.jsx)(W,{"data-pairing-request":e.id,icon:(0,Q.jsx)(qn,{}),name:e.deviceName,description:(0,Q.jsx)(`span`,{className:`font-mono`,children:t(`config:remoteAccess.requestSource`,{ip:e.ip})}),meta:t(`config:remoteAccess.requestedAt`,{time:Tt(e.requestedAt,n)}),actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(H,{size:`sm`,variant:`ghost`,disabled:y===e.id,onClick:()=>void M(e,!1),children:[(0,Q.jsx)(Ce,{}),t(`config:remoteAccess.reject`)]}),(0,Q.jsxs)(H,{size:`sm`,disabled:y===e.id,onClick:()=>void M(e,!0),children:[y===e.id?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(T,{}),t(`config:remoteAccess.approve`)]})]})},e.id))})}):null,r.listening?(0,Q.jsx)(K,{title:t(`config:remoteAccess.pairing`),"data-config-card":`remote-access-pairing`,children:(0,Q.jsx)(G,{children:(0,Q.jsx)(W,{icon:(0,Q.jsx)(Un,{}),name:t(`config:remoteAccess.pairWithPhone`),description:t(`config:remoteAccess.pairingDescription`),actions:(0,Q.jsxs)(H,{size:`sm`,disabled:x,onClick:()=>void j(),children:[x?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(Un,{}),t(x?`config:remoteAccess.generatingQr`:`config:remoteAccess.generateQr`)]}),detail:_&&!h?(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-content-secondary`,"aria-live":`polite`,children:_}):void 0})})}):null,(0,Q.jsx)(K,{title:t(`config:remoteAccess.devices`),count:s.length,"data-config-card":`remote-access-devices`,actions:(0,Q.jsx)(H,{size:`icon-sm`,variant:`ghost`,className:`pointer-coarse:size-11 max-[650px]:size-11`,onClick:()=>void E(),"aria-label":t(`config:remoteAccess.refresh`),title:t(`config:remoteAccess.refresh`),children:(0,Q.jsx)(fe,{})}),children:s.length===0?(0,Q.jsx)(Gt,{compact:!0,title:t(`config:remoteAccess.noDevices`)}):(0,Q.jsx)(G,{children:s.map(e=>(0,Q.jsx)(W,{icon:(0,Q.jsx)(qn,{}),name:e.name,nameMeta:e.current?t(`config:remoteAccess.currentDevice`):void 0,description:t(`config:remoteAccess.lastSeen`,{time:Tt(e.lastSeenAt,n)}),actions:(0,Q.jsx)(H,{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 Xi({attention:e=!1,glyph:t=null,children:n}){let r=e?`attention`:t;return(0,Q.jsxs)(`span`,{className:B(`inline-flex min-w-0 items-center gap-1.5 whitespace-nowrap`,e?`font-medium text-st-attn`:`text-content-secondary`),children:[r&&(0,Q.jsx)(Et,{status:r,className:`size-3.5`}),n]})}function Zi({requestConfirm:e}){let{t}=u(),n=window.pisperDesktop?.remoteWorkspaces,[r,i]=(0,Z.useState)([]),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),[l,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(``),v=(0,Z.useCallback)(async()=>{n&&i(await n.list())},[n]);(0,Z.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,Q.jsx)(K,{title:t(`config:remoteWorkspace.title`),"data-config-card":`remote-workspaces`,children:(0,Q.jsx)(G,{children:(0,Q.jsx)(W,{icon:(0,Q.jsx)(ge,{}),name:t(`remote-workspace:activeTitle`),description:t(`remote-workspace:activeDescription`),detail:(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:t(`remote-workspace:isolation`)})})})}):n?(0,Q.jsxs)(K,{title:t(`config:remoteWorkspace.title`),count:r.length,"data-config-card":`remote-workspaces`,description:t(`remote-workspace:description`),actions:(0,Q.jsx)(H,{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,Q.jsx)(fe,{className:`size-3.5`})}),children:[r.length>0&&(0,Q.jsx)(G,{children:r.map(r=>(0,Q.jsx)(W,{icon:(0,Q.jsx)(ge,{}),name:r.name,description:(0,Q.jsx)(`span`,{className:`font-mono`,children:r.address}),actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(H,{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,Q.jsx)(x,{className:`size-3.5`})]}),(0,Q.jsx)(H,{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,Q.jsx)(be,{className:`size-3.5`})})]})},r.id))}),(0,Q.jsxs)(`div`,{className:`@container/card mt-3 rounded-[var(--r-md)] border border-stroke px-3 pt-2 pb-1`,children:[(0,Q.jsx)(`p`,{className:`py-1.5 text-xs leading-relaxed text-content-secondary`,children:t(`remote-workspace:instructions`)}),(0,Q.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:l,code:f});p(``),await v(),await n.open(e),await v()})},children:[(0,Q.jsx)(bi,{label:t(`remote-workspace:name`),htmlFor:`remote-workspace-name`,children:(0,Q.jsx)(U,{id:`remote-workspace-name`,value:a,maxLength:160,disabled:m,placeholder:`Linux`,onChange:e=>o(e.target.value)})}),(0,Q.jsx)(bi,{label:t(`remote-workspace:address`),htmlFor:`remote-workspace-address`,children:(0,Q.jsx)(U,{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,Q.jsx)(bi,{label:t(`remote-workspace:fingerprint`),htmlFor:`remote-workspace-fingerprint`,children:(0,Q.jsx)(U,{id:`remote-workspace-fingerprint`,value:l,required:!0,disabled:m,placeholder:`SHA256:…`,autoComplete:`off`,spellCheck:!1,className:`font-mono text-xs`,onChange:e=>d(e.target.value)})}),(0,Q.jsx)(bi,{label:t(`remote-workspace:code`),htmlFor:`remote-workspace-code`,children:(0,Q.jsx)(U,{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,Q.jsx)(`div`,{className:`flex justify-end py-3`,children:(0,Q.jsxs)(H,{type:`submit`,className:`max-[650px]:h-11`,disabled:m,children:[m?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(x,{className:`size-3.5`}),t(`remote-workspace:pair`)]})})]})]}),g&&(0,Q.jsx)(q,{className:`mt-3`,children:g}),(0,Q.jsx)(`p`,{className:`mt-3 text-xs leading-relaxed text-content-muted`,children:t(`remote-workspace:isolation`)})]}):null}function Qi(e){let t=e.lastIndexOf(`@`);return t<0?{user:``,host:e}:{user:e.slice(0,t),host:e.slice(t+1)}}function $i(e){let t=e.system?.name?` · ${e.system.name}`:``;return e.kind===`node`?e.roots.join(` · `)+t:(e.port?`${e.target}:${e.port}`:e.target)+t}function ea({machine:e,onDone:t,onCancel:n}){let{t:r}=u(),i=(0,Z.useId)(),[a,o]=(0,Z.useState)(e?.name??``),[s,c]=(0,Z.useState)(()=>Qi(e?.target??``).host),[l,d]=(0,Z.useState)(()=>Qi(e?.target??``).user),f=l.trim()?`${l.trim()}@${s.trim()}`:s.trim(),[p,m]=(0,Z.useState)(e?.port?String(e.port):``),[h,g]=(0,Z.useState)(e?.defaultCwd??``),[_,v]=(0,Z.useState)(e?.auth??`key`),[y,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(``),D=!!e&&(f!==e?.target||(p.trim()?Number(p.trim()):null)!==(e?.port??null)),O=!!e?.passwordSet&&e?.auth===`password`,[k,A]=(0,Z.useState)(null),[j,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)(``),ee=e?.auth===`password`&&!D?e.hostKey??null:null,te=k??ee,ne=!!k&&(!ee||ee.fingerprint!==k?.fingerprint),R=O&&!D&&!ne,re=_===`password`&&!y&&!R,ie=_===`password`&&!l.trim(),z=_!==`password`||(k?j:!!ee),ae=!s.trim()||ie||re||!z,oe=()=>({target:f,port:p.trim()?Number(p.trim()):null}),se=()=>({...oe(),auth:_,..._===`password`&&y?{password:y}:{},..._===`password`&&k&&j?{hostKey:{type:k.type,key:k.key}}:{}}),ce=()=>{A(null),N(!1),L(``),w(null)},le=async()=>{F(!0),L(``),N(!1);try{let e=await Ft(oe());e.ok?A(e.hostKey):(A(null),L(dn(r,e.code,e.message)))}catch(e){A(null),L(dn(r,Rt(e),e instanceof Error?e.message:``))}finally{F(!1)}},ue=e=>E(dn(r,Rt(e),e instanceof Error?e.message:``,{auth:_})),de=async()=>{S(`test`),E(``),w(null);try{w(await It({...se(),...e?{id:e.id}:{}}))}catch(e){ue(e)}finally{S(``)}},fe=async n=>{if(n.preventDefault(),!ae){S(`save`),E(``);try{let n={name:a.trim(),...se(),defaultCwd:h.trim()},r=e?await Ht(e.id,n):await zt(n);await Vt(r.id).catch(()=>void 0),b(``),t()}catch(e){ue(e)}finally{S(``)}}};return(0,Q.jsxs)(`form`,{onSubmit:e=>void fe(e),"data-machine-ssh-form":e?`edit`:`add`,"aria-label":e?r(`machines:edit`,{name:e.name}):r(`machines:addSsh`),className:`mt-3 grid gap-3 rounded-[var(--r-md)] border border-stroke bg-surface-subtle p-3`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_7rem]`,children:[(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[r(`machines:form.target`),(0,Q.jsx)(U,{id:`${i}-target`,required:!0,autoFocus:!0,spellCheck:!1,value:s,className:`font-mono text-xs`,placeholder:r(`machines:form.targetPlaceholder`),"data-machine-target":!0,onChange:e=>{let t=Qi(e.target.value);c(t.host),t.user&&d(t.user),ce()}})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[r(`machines:form.port`),(0,Q.jsx)(U,{inputMode:`numeric`,value:p,className:`font-mono text-xs`,placeholder:`22`,"data-machine-port":!0,onChange:e=>{m(e.target.value),ce()}})]})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[r(`machines:form.user`),(0,Q.jsx)(U,{spellCheck:!1,autoCapitalize:`off`,autoComplete:`username`,value:l,required:_===`password`,className:`font-mono text-xs`,placeholder:r(_===`password`?`machines:form.userPlaceholder`:`machines:form.userPlaceholderKey`),"data-machine-user":!0,onChange:e=>{d(e.target.value),ce()}})]}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[(0,Q.jsx)(`span`,{id:`${i}-auth`,children:r(`machines:form.auth`)}),(0,Q.jsx)(ct,{"aria-labelledby":`${i}-auth`,value:_,onValueChange:e=>{v(e),w(null)},options:[{value:`key`,label:r(`machines:form.authKey`)},{value:`password`,label:r(`machines:form.authPassword`)}],"data-machine-auth":!0})]}),_===`password`&&(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[r(`machines:form.password`),(0,Q.jsx)(U,{type:`password`,autoComplete:`new-password`,spellCheck:!1,value:y,required:!R,placeholder:R?r(`machines:form.passwordKeep`):``,"aria-describedby":`${i}-password-hint`,"data-machine-password":!0,onChange:e=>b(e.target.value)})]}),_===`password`&&(0,Q.jsxs)(`section`,{"aria-labelledby":`${i}-host-key`,"data-machine-host-key":z?`confirmed`:te?`shown`:`missing`,className:`grid gap-2 rounded-[var(--r-md)] border border-stroke bg-surface-raised p-3 text-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`span`,{id:`${i}-host-key`,className:`inline-flex items-center gap-1.5 font-medium text-content-secondary`,children:[(0,Q.jsx)(zn,{className:`size-3.5`,"aria-hidden":`true`}),r(`machines:form.hostKey`)]}),(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsxs)(H,{type:`button`,variant:`outline`,size:`sm`,disabled:P||!s.trim(),"data-machine-host-key-fetch":!0,onClick:()=>void le(),children:[P&&(0,Q.jsx)(V,{className:`size-3.5`}),r(te?`machines:form.hostKeyRefetch`:`machines:form.hostKeyFetch`)]})]}),te?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(`code`,{className:`min-w-0 flex-1 rounded-[var(--r-sm)] bg-surface-subtle px-2 py-1.5 font-mono break-all text-content select-all`,"data-machine-host-key-fingerprint":!0,children:[te.type,` `,te.fingerprint]}),(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":r(`machines:form.hostKeyCopy`),title:r(`machines:form.hostKeyCopy`),onClick:()=>void navigator.clipboard?.writeText(`${te.type} ${te.fingerprint}`).catch(()=>void 0),children:(0,Q.jsx)(M,{className:`size-3.5`})})]}),k?(0,Q.jsxs)(`label`,{htmlFor:`${i}-host-key-confirm`,className:`flex items-start gap-2 text-content-secondary`,children:[(0,Q.jsx)(Ve,{id:`${i}-host-key-confirm`,checked:j,"data-machine-host-key-confirm":!0,onCheckedChange:e=>{N(e===!0),w(null)}}),(0,Q.jsx)(`span`,{children:ee&&ee.fingerprint!==k.fingerprint?r(`machines:form.hostKeyConfirmChanged`):r(`machines:form.hostKeyConfirm`)})]}):(0,Q.jsx)(`p`,{className:`m-0 text-content-muted`,children:r(`machines:form.hostKeySaved`)})]}):(0,Q.jsx)(`p`,{className:`m-0 text-content-muted`,children:r(`machines:form.hostKeyMissing`)}),(0,Q.jsx)(`p`,{className:`m-0 text-content-muted`,children:r(`machines:form.hostKeyHint`)}),I&&(0,Q.jsx)(q,{className:`mt-0`,children:I})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[r(`machines:form.name`),(0,Q.jsx)(U,{value:a,placeholder:r(`machines:form.namePlaceholder`),"data-machine-name":!0,onChange:e=>o(e.target.value)})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[r(`machines:form.defaultCwd`),(0,Q.jsx)(U,{spellCheck:!1,value:h,className:`font-mono text-xs`,placeholder:`~`,onChange:e=>g(e.target.value)})]})]}),(0,Q.jsxs)(`p`,{id:`${i}-password-hint`,className:`m-0 text-xs text-content-muted`,children:[_===`password`&&O&&D&&(0,Q.jsxs)(`span`,{"data-machine-password-again":!0,children:[r(`machines:form.passwordAgain`),` `]}),_===`password`&&O&&!D&&ne&&(0,Q.jsxs)(`span`,{"data-machine-password-again":`host-key`,children:[r(`machines:form.passwordAgainHostKey`),` `]}),r(_===`password`?`machines:form.passwordHint`:`machines:form.keyHint`)]}),C?.ok&&(0,Q.jsx)(`p`,{role:`status`,className:`m-0 text-xs text-success`,"data-machine-test-ok":!0,children:r(`machines:form.testOk`,{platform:C.platform,home:C.home})}),C&&!C.ok&&(0,Q.jsx)(q,{className:`mt-0`,"data-machine-test-failed":!0,children:dn(r,C.code,C.message,{auth:_})}),T&&(0,Q.jsx)(q,{className:`mt-0`,children:T}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,Q.jsx)(H,{type:`button`,variant:`ghost`,onClick:n,children:r(`machines:form.cancel`)}),(0,Q.jsxs)(H,{type:`button`,variant:`outline`,disabled:!!x||ae,"data-machine-test":!0,onClick:()=>void de(),children:[x===`test`&&(0,Q.jsx)(V,{className:`size-3.5`}),r(x===`test`?`machines:form.testing`:`machines:form.test`)]}),(0,Q.jsx)(H,{type:`submit`,disabled:!!x||ae,"data-machine-save":!0,children:r(`machines:form.save`)})]})]})}function ta({pairing:e,onDone:t}){let{t:n}=u(),[r,i]=(0,Z.useState)(!1),a=fn(e,{brain:n(`machines:pair.brainPlaceholder`),fingerprint:`SHA256:…`,root:n(`machines:pair.rootPlaceholder`)}),o=async()=>{try{await navigator.clipboard.writeText(a.join(`
|
|
2
2
|
`)),i(!0)}catch{i(!1)}};return(0,Q.jsxs)(`section`,{"aria-label":n(`machines:addNode`),"data-machine-pairing":!0,className:`mt-3 grid gap-2 rounded-[var(--r-md)] border border-stroke bg-surface-subtle p-3 text-xs`,children:[(0,Q.jsx)(`p`,{className:`m-0 text-content-secondary`,children:n(`machines:pair.description`)}),!e.remote.enabled&&(0,Q.jsx)(q,{className:`mt-0`,"data-machine-remote-off":!0,children:n(`machines:pair.remoteOff`)}),(0,Q.jsxs)(`p`,{className:`m-0 text-content-muted`,children:[n(`machines:pair.code`),` `,(0,Q.jsx)(`b`,{className:`font-mono text-content`,"data-machine-pairing-code":!0,children:e.code}),` `,`· `,n(`machines:pair.codeHint`)]}),(0,Q.jsx)(`p`,{className:`m-0 text-content-muted`,children:n(`machines:pair.runThere`)}),(0,Q.jsx)(`pre`,{className:`m-0 max-h-40 overflow-auto rounded-[var(--r-sm)] bg-surface-raised p-2.5 font-mono break-all whitespace-pre-wrap text-content-secondary`,children:a.join(`
|
|
3
3
|
`)}),(0,Q.jsx)(`p`,{className:`m-0 text-content-muted`,children:n(`machines:pair.rootHint`)}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsxs)(H,{type:`button`,variant:`outline`,onClick:()=>void o(),children:[(0,Q.jsx)(M,{"aria-hidden":`true`}),n(r?`machines:pair.copied`:`machines:pair.copy`)]}),(0,Q.jsx)(H,{type:`button`,onClick:t,children:n(`machines:pair.done`)})]})]})}function na({machine:e,checking:t}){let{t:n}=u(),r=e.kind===`ssh`&&!e.lastCheck,i=t?n(`machines:status.checking`):e.kind===`node`?e.online?n(`machines:status.online`):n(`machines:status.offline`):r?n(`machines:status.unchecked`):e.online?n(`machines:status.reachable`):n(`machines:status.unreachable`);return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-content-muted`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:B(`size-2 flex-none rounded-full`,e.online?`bg-success`:r?`bg-content-faint`:`bg-st-attn`)}),i]})}function ra({requestConfirm:e}){let{t}=u(),n=r(),{available:i,machines:a,refresh:o}=re(),[s,c]=(0,Z.useState)(!1),[l,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(``);if(!i)return null;let v=async()=>{_(``),c(!1),d(null);try{p(await Lt())}catch(e){_(e instanceof Error?e.message:String(e))}},y=async e=>{h(e.id),_(``);try{let n=await Vt(e.id);n.ok||_(dn(t,n.code,n.message,{auth:e.auth})),await o()}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(``)}},b=async n=>{if(await e({title:t(`machines:remove`,{name:n.name}),message:t(`machines:removeDescription`)})){_(``);try{await Bt(n.id),l?.id===n.id&&d(null),await o()}catch(e){_(e instanceof Error?e.message:String(e))}}};return(0,Q.jsxs)(K,{title:t(`machines:title`),count:a.length,description:t(`machines:description`),"data-config-card":`remote-machines`,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(H,{type:`button`,variant:`outline`,"data-machine-add-ssh":!0,onClick:()=>{p(null),d(null),c(!0)},children:[(0,Q.jsx)(de,{"aria-hidden":`true`}),t(`machines:addSsh`)]}),(0,Q.jsxs)(H,{type:`button`,variant:`outline`,"data-machine-add-node":!0,onClick:()=>void v(),children:[(0,Q.jsx)(R,{"aria-hidden":`true`}),t(`machines:addNode`)]})]}),children:[a.length>0&&(0,Q.jsx)(G,{children:a.map(e=>(0,Q.jsx)(W,{"data-machine":e.id,icon:e.kind===`ssh`?(0,Q.jsx)(ge,{}):(0,Q.jsx)(R,{}),name:e.name||t(`machines:unnamed`),description:(0,Q.jsx)(`span`,{className:`font-mono`,children:$i(e)}),status:(0,Q.jsx)(na,{machine:e,checking:m===e.id}),actions:(0,Q.jsxs)(Q.Fragment,{children:[e.kind===`ssh`&&(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":t(`machines:edit`,{name:e.name}),title:t(`machines:edit`,{name:e.name}),"data-machine-edit":!0,onClick:()=>{c(!1),p(null),d(e)},children:(0,Q.jsx)(le,{className:`size-3.5`})}),e.kind===`ssh`&&(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:!!m,"aria-label":t(`machines:recheck`,{name:e.name}),title:t(`machines:recheck`,{name:e.name}),onClick:()=>void y(e),children:(0,Q.jsx)(fe,{className:`size-3.5`})}),(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`hover:bg-danger-soft hover:text-danger`,"aria-label":t(`machines:remove`,{name:e.name}),title:t(`machines:remove`,{name:e.name}),onClick:()=>void b(e),children:(0,Q.jsx)(be,{className:`size-3.5`})})]})},e.id))}),g&&(0,Q.jsx)(q,{"data-machine-failure":!0,children:g}),s&&(0,Q.jsx)(ea,{onCancel:()=>c(!1),onDone:()=>{c(!1),o()}}),l&&(0,Q.jsx)(ea,{machine:l,onCancel:()=>d(null),onDone:()=>{d(null),o()}},l.id),f&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ta,{pairing:f,onDone:()=>{p(null),o()}}),!f.remote.enabled&&(0,Q.jsx)(H,{type:`button`,variant:`ghost`,className:`mt-1`,onClick:()=>n(`/config/remote-access`),children:t(`machines:pair.openRemote`)})]})]})}function ia({section:e,notify:t,requestConfirm:n,onBack:r}){let{t:i}=u(),a=h(e=>e.capabilities),o=g(),s=m(a,e,{mobileApp:o}),c=i(e===`remote-access`?`config:configPage.remoteAccess`:e===`mobile-server`?`config:configPage.mobileServer`:`config:configPage.desktopPet`),l=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,Q.jsx)(Di,{notify:t,requestConfirm:n}):e===`mobile-server`?(0,Q.jsx)(Ji,{requestConfirm:n}):(0,Q.jsxs)(Q.Fragment,{children:[!window.__PISPER_REMOTE_WORKSPACE__&&(0,Q.jsx)(Yi,{notify:t}),(0,Q.jsx)(Zi,{requestConfirm:n}),(0,Q.jsx)(ra,{requestConfirm:n})]}):(0,Q.jsx)(aa,{section:e,support:s}),(0,Q.jsx)(qt,{"data-device-feature":e,title:c,description:l,back:r&&{label:i(`navigation:sidebar.features`),ariaLabel:i(`navigation:shell.backToFeaturesLabel`),onBack:r},children:(0,Q.jsx)(`div`,{"data-config-card":pt,className:`min-w-0`,children:d})})}function aa({section:e,support:t}){let{t:n}=u(),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,Q.jsx)(K,{title:n(`config:deviceFeature.unavailableTitle`),"data-device-unsupported":!0,children:(0,Q.jsx)(G,{children:(0,Q.jsx)(W,{icon:e===`desktop-pet`?(0,Q.jsx)(C,{}):(0,Q.jsx)(ae,{}),name:r,description:i,status:n(`config:deviceFeature.unavailable`),actions:(0,Q.jsx)(st,{checked:!1,disabled:!0,"aria-label":r})})})})}function oa({className:e,...t}){return(0,Q.jsx)(ri,{"data-slot":`radio-group`,className:B(`grid w-full gap-2`,e),...t})}function sa({className:e,...t}){return(0,Q.jsx)(ci,{"data-slot":`radio-group-option`,className:B(`disabled:pointer-events-none disabled:opacity-50`,e),...t})}function ca(e,t){return t(e===`en-US`?`config:languageSettings.english`:`config:languageSettings.simplifiedChinese`)}function la({notify:e}){let{language:t,setLanguage:n,t:r}=u(),i=(0,Z.useId)(),a=(0,Z.useId)(),o=r=>{r!==t&&(n(r),e(c(r===`en-US`?`config:languageSettings.displayLanguageChangedToEnglish`:`config:languageSettings.displayLanguageChangedToSimplifiedChinese`,r)))};return(0,Q.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,Q.jsxs)(`div`,{className:`min-w-0 flex-1 basis-40`,children:[(0,Q.jsx)(`h2`,{id:i,className:`text-sm font-medium text-content`,children:r(`config:languageSettings.displayLanguage`)}),(0,Q.jsx)(`p`,{id:a,className:`mt-0.5 text-xs leading-relaxed text-content-muted`,children:r(`config:languageSettings.interfaceOnlyHint`)})]}),(0,Q.jsxs)(it,{value:t,onValueChange:e=>{let t=s.find(t=>t.value===e);t&&o(t.value)},children:[(0,Q.jsx)(tt,{"aria-labelledby":i,"aria-describedby":a,className:`min-w-36 shrink-0`,children:(0,Q.jsx)(et,{})}),(0,Q.jsx)(nt,{align:`end`,children:s.map(e=>(0,Q.jsx)(rt,{value:e.value,children:ca(e.value,r)},e.value))})]})]})}function ua({role:e,label:t,value:n,onCommit:r}){let{t:i}=u(),a=(0,Z.useId)(),[o,s]=(0,Z.useState)(String(n)),c=(0,Z.useRef)(o),l=(0,Z.useRef)(n),d=e===`ui`?Dn:Tn;(0,Z.useEffect)(()=>{l.current=n,c.current=String(n),s(String(n))},[n]);let f=o!==String(n)&&En(o,e)===null,p=()=>{let t=En(c.current,e);t!==null&&t!==l.current&&(r(t),l.current=t)};return(0,Q.jsxs)(`div`,{className:`flex max-w-full flex-col items-end gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(U,{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,Q.jsx)(`span`,{className:`text-sm text-content-muted`,children:`px`})]}),f&&(0,Q.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 da({label:e,options:t,value:n,onChange:r}){return(0,Q.jsx)(oa,{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,Q.jsx)(sa,{type:`button`,className:B(`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 fa={neutral:`var(--primary)`,blue:`#3d4bef`,teal:`#0f766e`,violet:`#6d4ad6`,coral:`#c93a48`,custom:`#3d4bef`};function pa(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 ma({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 ha({value:e,onCommit:t}){let{t:n}=u(),[r,i]=(0,Z.useState)(e),a=(0,Z.useRef)(e),[o,s]=(0,Z.useState)(()=>pa(e)),c=(0,Z.useId)(),l=e=>{a.current=e,i(e)};(0,Z.useEffect)(()=>{a.current=e,i(e),s(pa(e))},[e]);let d=e=>{s(e),l(ma(e))},f=()=>{let n=pn(a.current);n&&n!==pn(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()&&!pn(r);return(0,Q.jsxs)($e,{onOpenChange:t=>{t||(f(),pn(a.current)||(l(e),s(pa(e))))},children:[(0,Q.jsx)(Ze,{asChild:!0,children:(0,Q.jsxs)(H,{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,Q.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 shrink-0 rounded-full border border-stroke-strong`,style:{backgroundColor:e}}),(0,Q.jsx)(`span`,{className:`font-mono`,children:e})]})}),(0,Q.jsxs)(Qe,{align:`end`,sideOffset:8,className:`w-auto rounded-xl p-3`,children:[(0,Q.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:()=>{l(e),s(pa(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,Q.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,Q.jsx)(ot,{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,Q.jsx)(U,{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=>{l(e.target.value);let t=pn(e.target.value);t&&s(pa(t))},onBlur:f,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f())}}),(0,Q.jsx)(`p`,{id:c,className:`max-w-34 text-xs text-muted-foreground`,children:n(m?`config:interfaceSettings.invalidAccentColor`:`config:interfaceSettings.colorSpectrumHint`)})]})]})}function ga({notify:e,defaultAdvancedExpanded:t=!1,navigationKey:n}){let{t:r}=u(),{theme:i,density:a,accent:o,customAccent:s,uiFontSize:c,codeFontSize:l,radius:d,motion:f,setTheme:p,setDensity:m,setAccent:h,setCustomAccent:g,setUiFontSize:_,setCodeFontSize:y,setRadius:b,setMotion:x,resetAppearance:S}=mn(),C=ln(e=>e.pinned),w=ln(e=>e.setPinned),[T,D]=(0,Z.useState)(t),O=(0,Z.useId)(),k=(0,Z.useId)();(0,Z.useEffect)(()=>{t&&D(!0)},[t,n]);let A=i!==vn.theme||a!==vn.density||o!==vn.accent||s!==vn.customAccent||c!==vn.uiFontSize||l!==vn.codeFontSize||d!==vn.radius||f!==vn.motion,j=t=>n=>{t(n),e(r(`config:interfaceSettings.preferencesUpdated`))},M=[{value:`system`,label:r(`config:interfaceSettings.followSystem`),description:r(`config:interfaceSettings.followSystemDescription`),icon:Vn},{value:`light`,label:r(`config:interfaceSettings.light`),description:r(`config:interfaceSettings.lightDescription`),icon:Yn},{value:`dark`,label:r(`config:interfaceSettings.dark`),description:r(`config:interfaceSettings.darkDescription`),icon:Hn}],N=[{value:`comfortable`,label:r(`config:interfaceSettings.comfortable`),description:r(`config:interfaceSettings.comfortableDescription`),icon:Zn},{value:`compact`,label:r(`config:interfaceSettings.compact`),description:r(`config:interfaceSettings.compactDescription`),icon:Bn}],P=[{value:`system`,label:r(`config:interfaceSettings.motionSystem`),description:r(`config:interfaceSettings.motionSystemDescription`),icon:Vn},{value:`full`,label:r(`config:interfaceSettings.motionFull`),description:r(`config:interfaceSettings.motionFullDescription`),icon:ye},{value:`reduced`,label:r(`config:interfaceSettings.motionReduced`),description:r(`config:interfaceSettings.motionReducedDescription`),icon:v}],F=[{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`)}],I=[{value:`sharp`,label:r(`config:interfaceSettings.sharp`)},{value:`default`,label:r(`config:interfaceSettings.standard`)},{value:`soft`,label:r(`config:interfaceSettings.soft`)}];return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsx)(Zt,{title:r(`config:interfaceSettings.visualStyle`),description:r(`config:interfaceSettings.appearanceDescription`),"data-config-card":`interface-appearance`,action:(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,className:`pointer-coarse:h-11`,disabled:!A,onClick:()=>{S(),e(r(`config:interfaceSettings.defaultsRestored`))},children:[(0,Q.jsx)(me,{size:14}),r(`config:interfaceSettings.restoreDefaults`)]}),children:(0,Q.jsxs)(yi,{children:[(0,Q.jsx)(X,{title:r(`config:interfaceSettings.colorMode`),control:(0,Q.jsx)(`div`,{role:`radiogroup`,"aria-label":r(`config:interfaceSettings.colorMode`),className:`grid w-68 max-w-full grid-cols-3 gap-4`,children:M.map(e=>(0,Q.jsxs)(`label`,{className:`group flex min-w-0 cursor-pointer flex-col items-center gap-2 text-xs text-content-muted`,children:[(0,Q.jsx)(`input`,{className:`peer sr-only`,type:`radio`,name:k,value:e.value,checked:i===e.value,onChange:()=>j(p)(e.value)}),(0,Q.jsxs)(`span`,{"aria-hidden":`true`,className:B(`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,Q.jsxs)(`span`,{className:`absolute inset-2 rounded border border-(--preview-light-line) bg-(--preview-light-bg)`,children:[(0,Q.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-1/4 border-r border-(--preview-light-line) bg-(--preview-light-side)`}),(0,Q.jsx)(`span`,{className:`absolute top-3 right-1 h-0.5 w-1/2 rounded bg-(--preview-light-line)`}),(0,Q.jsx)(`span`,{className:`absolute top-5 right-2 h-0.5 w-1/3 rounded bg-(--preview-light-line)`})]}),e.value!==`light`&&(0,Q.jsxs)(`span`,{className:B(`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,Q.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-1/4 border-r border-(--preview-dark-line) bg-(--preview-dark-side)`}),(0,Q.jsx)(`span`,{className:`absolute top-3 right-1 h-0.5 w-1/2 rounded bg-(--preview-dark-line)`}),(0,Q.jsx)(`span`,{className:`absolute top-5 right-2 h-0.5 w-1/3 rounded bg-(--preview-dark-line)`})]})]}),(0,Q.jsx)(`span`,{className:B(i===e.value&&`font-medium text-content`),children:e.label})]},e.value))})}),(0,Q.jsx)(X,{title:r(`config:interfaceSettings.accentColor`),description:r(`config:interfaceSettings.accentDescription`),control:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Q.jsxs)(it,{value:o,onValueChange:e=>{let t=F.find(t=>t.value===e);t&&j(h)(t.value)},children:[(0,Q.jsx)(tt,{"aria-label":r(`config:interfaceSettings.accentColor`),className:`min-w-36`,children:(0,Q.jsx)(et,{})}),(0,Q.jsx)(nt,{align:`end`,children:F.map(e=>(0,Q.jsxs)(rt,{value:e.value,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 rounded-full border border-stroke-strong`,style:{backgroundColor:e.value===`custom`?s:fa[e.value]}}),e.label]},e.value))})]}),o===`custom`&&(0,Q.jsx)(ha,{value:pn(s)||vn.customAccent,onCommit:j(g)})]})})]})}),(0,Q.jsxs)(ze,{open:T,onOpenChange:D,children:[(0,Q.jsx)(Le,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"aria-controls":O,"aria-expanded":T,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,Q.jsx)(E,{size:16,"aria-hidden":`true`,className:B(`text-content-muted transition-transform`,!T&&`-rotate-90`)}),r(`config:interfaceSettings.advanced`)]})}),(0,Q.jsx)(Fe,{id:O,children:(0,Q.jsxs)(yi,{className:`mt-3`,children:[(0,Q.jsxs)(`div`,{className:`divide-y divide-stroke-soft`,"data-config-card":`interface-style`,children:[(0,Q.jsx)(X,{title:r(`config:interfaceSettings.uiFontSize`),description:r(`config:interfaceSettings.numericFontHint`),control:(0,Q.jsx)(ua,{role:`ui`,label:r(`config:interfaceSettings.uiFontSize`),value:c,onCommit:j(_)})}),(0,Q.jsx)(X,{title:r(`config:interfaceSettings.codeFontSize`),control:(0,Q.jsx)(ua,{role:`code`,label:r(`config:interfaceSettings.codeFontSize`),value:l,onCommit:j(y)})}),(0,Q.jsx)(X,{title:r(`config:interfaceSettings.cornerStyle`),control:(0,Q.jsx)(da,{label:r(`config:interfaceSettings.cornerStyle`),options:I,value:d,onChange:j(b)})})]}),(0,Q.jsxs)(`div`,{className:`divide-y divide-stroke-soft`,"data-config-card":`interface-motion`,children:[(0,Q.jsx)(X,{title:r(`config:interfaceSettings.interfaceDensity`),control:(0,Q.jsx)(da,{label:r(`config:interfaceSettings.interfaceDensity`),options:N,value:a,onChange:j(m)})}),(0,Q.jsx)(X,{title:r(`config:interfaceSettings.pinInspector`),description:r(`config:interfaceSettings.pinInspectorDescription`),control:(0,Q.jsx)(st,{checked:C,onCheckedChange:j(w),"aria-label":r(`config:interfaceSettings.pinInspector`),"data-setting":`pin-inspector`})}),(0,Q.jsx)(X,{title:r(`config:interfaceSettings.motion`),control:(0,Q.jsx)(da,{label:r(`config:interfaceSettings.motion`),options:P,value:f,onChange:j(x)})}),(0,Q.jsx)(X,{title:r(`config:interfaceSettings.automaticByTime`),description:r(`config:interfaceSettings.automaticByTimeDescription`),control:(0,Q.jsx)(st,{checked:i===`scheduled`,onCheckedChange:e=>j(p)(e?`scheduled`:`system`),"aria-label":r(`config:interfaceSettings.automaticByTime`)})})]})]})})]}),(0,Q.jsx)(la,{notify:e})]})}function _a({requestConfirm:e}){let{t}=u(),n=ht(e=>e.bindings),r=ht(e=>e.boardBindings),i=ht(e=>e.setBinding),a=ht(e=>e.setBoardBinding),o=ht(e=>e.resetBindings),[s,c]=(0,Z.useState)(null),[l,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(!1),m=On(),h=m.actions,g=m.boardActions,_=(e,n)=>{p(!1);let i=bt(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=vt(n,e,r);if(a){d({action:e,message:t(`config:shortcuts.conflict`,{action:h[a]})});return}try{mt({...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=yt.includes(n),i=r?St(e.nativeEvent):xt(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=_t.some(e=>n[e]!==gt[e])||yt.some(e=>r[e]!==wt[e]),S=e=>{let i=yt.includes(e),a=i?g[e]:h[e],o=i?r[e]:n[e],u=i?wt[e]:gt[e],f=t=>i?_(e,t):v(e,t);return(0,Q.jsxs)(`div`,{className:`py-2.5`,"data-shortcut-action":e,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-5 gap-y-2`,children:[(0,Q.jsx)(`label`,{htmlFor:`shortcut-${e}`,className:`min-w-0 text-sm font-medium text-content`,children:a}),(0,Q.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1 max-[650px]:w-full`,children:[(0,Q.jsx)(H,{id:`shortcut-${e}`,"data-shortcut-recorder":!0,variant:`outline`,className:B(`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":l?.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,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t(`config:shortcuts.recording`)}):Ct(o)?(0,Q.jsx)(ut,{className:`min-w-0 flex-wrap justify-center`,children:Ct(o).split(` + `).map((e,t)=>(0,Q.jsx)(dt,{className:`text-content-secondary`,children:e},t))}):(0,Q.jsx)(`span`,{className:`text-content-muted`,children:t(`config:shortcuts.disabled`)})}),(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(Je,{asChild:!0,children:(0,Q.jsx)(H,{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,Q.jsx)(P,{className:`size-4`})})}),(0,Q.jsxs)(Ye,{align:`end`,className:`w-40`,onCloseAutoFocus:e=>{document.activeElement?.hasAttribute(`data-shortcut-recorder`)&&e.preventDefault()},children:[(0,Q.jsxs)(Ke,{disabled:o===null,onSelect:()=>f(null),children:[(0,Q.jsx)(Ce,{className:`size-4`}),t(`config:shortcuts.disableKey`)]}),(0,Q.jsxs)(Ke,{disabled:o===u,onSelect:()=>f(u),children:[(0,Q.jsx)(me,{className:`size-4`}),t(`config:shortcuts.resetAll`)]})]})]})]})]}),l?.action===e&&(0,Q.jsx)(`p`,{id:`shortcut-error-${e}`,role:`alert`,className:`mt-2 text-xs text-danger`,children:l.message})]},e)},C=e=>e.kind===`fixed`?(0,Q.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,Q.jsxs)(`span`,{className:`min-w-0 text-sm text-content-secondary`,children:[m.label(e),(0,Q.jsx)(`span`,{className:`ml-1.5 text-xs text-content-muted`,children:t(`board:shortcuts.fixed`)})]}),(0,Q.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1 max-[650px]:w-full`,children:[(0,Q.jsx)(jn,{keys:e.keys,className:`h-8 w-44 justify-center px-2.5 max-[650px]:flex-1`}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`size-7 flex-none pointer-coarse:size-11 max-[650px]:size-11`})]})]},An(e)):S(e.action);return(0,Q.jsxs)(`section`,{className:`w-full min-w-0`,"data-config-card":`shortcuts-bindings`,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-5`,children:kn.map((e,n)=>(0,Q.jsxs)(`section`,{"aria-labelledby":`shortcut-group-${e.id}`,"data-shortcut-group":e.id,children:[(0,Q.jsxs)(`div`,{className:`flex min-h-7 items-center justify-between gap-3`,children:[(0,Q.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,Q.jsxs)(H,{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,Q.jsx)(me,{className:`size-3.5`,"aria-hidden":`true`}),t(`config:shortcuts.resetAll`)]})]}),(0,Q.jsx)(`p`,{className:`mb-2 text-xs text-content-muted`,children:m.groups[e.id].hint}),(0,Q.jsx)(yi,{children:e.entries.map(C)})]},e.id))}),(0,Q.jsx)(`div`,{className:`mt-3 min-h-5 text-xs text-content-muted`,role:`status`,"aria-live":`polite`,children:l?.action===null?(0,Q.jsx)(`span`,{className:`text-destructive`,children:l.message}):t(f?`config:shortcuts.saved`:`config:shortcuts.deviceScope`)})]})}function va(e,t){let n=(0,Z.useRef)(t);n.current=t,(0,Z.useEffect)(()=>{if(e)return e(()=>n.current?.())},[e])}l.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.contextWindowEstimated":`没查到这个模型的上下文窗口,暂按默认值估算。请填写实际大小,否则可能过早压缩。`,"modelEditor.contextWindowEstimatedShort":`未查到窗口,按默认值估算`,"modelEditor.editNamed":`编辑模型 {name}`,"modelEditor.optionsNamed":`模型能力:{name}`,"modelEditor.delete":`删除模型`,"modelEditor.deleteNamed":`删除模型 {name}`,"modelEditor.deleteConfirmation":`删除“{name}”?供应商连接和密钥会保留。若它是默认模型,将选用其他可用模型,没有可用模型时清空默认值;已有会话的模型不会自动替换。之后可以重新添加此模型。`,"modelEditor.deleted":`模型已删除`}),l.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.contextWindowEstimated":`This model's context window could not be found, so a default estimate is used. Enter the real size, or the conversation may be compacted too early.`,"modelEditor.contextWindowEstimatedShort":`Window not found; using a default estimate`,"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 ya(e){let t=(0,Z.useContext)(Sn);return(0,Z.useLayoutEffect)(()=>{t?.update(e)}),(0,Z.useLayoutEffect)(()=>()=>t?.remove(e.id),[t,e.id]),{requestClose:(0,Z.useCallback)(n=>{t?t.requestClose(e.id,n):n()},[t,e.id])}}var ba=[[`openai-responses`,`OpenAI Responses`],[`openai-completions`,`OpenAI Chat Completions`],[`anthropic-messages`,`Anthropic Messages`],[`google-generative-ai`,`Google Generative AI`]],xa={"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 Sa(e){return!e||ba.some(([t])=>t===e)?ba:[...ba,[e,xa[e]||e]]}var Ca={openai:C,"openai-codex":C,anthropic:w,google:ye,deepseek:j,xai:ce,openrouter:se,"kimi-coding":ye,"zai-coding-cn":w},wa={saveFallbackModels(e){return p(`/api/config/fallback-models`,{method:`PUT`,body:JSON.stringify({models:e})})},saveAuxiliaryModel(e){return p(`/api/config/auxiliary-model`,{method:`PUT`,body:JSON.stringify({model:e})})},deleteModel(e,t){return p(`/api/providers/`+encodeURIComponent(e)+`/models`,{method:`DELETE`,body:JSON.stringify({modelId:t})})},saveModel(e,t,n=!1){return p(`/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 p(`/api/providers/`+encodeURIComponent(e)+`/connection`,{method:`PUT`,body:JSON.stringify(t)})},importLocal(){return p(`/api/providers/import-local`,{method:`POST`,body:`{}`})}};function Ta(e,t){return t.name!==e.name||t.api!==e.api||t.baseUrl!==(e.baseUrl||``)||!!t.apiKey}function Ea({provider:e,onSave:t,draft:n,onDraftChange:r,onSavingChange:i,children:a}){let{t:o}=u(),[s,c]=(0,Z.useState)(!1),[l,d]=(0,Z.useState)(``),f=(0,Z.useId)(),p=Ta(e,n),m=async a=>{if(a.preventDefault(),!s){c(!0),i(!0),d(``);try{t(await wa.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,Q.jsxs)(`form`,{onSubmit:e=>void m(e),"data-provider-connection-editor":!0,children:[(0,Q.jsxs)(`fieldset`,{disabled:s,className:`min-w-0 divide-y divide-stroke-soft`,children:[(0,Q.jsx)(bi,{label:o(`config:configPage.displayName`),htmlFor:`${f}-name`,children:(0,Q.jsx)(U,{id:`${f}-name`,required:!0,value:n.name,onChange:e=>r({...n,name:e.target.value})})}),(0,Q.jsx)(bi,{label:o(`config:configPage.apiKey`),htmlFor:`${f}-key`,children:(0,Q.jsx)(U,{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,Q.jsx)(bi,{label:o(`config:configPage.apiProtocol`),labelId:`${f}-api-label`,help:(0,Q.jsx)(`span`,{className:`font-mono`,children:n.api}),children:(0,Q.jsx)(Y,{"aria-labelledby":`${f}-api-label`,value:n.api,onChange:e=>r({...n,api:e.target.value}),children:Sa(n.api).map(([e,t])=>(0,Q.jsx)(`option`,{value:e,children:t},e))})}),(0,Q.jsx)(bi,{label:`Base URL`,htmlFor:`${f}-url`,children:(0,Q.jsx)(U,{id:`${f}-url`,required:!0,type:`url`,className:`font-mono`,value:n.baseUrl,onChange:e=>r({...n,baseUrl:e.target.value})})})]}),l&&(0,Q.jsx)(q,{className:`mt-2 mb-3`,children:l}),a,(0,Q.jsxs)(`div`,{className:B(`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,Q.jsx)(`span`,{role:`status`,className:`mr-auto text-xs text-content-muted`,children:o(`config:configPage.unsavedChanges`)}),(0,Q.jsx)(H,{type:`submit`,className:`max-[650px]:h-11`,disabled:!p,loading:s,children:o(s?`config:configPage.saving`:`config:configPage.saveChanges`)})]})]})}var Da=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function Oa({label:e,checked:t,disabled:n,onChange:r}){return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t,disabled:n,onClick:r,className:B(`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,Q.jsx)(`span`,{"aria-hidden":`true`,className:B(`grid size-3.5 place-items-center rounded-[3px] border border-control`,t&&`border-star bg-star text-on-accent`),children:t&&(0,Q.jsx)(T,{size:11})}),e]})}function ka({provider:e,model:t,onSave:n,onClose:r}){let{t:i}=u(),[a]=(0,Z.useState)(()=>t?.contextWindow||2e5),o=t?.contextWindowSource===`estimated`,[s,c]=(0,Z.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})),[l,d]=(0,Z.useState)(()=>({contextWindow:String(a),maxTokens:String(t?.maxTokens||8192)})),[f,p]=(0,Z.useState)(t?.thinkingLevels||[`off`,`low`,`medium`,`high`]),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(``),b=s.capabilities.includes(`chat`),x=async i=>{if(i.preventDefault(),!g){_(!0),y(``);try{n(await wa.saveModel(e.id,{...s,modelId:s.modelId.trim(),thinkingLevels:m?f:void 0,contextWindow:Number(l.contextWindow)===a?void 0:Number(l.contextWindow),maxTokens:Number(l.maxTokens)},!t)),r()}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(!1)}}};return(0,Q.jsx)(Mt,{open:!0,onOpenChange:e=>{!e&&!g&&r()},children:(0,Q.jsxs)(Ot,{className:`sm:max-w-[540px] p-5`,showCloseButton:!g,onEscapeKeyDown:e=>{g&&e.preventDefault()},onInteractOutside:e=>e.preventDefault(),children:[(0,Q.jsxs)(jt,{children:[(0,Q.jsx)(kt,{children:i(t?`providers:modelEditor.edit`:`providers:modelEditor.add`)}),(0,Q.jsxs)(Dt,{children:[e.name,` · `,i(`providers:modelEditor.description`)]})]}),(0,Q.jsxs)(`form`,{onSubmit:e=>void x(e),className:`space-y-5`,children:[(0,Q.jsxs)(`fieldset`,{disabled:g,className:`space-y-5`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(`providers:modelEditor.id`),(0,Q.jsx)(U,{required:!0,disabled:!!t,value:s.modelId,onChange:e=>c({...s,modelId:e.target.value})})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(`config:configPage.modelName`),(0,Q.jsx)(U,{value:s.name,onChange:e=>c({...s,name:e.target.value})})]})]}),(0,Q.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Q.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`providers:modelEditor.capabilities`)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`chat`,`image`,`video`].map(e=>(0,Q.jsx)(Oa,{label:i(e===`chat`?`providers:modelEditor.chat`:e===`image`?`providers:modelEditor.image`:`providers:modelEditor.video`),checked:s.capabilities.includes(e),onChange:()=>c({...s,capabilities:s.capabilities.includes(e)?s.capabilities.filter(t=>t!==e):[...s.capabilities,e]})},e))}),(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:i(`providers:modelEditor.capabilitiesHint`)})]}),b&&(0,Q.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Q.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`providers:modelEditor.chatCapabilities`)}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(Oa,{label:i(`providers:modelEditor.vision`),checked:s.input.includes(`image`),onChange:()=>c({...s,input:s.input.includes(`image`)?[`text`]:[`text`,`image`]})}),(0,Q.jsx)(Oa,{label:i(`providers:modelEditor.reasoning`),checked:s.reasoning,onChange:()=>c({...s,reasoning:!s.reasoning})})]})]}),b&&s.reasoning&&(0,Q.jsxs)(`fieldset`,{children:[(0,Q.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`config:configPage.modelThinkingLevels`)}),!t&&!m&&(0,Q.jsx)(`p`,{className:`mb-2 text-xs text-content-muted`,children:i(`config:configPage.modelThinkingLevelsAutoHint`)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Da.map(e=>(0,Q.jsx)(Oa,{label:e,checked:e===`off`||f.includes(e),disabled:e===`off`,onChange:()=>{h(!0),p(f.includes(e)?f.filter(t=>t!==e):[...f,e])}},e))})]}),b&&(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[`contextWindow`,`maxTokens`].map(e=>(0,Q.jsxs)(`div`,{className:`grid content-start gap-1.5 text-sm`,children:[(0,Q.jsxs)(`label`,{className:`grid gap-1.5`,children:[i(e===`contextWindow`?`providers:modelEditor.contextWindow`:`providers:modelEditor.maxTokens`),(0,Q.jsx)(U,{required:!0,type:`number`,min:1,max:1e8,step:1,value:l[e],"aria-describedby":e===`contextWindow`&&o?`model-context-window-estimated`:void 0,onChange:t=>d({...l,[e]:t.target.value})})]}),e===`contextWindow`&&o&&(0,Q.jsx)(`small`,{id:`model-context-window-estimated`,className:`text-xs text-content-muted`,children:i(`providers:modelEditor.contextWindowEstimated`)})]},e))})]}),v&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:v}),(0,Q.jsxs)(At,{children:[(0,Q.jsx)(H,{type:`button`,variant:`ghost`,disabled:g,onClick:r,children:i(`config:configPage.cancel`)}),(0,Q.jsxs)(H,{type:`submit`,disabled:g||!s.capabilities.length||!s.modelId.trim(),children:[g&&(0,Q.jsx)(ie,{className:`animate-spin`,size:14}),` `,i(g?`config:configPage.saving`:`config:configPage.saveChanges`)]})]})]})]})})}function Aa(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 ja(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 Ma(e){return e?e>=1e6?`${Number((e/1e6).toFixed(2))}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e):`—`}function Na({model:e}){let{t}=u();if(e.contextWindowSource!==`estimated`)return(0,Q.jsx)(Q.Fragment,{children:Ma(e.contextWindow)});let n=t(`providers:modelEditor.contextWindowEstimatedShort`);return(0,Q.jsxs)(`span`,{className:`text-warning-strong`,title:n,"data-context-window-estimated":!0,children:[`≈`,Ma(e.contextWindow),(0,Q.jsxs)(`span`,{className:`sr-only`,children:[` `,n]})]})}function Pa(e){return Sa(e).find(([t])=>t===e)?.[1]||e}var Fa=`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 Ia(e){let{t}=u(),n=(0,Z.useId)(),{providers:r,defaultId:i}=Aa(e.config,e.selectedProviderId),a=r.find(t=>t.id===e.selectedProviderId),[o,s]=(0,Z.useState)({}),[c,l]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),p=!!(c||e.settingDefault||e.settingModel||e.toggling||e.deletingModel);ya({id:`provider-drafts-${n}`,dirty:r.some(e=>!!(o[e.id]&&Ta(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`,z,t.includes(`chat`)],[`image`,te,t.includes(`image`)],[`video`,oe,t.includes(`video`)],[`reasoning`,w,!!e.reasoning&&t.includes(`chat`)]].filter(([,,e])=>e).map(([e,t])=>(0,Q.jsxs)(`span`,{title:m[e],className:`inline-flex`,children:[(0,Q.jsx)(t,{size:13,"aria-hidden":`true`}),(0,Q.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,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,Q.jsx)(T,{className:`size-3.5`,"aria-hidden":`true`}),t(`config:providerWorkbench.connected`)]}):t(`config:configPage.disabled2`):t(`config:providerWorkbench.notConnected`),v=n=>(0,Q.jsxs)(`div`,{className:`@container/card min-w-0`,"data-provider-detail":n.id,children:[(0,Q.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,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-content-muted`,children:n.id}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-sm text-content-secondary`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:t(`config:configPage.enabled`)}),(0,Q.jsx)(vi,{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,Q.jsxs)(Xe,{children:[(0,Q.jsx)(Je,{asChild:!0,children:(0,Q.jsx)(H,{variant:`ghost`,size:`icon-sm`,className:`pointer-coarse:size-11 max-[650px]:size-11`,"aria-label":t(`config:providerWorkbench.actions`),children:(0,Q.jsx)(P,{size:16})})}),(0,Q.jsxs)(Ye,{align:`end`,children:[(0,Q.jsxs)(Ke,{disabled:n.id===i||!n.configured||!n.enabled||!n.defaultModel||p,onSelect:()=>void e.onSetDefault(n),children:[(0,Q.jsx)(Jn,{size:14}),t(`config:configPage.setAsDefaultProvider`)]}),(0,Q.jsxs)(Ke,{disabled:p,onSelect:()=>e.onClone(n),children:[(0,Q.jsx)(M,{size:14}),t(`config:configPage.cloneProvider`)]}),n.custom&&(0,Q.jsxs)(Ke,{className:`text-destructive`,disabled:p,onSelect:()=>void e.onDelete(n),children:[(0,Q.jsx)(be,{size:14}),t(`config:configPage.deleteProvider`)]})]})]})]}),(0,Q.jsxs)(Ea,{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:l,onSave:e.onSave,children:[(0,Q.jsxs)(`div`,{className:`mt-2 flex min-h-10 items-center gap-2 border-t border-stroke-soft pt-2`,children:[(0,Q.jsxs)(`h3`,{className:`text-[13px] font-medium text-content-muted`,children:[t(`config:providerWorkbench.models`),(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,n.models.length]})]}),(0,Q.jsxs)(H,{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,Q.jsx)(de,{size:14}),t(`providers:modelEditor.add`)]})]}),n.models.length>0&&(0,Q.jsxs)(`div`,{className:B(Fa,`hidden h-8 text-xs font-medium text-content-muted @min-[560px]/card:grid`),children:[(0,Q.jsx)(`span`,{children:t(`providers:modelEditor.id`)}),(0,Q.jsx)(`span`,{children:t(`config:configPage.displayName`)}),(0,Q.jsx)(`span`,{className:`text-right`,children:t(`config:providerWorkbench.contextColumn`)}),(0,Q.jsx)(`span`,{children:t(`providers:modelEditor.capabilities`)}),(0,Q.jsx)(`span`,{"aria-hidden":`true`})]}),n.models.map(r=>{let i=n.defaultModel===r.id;return(0,Q.jsxs)(`div`,{"data-provider-model":r.id,className:B(Fa,`min-h-11.5 border-t border-stroke-soft py-px text-sm text-content-secondary`),children:[(0,Q.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,Q.jsx)(`span`,{className:`block truncate font-mono text-[12.5px] text-content`,children:r.id}),(0,Q.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,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:r.name||r.id}),(0,Q.jsx)(`span`,{className:`tabular-nums`,children:(0,Q.jsx)(Na,{model:r})}),h(r)]})]}),(0,Q.jsx)(`span`,{className:`hidden min-w-0 truncate text-content @min-[560px]/card:block`,children:r.name||r.id}),(0,Q.jsx)(`span`,{className:`hidden text-right tabular-nums @min-[560px]/card:block`,children:(0,Q.jsx)(Na,{model:r})}),(0,Q.jsx)(`span`,{className:`hidden items-center gap-2 text-content-muted @min-[560px]/card:flex`,children:h(r)}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[r.kind===`chat`&&(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-sm`,className:B(`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,Q.jsx)(Jn,{size:15,className:B(i&&`fill-current`)})}),(0,Q.jsx)(H,{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,Q.jsx)(ve,{size:14})}),(0,Q.jsx)(H,{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,Q.jsx)(be,{size:14})})]})]},r.id)})]},n.id)]});return(0,Q.jsxs)(K,{"data-config-card":`models-connections`,"data-model-provider-list":!0,title:t(`config:providerWorkbench.providers`),count:r.length,meta:e.meta,children:[r.length>0?(0,Q.jsx)(G,{children:r.map(n=>{let r=n.id===i,o=a?.id===n.id;return(0,Q.jsx)(W,{"data-provider-row":n.id,icon:(0,Q.jsx)(`span`,{className:`text-[13px] font-semibold text-content-secondary`,children:ja(n.name)}),name:n.name,description:[...n.configured?[]:[g(n)],t(`config:configPage.countModels`,{count:n.models.length}),Pa(n.api)].join(` · `),status:(0,Q.jsxs)(Q.Fragment,{children:[r&&(0,Q.jsx)($t,{variant:`outline`,"data-provider-default":!0,className:`mr-2`,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,Q.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,Q.jsx)(Wt,{size:40,className:`mb-1`}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-content`,children:t(`config:providerWorkbench.noConnections`)}),(0,Q.jsx)(`p`,{className:`max-w-sm text-xs text-content-muted`,children:t(`config:providerWorkbench.addConnectionHint`)})]}),e.onAddConnection&&(0,Q.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,Q.jsx)(de,{size:16,"aria-hidden":`true`,className:`flex-none text-content-muted`}),(0,Q.jsx)(`span`,{className:`flex-none`,children:t(`config:providerWorkbench.addProvider`)}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:t(`config:providerWorkbench.addProviderHint`)})]}),d&&(0,Q.jsx)(ka,{provider:d.provider,model:d.model,onSave:e.onSave,onClose:()=>f(null)})]})}function La(){let e=globalThis.crypto.getRandomValues(new Uint32Array(4));return`custom-${Array.from(e,e=>e.toString(16).padStart(8,`0`)).join(``)}`}function Ra({value:e,onChange:t,configured:n=!1,cloning:r=!1}){let{t:i}=u();return(0,Q.jsxs)(J,{variant:`control`,children:[i(`config:configPage.apiKey`),(0,Q.jsx)(U,{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 za({ids:e,onChange:t,placeholder:n,primaryId:r=``}){let{t:i}=u(),[a,o]=(0,Z.useState)(``),s=()=>{let n=a.trim();!n||n===r.trim()||e.includes(n)||(t([...e,n]),o(``))};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(J,{variant:`control`,children:[i(`config:configPage.manualModelIds`),(0,Q.jsxs)(`div`,{className:`flex items-stretch gap-1.5`,children:[(0,Q.jsx)(U,{"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,Q.jsx)(H,{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,Q.jsx)(de,{size:14})})]})]}),e.length>0&&(0,Q.jsx)(`div`,{className:`flex flex-col overflow-hidden rounded-md border border-stroke`,children:e.map(n=>(0,Q.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,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12.5px] text-content`,children:n}),(0,Q.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,Q.jsx)(Ce,{size:12})})]},n))}),(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`config:configPage.manualModelIdsHint`)})]})}function Ba(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 Va({onClose:e,onCreated:t,onConfigChanged:n,initialProviderType:r=`chat`,initialProvider:i,cloneProvider:a,embedded:o=!1}){let{t:s}=u(),c=i||a,l=!!a,d=c?.type||r,f=Ba(c,d),[m,h]=(0,Z.useState)(``),g=!!(i||m),[_,v]=(0,Z.useState)(()=>({name:a?s(`config:configPage.clonedProviderName`,{name:a.name}):i?.name||``,id:a?La():i?.id||``,providerType:d,api:i?.api||`openai-responses`,baseUrl:i?.baseUrl||``,model:f?.id||``,modelName:f?.name||``,modelKind:f?.kind===`image`||f?.kind===`video`?f.kind:d===`visual`?`image`:`chat`,reasoning:f?.reasoning!==!1,thinkingLevels:f?.thinkingLevels||[],enabled:i?.enabled??!0})),y=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],[b,x]=(0,Z.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,Z.useState)(!1),[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(``),A=O.trim()||void 0,[j,M]=(0,Z.useState)([]),N=e=>v(t=>({...t,name:e,id:t.id||e.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)}));return(0,Z.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,Q.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,Q.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(!l&&!A&&!i?.configured&&!m){D(s(`config:configPage.enterTheAPIKeyForThisConnection`));return}w(!0),D(``);try{if(a){t(await p(`/api/providers/${encodeURIComponent(a.id)}/clone`,{method:`POST`,body:JSON.stringify({name:_.name,id:_.id,apiKey:A})}));return}let e=g?await p(`/api/config`,{method:`PUT`,body:JSON.stringify({..._,apiKey:A,thinkingLevels:b?_.thinkingLevels:void 0,provider:m||_.id,providerName:_.name,setAsDefault:!1})}):await p(`/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 p(`/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,Q.jsxs)(rn,{children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{children:s(l?`config:configPage.cloneProvider`:g?`config:configPage.editProviderConnection`:`config:configPage.addProviderConnection`)}),!l&&(0,Q.jsx)(`p`,{children:s(g?`config:configPage.updateProviderKeyURLAndModelSettings`:`config:configPage.youCanCreateMultipleConnectionsUsingTheSameProtocolEachWithItsOwnKeyAndBaseURL`)})]}),(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`config:configPage.closeDialog`),disabled:C,onClick:t=>{t.preventDefault(),t.stopPropagation(),e()},children:(0,Q.jsx)(Ce,{size:17})})]}),(0,Q.jsxs)(`div`,{className:`form-grid grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(J,{variant:`control`,children:[s(`config:configPage.displayName`),(0,Q.jsx)(U,{value:_.name,onChange:e=>N(e.target.value),placeholder:s(`config:configPage.forExampleOpenAIOfficial`)})]}),(0,Q.jsxs)(J,{variant:`control`,children:[`Provider ID`,(0,Q.jsx)(U,{value:_.id,disabled:g,onChange:e=>v({..._,id:e.target.value}),placeholder:`openai-official`})]})]}),(0,Q.jsx)(Ra,{value:O,onChange:k,configured:i?.configured,cloning:l}),!l&&(0,Q.jsxs)(Q.Fragment,{children:[!o&&(0,Q.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,Q.jsx)(`span`,{className:`text-xs text-content-muted`,children:s(`config:configPage.providerPurpose`)}),(0,Q.jsx)(`strong`,{className:`font-mono text-xs font-medium`,children:_.providerType===`visual`?s(`config:configPage.visualProvider`):s(`config:configPage.chatProvider`)})]}),(0,Q.jsxs)(J,{variant:`control`,children:[s(`config:configPage.apiProtocol`),(0,Q.jsx)(Y,{value:_.api,onChange:e=>v({..._,api:e.target.value}),children:ba.map(([e,t])=>(0,Q.jsx)(`option`,{value:e,children:t},e))})]}),(0,Q.jsxs)(J,{variant:`control`,children:[`Base URL`,(0,Q.jsx)(U,{value:_.baseUrl,onChange:e=>v({..._,baseUrl:e.target.value}),placeholder:`https://api.openai.com/v1`})]}),(0,Q.jsxs)(`div`,{className:`form-grid grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(J,{variant:`control`,children:[s(g?`config:configPage.providerDefaultModel`:`config:configPage.initialModelID`),(0,Q.jsx)(U,{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,Q.jsxs)(J,{variant:`control`,children:[s(`config:configPage.modelName`),(0,Q.jsx)(U,{value:_.modelName,onChange:e=>v({..._,modelName:e.target.value}),placeholder:s(`config:configPage.leaveBlankToUseTheModelID`)})]})]}),(0,Q.jsxs)(`details`,{open:!o||void 0,className:`group rounded-lg border border-border px-3 py-2 [&[open]]:space-y-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-[13px] text-muted-foreground`,children:s(`config:providerWorkbench.modelOptions`)}),(0,Q.jsxs)(J,{variant:`control`,children:[s(`config:configPage.modelType`),(0,Q.jsxs)(Y,{value:_.modelKind,onChange:e=>v({..._,modelKind:e.target.value,providerType:e.target.value===`chat`?`chat`:`visual`}),children:[(0,Q.jsx)(`option`,{value:`chat`,children:s(`providers:modelEditor.chat`)}),(0,Q.jsx)(`option`,{value:`image`,children:s(`providers:modelEditor.image`)}),(0,Q.jsx)(`option`,{value:`video`,children:s(`providers:modelEditor.video`)})]})]}),(0,Q.jsx)(`div`,{className:`grid gap-[9px]`,children:(0,Q.jsx)(za,{ids:j,onChange:M,primaryId:_.model,placeholder:_.providerType===`visual`?`gpt-image-1`:`gpt-5.5`})}),_.modelKind===`chat`&&(0,Q.jsxs)(J,{variant:`control`,children:[s(`config:configPage.modelThinkingLevels`),(0,Q.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,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r,onClick:()=>!t&&S(e),className:B(`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,Q.jsx)(T,{size:12}),e]},e)})}),(0,Q.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:s(`config:configPage.modelThinkingLevelsHint`)})]})]}),!o&&(0,Q.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,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Q.jsx)(`strong`,{className:`text-[13px]`,children:g?s(`config:configPage.providerEnabled`,{name:_.name}):s(`config:configPage.enableAfterCreation`)}),_.providerType===`visual`&&(0,Q.jsx)(`small`,{className:`text-[13px] text-muted-foreground`,children:s(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]}),(0,Q.jsx)(vi,{value:_.enabled,onChange:e=>v({..._,enabled:e})})]})]}),E&&(0,Q.jsxs)(tn,{children:[(0,Q.jsx)(xe,{size:13}),E]}),(0,Q.jsxs)(`div`,{className:`mt-[18px] flex justify-end gap-2`,children:[(0,Q.jsx)(H,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:C,onClick:e,children:s(`config:configPage.cancel`)}),(0,Q.jsxs)(H,{type:`submit`,className:`max-[650px]:h-11`,disabled:C,children:[C?(0,Q.jsx)(V,{className:`text-current`}):g?(0,Q.jsx)(T,{size:14}):(0,Q.jsx)(de,{size:14}),s(C?`config:configPage.saving`:l?`config:configPage.cloneProvider`:g?`config:configPage.saveChanges`:`config:configPage.createConnection`)]})]})]})})}function Ha(e){return(e.providers||[]).filter(e=>e.importable&&!e.imported&&!e.conflict).length}function Ua(e){return Ha(e)>0}function Wa(e,t){return!t&&!Ua(e)}function Ga(e,t,n){let r=e.providers||[],i=e.errors||[],a=Ua(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 Ka(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 qa(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 Ja(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 Ya({discovery:e,discovering:t,error:n,importing:r,forceVisible:i=!1,onRefresh:a,onImport:o}){let{t:s}=u(),[c,l]=(0,Z.useState)(null),d=e.providers||[],f=e.errors||[];if(!i&&!Ga(e,t,n))return null;let p=c??(!i&&Wa(e,t)),m=()=>(l(null),a()),h=e=>(l(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,Q.jsxs)(hi,{className:`mb-3 py-3.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2.5 max-[650px]:flex-wrap`,children:[(0,Q.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:()=>l(!p),children:[(0,Q.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,Q.jsx)(ge,{size:18})}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-content`,children:s(`config:configPage.localProviderConfiguration`)}),(0,Q.jsx)(`span`,{className:`text-xs leading-[1.45] text-content-muted`,children:s(`config:configPage.readProviderEndpointModelAndAuthenticationFieldsFromCodexConfigTomlAndClaudeSettingsJson`)})]}),(0,Q.jsx)(E,{size:16,"aria-hidden":`true`,className:B(`flex-none text-content-muted transition-transform`,!p&&`rotate-180`)})]}),(0,Q.jsxs)(H,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:t||!!r,onClick:m,children:[t?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(fe,{size:13}),s(`config:configPage.rescan`)]})]}),!p&&(0,Q.jsxs)(Q.Fragment,{children:[t&&!d.length?(0,Q.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,Q.jsx)(V,{}),s(`config:configPage.scanningProviderConfigurationFiles`)]}):d.length?(0,Q.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 max-[650px]:grid-cols-1`,children:d.map(e=>{let t=Ka(e),n=r===e.id,i=e.source.startsWith(`claude-`)?w:C,a=e.kind===`authentication`?s(`config:configPage.officialProviderAuthenticationOnly`):e.models?.length?e.models.map(e=>e.id).join(`, `):s(`config:configPage.noModelSpecified`);return(0,Q.jsxs)(`div`,{className:B(`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,Q.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,Q.jsx)(i,{size:15})}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Q.jsxs)(`span`,{className:`truncate text-sm font-medium text-content`,children:[t,` · `,e.providerName]}),(0,Q.jsxs)(`span`,{className:`truncate font-mono text-xs text-content-muted`,children:[e.api,` · `,a]}),(0,Q.jsxs)(`span`,{className:`truncate text-xs text-content-muted`,children:[e.kind===`authentication`?s(`config:configPage.officialEndpointOnly`):e.baseUrl||s(`config:configPage.noBaseURLSpecified`),` `,`· `,qa(e,s),` · `,e.location]})]}),(0,Q.jsx)(`span`,{className:`flex min-w-0 flex-none items-center max-[650px]:col-start-2`,children:e.imported?(0,Q.jsx)(_i,{tone:`green`,children:s(`config:configPage.loaded`)}):e.conflict?(0,Q.jsx)(_i,{tone:`amber`,children:s(`config:configPage.conflictDetected`)}):e.importable?(0,Q.jsxs)(H,{type:`button`,size:`sm`,className:`pointer-coarse:h-11`,disabled:n||!!r,onClick:()=>h(e),children:[n?(0,Q.jsx)(V,{className:`size-3 text-current`}):(0,Q.jsx)(N,{size:12}),n?s(`config:configPage.loading`):e.kind===`authentication`?s(`config:configPage.loadLoginState`):s(`config:configPage.loadConfiguration`)]}):(0,Q.jsx)(_i,{tone:`gray`,children:s(`config:configPage.cannotLoad`)})})]},e.id)})}):(0,Q.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,Q.jsx)(ge,{size:15,"aria-hidden":`true`}),s(`config:configPage.noImportableCodexOrClaudeProviderConfigurationWasDetected`)]}),(n||f.length>0||d.some(e=>e.warnings?.some(e=>e.code!==`login_auth_not_imported`)))&&(0,Q.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,Q.jsxs)(`span`,{children:[(0,Q.jsx)(xe,{size:13}),n]}),f.map((e,t)=>(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(xe,{size:13}),Ka(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,Q.jsxs)(`span`,{children:[(0,Q.jsx)(xe,{size:13}),Ka(e),` · `,Ja(t.code,s)]},`${e.id}-${t.code}-${n}`)))]})]})]})}function Xa(e){try{return{name:new URL(e).hostname.replace(/^www\./i,``)||`Custom Provider`}}catch{return{name:`Custom Provider`}}}function Za({config:e,providerType:t=`chat`,initialProviderId:n,onClose:r,onConfigChanged:i,onCompleted:a}){let{t:o}=u(),s=n&&e.providers.find(e=>e.id===n)||null,[c,l]=(0,Z.useState)(1),[d,f]=(0,Z.useState)(s),[m]=(0,Z.useState)(La),[h,g]=(0,Z.useState)(``),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),[x,S]=(0,Z.useState)(s?.baseUrl||``),[C,w]=(0,Z.useState)(s?.api||`openai-responses`),[E,D]=(0,Z.useState)(``),O=E.trim()||void 0,[k,A]=(0,Z.useState)(s?.organization||``),[j,M]=(0,Z.useState)(s?.name||``),[N,P]=(0,Z.useState)(s?.models||[]),[F,I]=(0,Z.useState)(s?.defaultModel||``),[L,ee]=(0,Z.useState)([]),[te,ne]=(0,Z.useState)(s?.models.find(e=>e.id===s.defaultModel)?.kind||(t===`visual`?`image`:`chat`)),[R,re]=(0,Z.useState)(!1),[ie,z]=(0,Z.useState)(``),[ae,oe]=(0,Z.useState)(``),se=Xa(x),ce=o(t===`visual`?`config:configPage.visualProvider`:`config:configPage.chatProvider`),le=o(c===1?`config:configPage.quickSetupStepBaseUrl`:c===2?`config:configPage.quickSetupStepProtocol`:`config:configPage.quickSetupStepModel`),ue=N.filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`),de=()=>{let e=x.trim();try{let t=new URL(e);if(![`http:`,`https:`].includes(t.protocol))throw Error()}catch{z(o(`config:configPage.providerBaseURLMustBeHTTPOrHTTPS`));return}z(``),j.trim()||M(se.name),l(2)},pe=()=>{if(!C){z(o(`config:configPage.selectAPIProtocol`));return}z(``),l(3)},me=async()=>{if(R)return;let e=d;if(!O&&!e?.configured&&!h){z(o(`config:configPage.enterTheAPIKeyForThisConnection`));return}re(!0),z(``),oe(``);try{let n=((await p(`/api/providers/models/discover-connection`,{method:`POST`,body:JSON.stringify({providerId:e?.id||h,providerType:t,api:C,baseUrl:x,organization:k,apiKey:O})})).models||[]).filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`);if(!n.length){z(o(t===`visual`?`config:configPage.fetchOrAddAVisualModel`:`config:configPage.fetchOrAddAChatModel`));return}P(n);let r=n.find(e=>e.id===F)||n[0];I(r.id),ne(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];I(e.id),ne(t===`visual`?e.kind:`chat`),oe(r)}else z(r)}finally{re(!1)}},he=async()=>{if(R)return;let e=F.trim()||L[0]||``;if(!e){z(o(`config:configPage.selectModelToFinish`));return}if(!O&&!d?.configured&&!h){z(o(`config:configPage.enterTheAPIKeyForThisConnection`));return}let n=new Set((d?.models||[]).map(e=>e.id)),r=L.filter(t=>t!==e&&!n.has(t));re(!0),z(``);try{let n=d?.id||h,o=n?await p(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:n,providerType:t,api:C,baseUrl:x,organization:k,model:e,modelKind:t===`visual`?te:`chat`,apiKey:O,setAsDefault:!1,enabled:!0})}):await p(`/api/providers`,{method:`POST`,body:JSON.stringify({id:m,name:j.trim()||se.name,providerType:t,api:C,baseUrl:x,organization:k,apiKey:O,model:e,modelKind:t===`visual`?te:`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&&f(u),i?.(l?{...o,createdProviderId:l}:o),r.length){let e=t===`visual`?te:`chat`;try{o=await p(`/api/providers/${encodeURIComponent(c)}/models/batch`,{method:`POST`,body:JSON.stringify({models:r.map(t=>({id:t,kind:e}))})})}catch(e){z(e instanceof Error?e.message:String(e));return}}a(l?{...o,createdProviderId:l}:o)}catch(e){z(e instanceof Error?e.message:String(e))}finally{re(!1)}};return(0,Q.jsx)(Mt,{open:!0,onOpenChange:e=>{!e&&!R&&r()},children:(0,Q.jsxs)(Ot,{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":R,onEscapeKeyDown:e=>{R&&e.preventDefault()},onInteractOutside:e=>{R&&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,Q.jsxs)(rn,{children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(kt,{asChild:!0,children:(0,Q.jsx)(`h2`,{children:o(t===`visual`?`config:configPage.visualQuickSetupTitle`:`config:configPage.quickSetupTitle`)})}),(0,Q.jsx)(Dt,{asChild:!0,children:(0,Q.jsxs)(`p`,{children:[o(`config:configPage.stepIndicator`,{current:c,total:3}),` · `,le]})})]}),(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`pointer-coarse:size-11`,"aria-label":o(`config:configPage.closeDialog`),disabled:R,onClick:r,children:(0,Q.jsx)(Ce,{size:17})})]}),(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`mt-3 grid grid-cols-3 gap-1`,children:[1,2,3].map(e=>(0,Q.jsx)(`span`,{className:B(`h-1 rounded-full`,e<=c?`bg-star`:`bg-surface-active`)},e))}),(0,Q.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,Q.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,Q.jsx)(ge,{size:15,"aria-hidden":`true`})}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-content`,children:j||se.name}),(0,Q.jsx)(`small`,{className:`text-xs text-content-muted`,children:ce})]}),(0,Q.jsx)(_i,{tone:`gray`,children:ce})]}),c===1&&(0,Q.jsxs)(`div`,{className:`[margin-top:14px]`,children:[(0,Q.jsxs)(J,{variant:`control`,children:[`Base URL`,(0,Q.jsx)(U,{ref:v,value:x,onChange:e=>S(e.target.value),placeholder:`https://api.example.com/v1`,inputMode:`url`})]}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs leading-[1.5] text-content-muted`,children:o(`config:configPage.quickSetupBaseUrlHint`)})]}),c===2&&(0,Q.jsxs)(`div`,{className:`[margin-top:14px]`,children:[(0,Q.jsxs)(J,{variant:`control`,children:[o(`config:configPage.apiProtocol`),(0,Q.jsx)(Y,{value:C,onChange:e=>w(e.target.value),children:ba.map(([e,t])=>(0,Q.jsx)(`option`,{value:e,children:t},e))})]}),(0,Q.jsxs)(J,{variant:`control`,children:[`Organization`,(0,Q.jsx)(U,{value:k,onChange:e=>A(e.target.value),placeholder:o(`config:configPage.optionalUsedOnlyForOpenAIOrganization`)})]})]}),c===3&&(0,Q.jsxs)(`div`,{className:`[margin-top:14px]`,children:[!d&&(0,Q.jsxs)(J,{variant:`control`,children:[o(`config:configPage.displayName`),(0,Q.jsx)(U,{value:j,onChange:e=>M(e.target.value),placeholder:se.name})]}),(0,Q.jsx)(Ra,{value:E,onChange:D,configured:d?.configured}),(0,Q.jsxs)(H,{type:`button`,variant:`secondary`,className:`mt-2.5 w-full max-[650px]:h-11`,disabled:R,onClick:()=>void me(),children:[R?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(fe,{size:14}),o(R?`config:configPage.fetchingModels`:`config:configPage.fetchModels`)]}),ae&&(0,Q.jsxs)(en,{className:`[margin-top:10px]`,children:[(0,Q.jsx)(xe,{size:15}),(0,Q.jsx)(`small`,{children:o(`config:configPage.discoverFailedUsingExisting`,{message:ae})})]}),ue.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.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,Q.jsx)(`div`,{className:`flex max-h-[260px] flex-col overflow-y-auto rounded-md border border-stroke`,children:ue.map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:B(`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:()=>{I(e.id),ne(t===`visual`?e.kind:`chat`)},children:[(0,Q.jsx)(`span`,{className:B(`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,Q.jsx)(T,{size:11})}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-content`,children:e.name}),t===`visual`&&(0,Q.jsx)(_i,{tone:`gray`,children:e.kind===`video`?o(`config:configPage.visualVideoModel`):o(`config:configPage.visualImageModel`)})]},`${e.id}-${e.kind}`))})]}),(0,Q.jsxs)(`div`,{className:`mt-3.5 grid gap-2`,children:[(0,Q.jsxs)(J,{variant:`control`,children:[o(`config:configPage.manualModelId`),(0,Q.jsx)(U,{value:F,onChange:e=>I(e.target.value),placeholder:t===`visual`?`gpt-image-1`:`gpt-5.4`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:o(`config:configPage.manualModelIdHint`)}),t===`visual`&&(0,Q.jsxs)(J,{variant:`control`,children:[o(`config:configPage.modelType`),(0,Q.jsxs)(Y,{value:te,onChange:e=>ne(e.target.value),children:[(0,Q.jsx)(`option`,{value:`image`,children:o(`config:configPage.imageGenerationAndEditing`)}),(0,Q.jsx)(`option`,{value:`video`,children:o(`config:configPage.videoGeneration`)})]})]}),(0,Q.jsx)(za,{ids:L,onChange:ee,primaryId:F,placeholder:t===`visual`?`gpt-image-1`:`gpt-5.5`})]})]}),ie&&(0,Q.jsxs)(tn,{children:[(0,Q.jsx)(xe,{size:13}),ie]}),(0,Q.jsxs)(`div`,{className:`mt-[18px] flex justify-between gap-2`,children:[(0,Q.jsxs)(H,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:R||c===1,onClick:()=>{z(``),l(c-1)},children:[(0,Q.jsx)(y,{size:14}),o(`config:configPage.previousStep`)]}),c===1?(0,Q.jsxs)(H,{type:`button`,className:`max-[650px]:h-11`,disabled:R||!x.trim(),onClick:de,children:[(0,Q.jsx)(b,{size:14}),o(`config:configPage.nextStep`)]}):c===2?(0,Q.jsxs)(H,{type:`button`,className:`max-[650px]:h-11`,disabled:R,onClick:pe,children:[(0,Q.jsx)(b,{size:14}),o(`config:configPage.nextStep`)]}):(0,Q.jsxs)(H,{type:`button`,className:`max-[650px]:h-11`,disabled:R||!F.trim()&&L.length===0,onClick:()=>void he(),children:[R?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(T,{size:14}),o(R?`config:configPage.saving`:`config:configPage.saveChanges`)]})]})]})})}var Qa=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],$a=``;function eo(e){return`${e.provider.id}/${e.model.id}`}function to({labelId:e,label:t,hint:n,children:r}){return(0,Q.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,280px)] items-center gap-x-6 gap-y-0.5 border-b border-stroke py-4 max-[650px]:grid-cols-[auto_minmax(0,1fr)] max-[650px]:gap-x-3 max-[650px]:gap-y-1 max-[650px]:py-3`,children:[(0,Q.jsx)(`div`,{id:e,className:`self-end text-sm font-medium text-content max-[650px]:self-center`,children:t}),(0,Q.jsx)(`div`,{className:`row-span-2 min-w-0 max-[650px]:row-span-1`,children:r}),(0,Q.jsx)(`p`,{id:`${e}-hint`,className:`col-start-1 self-start text-xs text-content-muted max-[650px]:col-span-2`,children:n})]})}function no({config:e,notify:t,busy:n,onConfigChanged:r,onSetDefaultModel:i}){let{t:a}=u(),o=(0,Z.useId)(),s={off:a(`chat:focusSession.thinkingLabel.off`),minimal:a(`chat:focusSession.thinkingLabel.minimal`),low:a(`chat:focusSession.thinkingLabel.low`),medium:a(`chat:focusSession.thinkingLabel.medium`),high:a(`chat:focusSession.thinkingLabel.high`),xhigh:a(`chat:focusSession.thinkingLabel.xhigh`),max:a(`chat:focusSession.thinkingLabel.max`)},[c,l]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(e.thinkingLevel),[g,_]=(0,Z.useState)(e.toolMode);(0,Z.useEffect)(()=>{h(e.thinkingLevel),_(e.toolMode)},[e.thinkingLevel,e.toolMode]);let v=(e.fallbackModels||[]).join(`
|
|
4
4
|
`),[y,b]=(0,Z.useState)(e.fallbackModels||[]);(0,Z.useEffect)(()=>{b(v?v.split(`
|
|
5
5
|
`):[])},[v]);let[x,S]=(0,Z.useState)(e.auxiliaryModel||``);(0,Z.useEffect)(()=>{S(e.auxiliaryModel||``)},[e.auxiliaryModel]);let C=e.defaultProvider||e.provider,w=e.defaultModel||e.model,T=e.providers.find(e=>e.id===C),E=T?.models.find(e=>e.id===w)?.thinkingLevels,D=Qa.filter(e=>!E?.length||E.includes(e)||e===m),O=e=>E?.length&&!E.includes(e)?a(`config:providerWorkbench.thinkingUnsupportedByModel`,{level:s[e]}):s[e],k=!!(T?.configured&&w),A=e.providers.filter(e=>e.type===`chat`&&e.configured&&e.enabled),j=A.flatMap(e=>e.models.filter(e=>e.kind===`chat`).map(t=>({provider:e,model:t,value:`${e.id}${$a}${t.id}`}))),M=T&&w?`${T.id}${$a}${w}`:``,N=async n=>{if(!(!T||!w)){l(!0),f(``);try{r(await p(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:T.id,providerType:T.type,api:T.api,baseUrl:T.baseUrl||``,organization:T.organization||``,model:w,thinkingLevel:n.thinkingLevel??e.thinkingLevel,toolMode:n.toolMode??e.toolMode,setAsDefault:!1})})),t(a(`config:configPage.runtimePolicySaved`))}catch(t){h(e.thinkingLevel),_(e.toolMode),f(t instanceof Error?t.message:String(t))}finally{l(!1)}}},P=!k||c||n,F=async(e,n)=>{let i=[...y];i[e]=n;let o=i.filter((e,t)=>e&&i.indexOf(e)===t),s=y;b(o),l(!0),f(``);try{r(await wa.saveFallbackModels(o)),t(a(`config:providerWorkbench.fallbackModelsSaved`))}catch(e){b(s),f(e instanceof Error?e.message:String(e))}finally{l(!1)}},I=async e=>{let n=x;S(e),l(!0),f(``);try{r(await wa.saveAuxiliaryModel(e)),t(a(`config:providerWorkbench.auxiliaryModelSaved`))}catch(e){S(n),f(e instanceof Error?e.message:String(e))}finally{l(!1)}},L=(e,t)=>(0,Q.jsxs)(Y,{"aria-labelledby":t,className:`w-full`,disabled:!j.length||n||c||e>0&&!y[0],value:y[e]||``,onChange:t=>void F(e,t.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:a(`config:providerWorkbench.fallbackNone`)}),y[e]&&!j.some(t=>eo(t)===y[e])&&(0,Q.jsx)(`option`,{value:y[e],children:y[e]}),j.map(e=>(0,Q.jsx)(`option`,{value:eo(e),children:`${e.model.name||e.model.id} · ${e.provider.name}`},e.value))]});return(0,Q.jsxs)(`section`,{"data-config-card":`models-current-model`,"aria-labelledby":`${o}-heading`,"aria-busy":c||void 0,className:`mt-6 min-w-0`,children:[(0,Q.jsx)(`h2`,{id:`${o}-heading`,className:`sr-only`,children:a(`config:configPage.currentChatModel`)}),(0,Q.jsxs)(`div`,{"data-config-target":`models-runtime-policy`,className:`border-t border-stroke`,children:[(0,Q.jsx)(to,{labelId:`${o}-model`,label:a(`config:providerWorkbench.defaultModel`),hint:a(`config:providerWorkbench.defaultModelHint`),children:(0,Q.jsxs)(Y,{"aria-labelledby":`${o}-model`,className:`w-full`,disabled:!j.length||n||c,value:j.some(e=>e.value===M)?M:``,onChange:e=>{let[t,n]=e.target.value.split($a),r=A.find(e=>e.id===t);r&&n&&i(r,n)},children:[!j.length&&(0,Q.jsx)(`option`,{value:``,children:a(`config:providerWorkbench.noChatModel`)}),j.map(({provider:e,model:t,value:n})=>(0,Q.jsx)(`option`,{value:n,children:`${Pt(t.name||t.id,j.map(e=>e.model.name||e.model.id))} · ${e.name}`},n))]})}),(0,Q.jsx)(to,{labelId:`${o}-fallback`,label:a(`config:providerWorkbench.fallbackModels`),hint:a(`config:providerWorkbench.fallbackModelsHint`),children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Q.jsx)(`span`,{id:`${o}-fallback-1`,className:`sr-only`,children:a(`config:providerWorkbench.fallbackFirst`)}),L(0,`${o}-fallback ${o}-fallback-1`),y[0]&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{id:`${o}-fallback-2`,className:`sr-only`,children:a(`config:providerWorkbench.fallbackSecond`)}),L(1,`${o}-fallback ${o}-fallback-2`)]})]})}),(0,Q.jsx)(to,{labelId:`${o}-auxiliary`,label:a(`config:providerWorkbench.auxiliaryModel`),hint:a(`config:providerWorkbench.auxiliaryModelHint`),children:(0,Q.jsxs)(Y,{"aria-labelledby":`${o}-auxiliary`,"aria-describedby":`${o}-auxiliary-hint`,className:`w-full`,disabled:!j.length||n||c,value:x,onChange:e=>void I(e.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:a(`config:providerWorkbench.auxiliaryFollowSession`)}),x&&!j.some(e=>eo(e)===x)&&(0,Q.jsx)(`option`,{value:x,children:x}),j.map(e=>(0,Q.jsx)(`option`,{value:eo(e),children:`${e.model.name||e.model.id} · ${e.provider.name}`},e.value))]})}),(0,Q.jsx)(to,{labelId:`${o}-thinking`,label:a(`config:configPage.thinkingLevel`),hint:a(`config:providerWorkbench.thinkingHint`),children:(0,Q.jsx)(Y,{"aria-labelledby":`${o}-thinking`,className:`w-full`,disabled:P,value:m,onChange:e=>{h(e.target.value),N({thinkingLevel:e.target.value})},children:D.map(e=>(0,Q.jsx)(`option`,{value:e,children:O(e)},e))})}),(0,Q.jsx)(to,{labelId:`${o}-tools`,label:a(`config:configPage.availableTools`),hint:a(`config:providerWorkbench.toolsHint`),children:(0,Q.jsxs)(Y,{"aria-labelledby":`${o}-tools`,className:`w-full`,disabled:P,value:g,onChange:e=>{_(e.target.value),N({toolMode:e.target.value})},children:[(0,Q.jsx)(`option`,{value:`full`,children:a(`config:configPage.fullToolAccess`)}),(0,Q.jsx)(`option`,{value:`custom`,children:a(`config:configPage.customManageEachToolOnThePluginsPage`)})]})})]}),(!k||c)&&(0,Q.jsxs)(`p`,{className:`mt-2 flex items-center gap-2 text-xs text-content-muted`,role:`status`,children:[c&&(0,Q.jsx)(V,{className:`size-3`}),a(c?`config:configPage.saving`:`config:providerWorkbench.defaultsNeedProvider`)]}),d&&(0,Q.jsx)(q,{children:d})]})}function ro({className:e,...t}){return(0,Q.jsx)(Ar,{"data-slot":`accordion`,className:B(`flex w-full flex-col`,e),...t})}function io({className:e,...t}){return(0,Q.jsx)(jr,{"data-slot":`accordion-item`,className:B(`not-last:border-b not-last:border-stroke-soft`,e),...t})}function ao({className:e,children:t,...n}){return(0,Q.jsx)(Mr,{className:`flex`,children:(0,Q.jsxs)(Nr,{"data-slot":`accordion-trigger`,className:B(`group/accordion-trigger relative flex flex-1 items-start justify-between rounded-sm border border-transparent py-2.5 text-left text-sm font-medium transition-colors hover:underline focus-visible:after:border-ring disabled:pointer-events-none disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground`,e),...n,children:[t,(0,Q.jsx)(E,{"data-slot":`accordion-trigger-icon`,className:`pointer-events-none shrink-0 group-aria-expanded/accordion-trigger:hidden`}),(0,Q.jsx)(O,{"data-slot":`accordion-trigger-icon`,className:`pointer-events-none hidden shrink-0 group-aria-expanded/accordion-trigger:inline`})]})})}function oo({className:e,children:t,...n}){return(0,Q.jsx)(Pr,{"data-slot":`accordion-content`,className:`overflow-hidden text-sm data-open:animate-accordion-down data-closed:animate-accordion-up`,...n,children:(0,Q.jsx)(`div`,{className:B(`h-(--radix-accordion-content-height) pt-0 pb-2.5 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4`,e),children:t})})}var so=[`fast`,`standard`,`strong`],co={listProfiles(){return p(`/api/agent-profiles`)},saveModelTiers(e){return p(`/api/config/subagent-model-tiers`,{method:`PUT`,body:JSON.stringify({tiers:e})})}};function lo({config:e,notify:t,busy:n,onConfigChanged:r}){let{t:i}=u(),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,Z.useId)(),[c,l]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(``),_=e.subagentModelTiers||{},v=so.map(e=>_[e]||``).join(`
|
|
6
6
|
`),[y,b]=(0,Z.useState)(_);(0,Z.useEffect)(()=>{let e=v.split(`
|
|
7
|
-
`);b(Object.fromEntries(so.map((t,n)=>[t,e[n]]).filter(([,e])=>e)))},[v]),(0,Z.useEffect)(()=>{let e=!0;return co.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:`${Pt(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),l(!0),f(``);try{r(await co.saveModelTiers(o)),t(i(`config:subagents.tiersSaved`))}catch(e){b(a),f(e instanceof Error?e.message:String(e))}finally{l(!1)}},w=so.filter(e=>y[e]).length,T=p?.profiles||[],E=p?.errors||[];return(0,Q.jsx)(`section`,{"aria-labelledby":`${s}-heading`,"aria-busy":c||void 0,"data-config-card":`models-subagents`,"data-config-target":`models-subagents`,className:`min-w-0 border-t border-stroke`,children:(0,Q.jsx)(ro,{type:`single`,collapsible:!0,children:(0,Q.jsxs)(io,{value:`subagents`,children:[(0,Q.jsx)(ao,{children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,Q.jsx)(`span`,{id:`${s}-heading`,children:i(`config:subagents.title`)}),(0,Q.jsx)(`span`,{className:`truncate text-xs font-normal text-content-muted`,children:w?i(`config:subagents.configuredSummary`,{count:w}):i(`config:subagents.followSession`)})]})}),(0,Q.jsxs)(oo,{className:`h-auto`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`config:subagents.hint`)}),(0,Q.jsx)(`div`,{className:`mt-3 border-t border-stroke`,children:so.map(e=>{let t=y[e]||``;return(0,Q.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,Q.jsxs)(`div`,{className:`min-w-[min(240px,100%)] flex-1`,children:[(0,Q.jsxs)(`div`,{id:`${s}-${e}`,className:`text-sm text-content`,children:[a(e),(0,Q.jsx)(`code`,{className:`ml-2 font-mono text-xs text-content-muted`,children:e})]}),(0,Q.jsx)(`p`,{id:`${s}-${e}-hint`,className:`mt-0.5 text-xs text-content-muted`,children:o(e)})]}),(0,Q.jsx)(`div`,{className:`w-[min(280px,100%)] min-w-0 max-[650px]:w-full`,children:(0,Q.jsxs)(Y,{"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,Q.jsx)(`option`,{value:``,children:i(`config:subagents.followSession`)}),t&&!S.some(e=>e.value===t)&&(0,Q.jsx)(`option`,{value:t,children:t}),S.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value))]})})]},e)})}),d&&(0,Q.jsx)(q,{children:d}),(0,Q.jsx)(`h3`,{className:`mt-5 text-[13px] font-medium text-content`,children:i(`config:subagents.globalDefinitions`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-content-muted`,children:i(`config:subagents.definitionsHint`)}),p===null?(0,Q.jsxs)(`p`,{role:`status`,className:`mt-3 flex items-center gap-2 text-xs text-content-muted`,children:[(0,Q.jsx)(V,{className:`size-3`}),i(`config:subagents.loading`)]}):T.length===0&&E.length===0?(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-content-muted`,children:i(`config:subagents.empty`)}):(0,Q.jsxs)(`ul`,{className:`mt-3 flex min-w-0 flex-col border-t border-stroke`,children:[T.map(e=>(0,Q.jsxs)(`li`,{className:`min-w-0 border-b border-stroke py-2 text-[13px]`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`code`,{className:`shrink-0 font-mono text-content`,children:e.name}),(0,Q.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,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-content-secondary`,children:e.description})]},e.name)),E.map(e=>(0,Q.jsxs)(`li`,{className:`min-w-0 border-b border-stroke py-2 text-[13px]`,children:[(0,Q.jsx)(`code`,{className:`font-mono text-danger`,children:e.file||e.scope}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-danger`,children:e.message})]},`${e.scope}:${e.file}`))]}),h&&(0,Q.jsx)(q,{children:h})]})]})})})}function uo(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)||e}function fo({notify:e}){let{t}=u(),n=(0,Z.useId)(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[l,d]=(0,Z.useState)(`allow`),[f,p]=(0,Z.useState)(`bash`),[m,h]=(0,Z.useState)(``);(0,Z.useEffect)(()=>{let e=!0;return un.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(()=>un.add({effect:l,tool:f,pattern:e}),t(`config:permissionRules.added`))&&h(``)};return(0,Q.jsx)(`section`,{"aria-labelledby":`${n}-heading`,"data-config-card":`models-permission-rules`,"data-config-target":`models-permission-rules`,className:`min-w-0 border-b border-stroke`,children:(0,Q.jsx)(ro,{type:`single`,collapsible:!0,children:(0,Q.jsxs)(io,{value:`rules`,children:[(0,Q.jsx)(ao,{children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,Q.jsx)(`span`,{id:`${n}-heading`,children:t(`config:permissionRules.title`)}),(0,Q.jsx)(`span`,{className:`truncate text-xs font-normal text-content-muted`,children:r===null?``:r.length?t(`config:permissionRules.countSummary`,{count:r.length}):t(`config:permissionRules.noneSummary`)})]})}),(0,Q.jsxs)(oo,{className:`h-auto`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:t(`config:permissionRules.hint`)}),r===null?(0,Q.jsxs)(`p`,{role:`status`,className:`mt-3 flex items-center gap-2 text-xs text-content-muted`,children:[(0,Q.jsx)(V,{className:`size-3`}),t(`config:permissionRules.loading`)]}):r.length===0?(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-content-muted`,children:t(`config:permissionRules.empty`)}):(0,Q.jsx)(`ul`,{className:`mt-3 flex min-w-0 flex-col border-t border-stroke`,children:r.map(e=>(0,Q.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 border-b border-stroke py-2 text-[13px]`,children:[(0,Q.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,Q.jsx)(`span`,{className:`shrink-0 text-xs text-content-muted`,children:e.tool===`files`?t(`config:permissionRules.files`):t(`config:permissionRules.command`)}),(0,Q.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-content`,title:e.pattern,children:e.pattern}),(0,Q.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate text-xs text-content-muted`,title:e.cwd||void 0,children:e.cwd?uo(e.cwd):t(`config:permissionRules.global`)}),(0,Q.jsx)(H,{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(()=>un.remove(e.id),t(`config:permissionRules.removed`)),children:(0,Q.jsx)(be,{})})]},e.id))}),(0,Q.jsxs)(`form`,{className:`mt-3 flex min-w-0 flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,Q.jsxs)(Y,{"aria-label":t(`config:permissionRules.effectLabel`),className:`w-28`,disabled:s,value:l,onChange:e=>{let t=e.target.value===`deny`?`deny`:`allow`;d(t),t===`deny`&&p(`bash`)},children:[(0,Q.jsx)(`option`,{value:`allow`,children:t(`config:permissionRules.allow`)}),(0,Q.jsx)(`option`,{value:`deny`,children:t(`config:permissionRules.deny`)})]}),(0,Q.jsxs)(Y,{"aria-label":t(`config:permissionRules.toolLabel`),className:`w-32`,disabled:s||l===`deny`,value:f,onChange:e=>p(e.target.value===`files`?`files`:`bash`),children:[(0,Q.jsx)(`option`,{value:`bash`,children:t(`config:permissionRules.command`)}),(0,Q.jsx)(`option`,{value:`files`,children:t(`config:permissionRules.files`)})]}),(0,Q.jsx)(U,{"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,Q.jsxs)(H,{type:`submit`,variant:`secondary`,disabled:s||!m.trim(),className:`max-[650px]:min-h-11`,children:[s&&(0,Q.jsx)(V,{className:`size-3`}),t(`config:permissionRules.add`)]})]}),a&&(0,Q.jsx)(q,{children:a})]})]})})})}function po(e){return e instanceof Error?e.message:String(e)}function mo({notify:e,requestConfirm:t,t:n}){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!0),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(``),v=(0,Z.useRef)(0),y=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{let e=!0;y.current=!0;let t=v.current;return p(`/api/config`).then(n=>{if(e)return v.current===t&&i(n),o(!1),p(`/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(po(n)),o(!1))}),()=>{e=!1,y.current=!1,v.current+=1}},[]);let b=(0,Z.useCallback)(e=>{v.current+=1,i(e),o(!1),c(``)},[]),x=(0,Z.useCallback)(async()=>{let e=v.current,t=await p(`/api/config`);y.current&&v.current===e&&b(t)},[b]),S=(0,Z.useCallback)(async(t,r)=>{u(t.id),c(``);try{let i=await p(`/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(po(e))}finally{u(``)}},[b,e,n]),C=(0,Z.useCallback)(async t=>{f(t.id),c(``);try{let r=await p(`/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(po(e))}finally{f(``)}},[b,e,n]),w=(0,Z.useCallback)(async(t,r)=>{h(t.id),c(``);try{let i=await p(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:t.id,model:r,setAsDefault:!1})});b(i),e(n(`config:configPage.providerConnectionUpdated`))}catch(e){c(po(e))}finally{h(``)}},[b,e,n]),T=(0,Z.useCallback)(async(t,r)=>{f(t.id),c(``);try{let i=await p(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:t.id,model:r,setAsDefault:!1})});(i.defaultProvider||i.provider)!==t.id&&(i=await p(`/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(po(e))}finally{f(``)}},[b,e,n]),E=(0,Z.useCallback)(async()=>{o(!0),c(``);let e=v.current;try{let t=await p(`/api/config`);y.current&&v.current===e&&b(t)}catch(e){y.current&&c(po(e))}finally{y.current&&o(!1)}},[b]),D=(0,Z.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 wa.deleteModel(r.id,i.id)),e(n(`providers:modelEditor.deleted`))}catch(e){c(po(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,Z.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 p(`/api/providers/${encodeURIComponent(r.id)}`,{method:`DELETE`});b(t),e(n(`config:configPage.providerConnectionDeleted`))}catch(e){c(po(e))}}},[b,e,t,n]),deleteModel:D}}function ho({requestConfirm:e,onImported:t,onAutoImported:n,t:r}){let[i,a]=(0,Z.useState)({providers:[],errors:[]}),[o,s]=(0,Z.useState)(!0),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(``),[f,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)({imported:0,skipped:0}),_=(0,Z.useRef)(0),v=(0,Z.useRef)(n);v.current=n;let y=(0,Z.useCallback)(async()=>{let e=++_.current;s(!0),l(``);try{let t=await wa.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(po(t))}finally{e===_.current&&s(!1)}},[]);return(0,Z.useEffect)(()=>(y(),()=>{_.current+=1}),[y]),{discovery:i,autoImport:h,discovering:o,error:c,operationError:u,importing:f,refresh:y,importProvider:(0,Z.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 p(`/api/providers/${encodeURIComponent(n.id)}/import`,{method:`POST`,body:`{}`});a(e.discovery),t(e)}catch(e){d(po(e))}finally{m(``)}}},[t,e,r])}}function go({providers:e,defaultProviderId:t=``,toggling:n,settingDefault:r=``,settingModel:i=``,onConfigure:a,onClone:o,onSetDefault:s,onSetDefaultModel:c,onToggle:l,onDelete:d}){let{t:f}=u(),p=e.filter(e=>e.configured||e.custom);return(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:p.map(e=>{let u=Ca[e.id]||ge,p=e.id===t,m=e.configured?e.enabled?f(`config:configPage.authenticationReady`):f(`config:configPage.disabled2`):e.id===`openai-codex`?f(`config:configPage.codexCLILoginRequired`):f(`config:configPage.apiKeyRequired`);return(0,Q.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,Q.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,Q.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,Q.jsx)(u,{size:15})}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),p&&(0,Q.jsx)($t,{variant:`accent`,children:f(`config:configPage.defaultBadge`)})]}),c&&e.models.some(e=>e.kind===`chat`)?(0,Q.jsxs)(`label`,{className:`grid min-w-0 gap-1 text-xs text-content-muted`,children:[f(`config:configPage.providerDefaultModel`),(0,Q.jsxs)(Y,{"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,Q.jsx)(`option`,{value:e.defaultModel||``,disabled:!0,children:e.defaultModel||f(`config:configPage.selectModel`)}),e.models.filter(e=>e.kind===`chat`).map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}):e.defaultModel?(0,Q.jsxs)(`small`,{className:`truncate font-mono text-xs text-content-muted`,title:e.defaultModel,children:[f(`config:configPage.providerDefaultModel`),`: `,e.defaultModel]}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`small`,{className:`text-xs text-content-muted`,children:m}),(0,Q.jsxs)(`div`,{className:`flex flex-none items-center gap-1.5`,children:[s&&(0,Q.jsx)(H,{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,Q.jsx)(Jn,{size:13})}),(0,Q.jsx)(H,{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,Q.jsx)(M,{size:13})}),(0,Q.jsx)(vi,{ariaLabel:f(`config:configPage.providerEnabled`,{name:e.name}),value:e.configured&&e.enabled,disabled:!e.configured||n===e.id,onChange:t=>l(e,t)}),e.custom&&(0,Q.jsx)(H,{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,Q.jsx)(be,{size:13})})]})]})]},e.id)})})}var _o=`pisper.config.visualConnectionsOpen`,vo={running:null,result:null,error:``};function yo(){return i.getItem(_o)===`1`}function bo({config:e,notify:t,toggling:n,onToggleProvider:r,onDeleteProvider:a,onCloneProvider:o,onQuickSetup:s,onEditVisualProvider:c}){let{t:l}=u(),[d,f]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!0),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(``),[w,D]=(0,Z.useState)(yo),O=(0,Z.useCallback)(async()=>{try{f(await p(`/api/visual/models`)),C(``)}catch(e){C(e instanceof Error?e.message:String(e))}finally{h(!1)}},[]);(0,Z.useEffect)(()=>{O()},[O,e]),(0,Z.useEffect)(()=>{vo.result&&x(vo.result),vo.error&&C(vo.error);let e=vo.running;if(!e)return;y(!0);let t=!0;return e.then(e=>{t&&x(e)}).catch(()=>{t&&C(vo.error)}).finally(()=>{t&&y(!1)}),()=>{t=!1}},[]);let j=async(e,n)=>{_(e),C(``);try{f(await p(`/api/visual/models/${e}`,{method:`PUT`,body:JSON.stringify({model:n})})),t(l(`config:configPage.visualModelUpdated`))}catch(e){C(e instanceof Error?e.message:String(e))}finally{_(``)}},M=async()=>{if(vo.running)return;y(!0),C(``),x(null),vo.result=null,vo.error=``;let e=p(`/api/visual/test`,{method:`POST`,body:`{}`,timeout:21e4});vo.running=e;try{let n=await e;vo.result=n,x(n),t(l(`config:configPage.testSucceeded`))}catch(e){let n=e instanceof Error?e.message:String(e);vo.error=n,C(n),t(n)}finally{vo.running=null,y(!1)}},N=e=>{D(e),i.setItem(_o,e?`1`:`0`)},P=e.providers.filter(e=>e.type===`visual`),F=P.filter(e=>e.configured||e.custom),I=d?.imageModels||[],L=d?.videoModels||[];return(0,Q.jsxs)(`section`,{className:`mt-3`,children:[(0,Q.jsxs)(hi,{className:`mb-3 py-3.5`,"data-config-card":`models-visual`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:B(`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,Q.jsx)(ye,{size:18})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-content-muted`,children:l(`config:configPage.currentVisualModel`)}),m?(0,Q.jsxs)(`span`,{role:`status`,className:`flex items-center gap-2 text-xs text-content-muted`,children:[(0,Q.jsx)(V,{className:`size-3.5`}),l(`config:configPage.loadingVisualStatus`)]}):d?.image?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`truncate text-sm font-medium text-content`,children:[d.image.providerName,` / `,d.image.name]}),(0,Q.jsxs)(_i,{tone:`green`,children:[(0,Q.jsx)(A,{size:11,className:`mr-[3px] inline`}),l(`config:configPage.authenticationReady`)]})]}),d.video&&(0,Q.jsxs)(`small`,{className:`text-xs text-content-muted [overflow-wrap:anywhere]`,children:[l(`config:configPage.visualVideoModel`),`:`,d.video.providerName,` /`,` `,d.video.name]})]}):(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-warning-strong`,children:[(0,Q.jsx)(k,{size:14,"aria-hidden":`true`}),l(`config:configPage.visualNoneConfigured`)]}),(0,Q.jsx)(`small`,{className:`text-xs text-content-muted`,children:l(`config:configPage.visualEmptyHint`)})]})]}),(0,Q.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,Q.jsxs)(H,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:v,onClick:()=>void M(),children:[v?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(ee,{size:13}),l(v?`config:configPage.testingGeneration`:`config:configPage.testGeneration`)]}),(0,Q.jsxs)(H,{className:`max-[650px]:h-11`,onClick:s,children:[(0,Q.jsx)(Qn,{size:13}),l(`config:configPage.visualQuickSetup`)]})]})]}),b&&(0,Q.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,Q.jsx)(`img`,{src:b.previewDataUrl,alt:b.modelName,className:`size-11 flex-none rounded-xs object-cover`}):(0,Q.jsx)(T,{size:16,className:`flex-none text-success`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-px text-xs`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-success-strong`,children:l(`config:configPage.testSucceeded`)}),(0,Q.jsxs)(`span`,{className:`truncate font-mono text-content-muted`,children:[b.providerName,` / `,b.modelName,` · `,b.path]})]})]})]}),(0,Q.jsxs)(ze,{open:w,onOpenChange:N,children:[(0,Q.jsx)(Le,{asChild:!0,children:(0,Q.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,Q.jsx)(E,{size:16,"aria-hidden":`true`,className:`flex-none text-content-muted transition-transform group-data-[state=closed]:-rotate-90`}),(0,Q.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-content`,children:l(`config:configPage.visualConnections`)}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:l(`config:configPage.visualConnectionsHint`)})]})}),(0,Q.jsx)(Fe,{children:(0,Q.jsxs)(hi,{className:`mt-2 py-4`,children:[(0,Q.jsx)(go,{providers:P,toggling:n,onClone:o,onConfigure:e=>c(e.id),onToggle:r,onDelete:a}),F.length===0&&(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:l(`config:configPage.visualEmptyHint`)}),(I.length>0||L.length>0)&&(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 border-t border-stroke-soft pt-3`,children:[I.length>0&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`w-16 flex-none text-xs text-content-muted`,children:l(`config:configPage.visualImageModel`)}),(0,Q.jsxs)(Y,{className:`min-w-0 flex-1`,value:d?.imageSelection||``,disabled:g===`image`,"aria-label":l(`config:configPage.visualImageModel`),onChange:e=>void j(`image`,e.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:l(`config:configPage.visualAutoSelected`)}),I.map(e=>(0,Q.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),L.length>0&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`w-16 flex-none text-xs text-content-muted`,children:l(`config:configPage.visualVideoModel`)}),(0,Q.jsxs)(Y,{className:`min-w-0 flex-1`,value:d?.videoSelection||``,disabled:g===`video`,"aria-label":l(`config:configPage.visualVideoModel`),onChange:e=>void j(`video`,e.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:l(`config:configPage.visualAutoSelected`)}),L.map(e=>(0,Q.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),(0,Q.jsx)(`small`,{className:`text-xs text-content-muted`,children:l(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]})]})})]}),S&&(0,Q.jsx)(`div`,{className:`mt-2.5`,children:(0,Q.jsxs)(tn,{children:[(0,Q.jsx)(xe,{size:13}),S]})})]})}var xo=`pisper.config.manageConnectionsOpen`;function So(){let e=i.getItem(xo);return e===`1`||e!==`0`&&null}function Co({defaultAdvancedExpanded:e=!1,navigationKey:n,notify:r,registerPrimaryAction:a,requestConfirm:o}){let{t:s}=u(),c=t(),l=new URLSearchParams(c.search).get(`import`)===`1`,[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(()=>l||e?!0:So());(0,Z.useEffect)(()=>{l&&v(!0)},[l]),(0,Z.useEffect)(()=>{e&&v(!0)},[e,n]);let y=mo({notify:r,requestConfirm:o,t:s}),{config:b}=y,x=ho({requestConfirm:o,onAutoImported:y.refreshConfig,onImported:e=>{y.applyConfig(e.config);let t=e.config.providers.find(t=>t.id===e.providerId);r(e.kind===`authentication`?s(`config:configPage.nameLoginStateHasBeenLoadedIntoPisper`,{name:t?.name||e.providerId}):s(`config:configPage.nameConfigurationHasBeenLoadedIntoPisper`,{name:t?.name||e.providerId}))},t:s});if(va(a,()=>m({providerType:`chat`})),!b)return y.error&&!y.loading?(0,Q.jsx)(Ut,{kind:`error`,title:s(`config:providerWorkbench.loadFailed`),description:y.error,action:(0,Q.jsx)(H,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void y.reload(),children:s(`common:pageTemplate.retry`)})}):(0,Q.jsx)(Ut,{kind:`loading`,title:s(`config:configPage.loadingModelCatalog`),description:s(`config:configPage.readingProvidersAndAuthenticationStatus`)});let S=_??!1,C=Ha(x.discovery),w=e=>{v(e),i.setItem(xo,e?`1`:`0`)},T=e=>g(e);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(no,{config:b,notify:r,busy:!!(y.settingDefault||y.toggling),onConfigChanged:y.applyConfig,onSetDefaultModel:y.setDefaultChatModel}),(0,Q.jsx)(Ia,{config:b,selectedProviderId:d,onSelectProvider:f,toggling:y.toggling,settingDefault:y.settingDefault,settingModel:y.settingModel,onSave:e=>{y.applyConfig(e),r(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:(x.discovering||x.autoImport.imported>0||x.autoImport.skipped>0)&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,role:`status`,children:[x.discovering&&(0,Q.jsx)(V,{className:`size-3`}),x.discovering?s(`config:providerWorkbench.scanningLocal`):s(`config:providerWorkbench.localImportStatus`,{imported:x.autoImport.imported,skipped:x.autoImport.skipped})]})}),y.error&&(0,Q.jsx)(q,{children:y.error}),(0,Q.jsxs)(`div`,{className:`mt-8`,"data-config-advanced":!0,children:[(0,Q.jsx)(lo,{config:b,notify:r,busy:!!(y.settingDefault||y.toggling),onConfigChanged:y.applyConfig}),(0,Q.jsx)(fo,{notify:r})]}),C>0&&(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-2 gap-y-0 text-xs text-content-muted`,children:[(0,Q.jsx)(`span`,{children:s(`config:configPage.localProviderImportHint`,{count:C})}),(0,Q.jsx)(H,{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,Q.jsxs)(ze,{open:S,onOpenChange:w,"data-config-card":`models-advanced`,children:[(0,Q.jsx)(Le,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:`group flex min-h-9 w-full cursor-pointer items-center gap-2 border-0 border-b border-stroke bg-transparent py-2.5 text-left outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus max-[650px]:min-h-11`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-content`,children:s(`config:providerWorkbench.advanced`)}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:s(`config:providerWorkbench.advancedHint`)}),(0,Q.jsx)(E,{size:16,"aria-hidden":`true`,className:`ml-auto shrink-0 text-content-muted transition-transform group-data-[state=open]:rotate-180`})]})}),(0,Q.jsxs)(Fe,{id:`model-connection-management`,children:[(0,Q.jsx)(Ya,{discovery:x.discovery,discovering:x.discovering,error:x.error||x.operationError,importing:x.importing,forceVisible:l,onRefresh:x.refresh,onImport:x.importProvider}),(0,Q.jsx)(bo,{config:b,notify:r,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,Q.jsx)(Za,{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),r(s(`config:configPage.setupComplete`)),m(null)}}),h&&(0,Q.jsx)(Va,{initialProviderType:h.type,cloneProvider:h,onClose:()=>g(null),onCreated:e=>{y.applyConfig(e),e.createdProviderId&&f(e.createdProviderId),r(s(`config:configPage.providerConnectionCreated`)),g(null)}})]})}var wo=[`browser`,`feishu`,`weixin`,`qq`,`telegram`];function To(e){if(!e||typeof e!=`object`||Array.isArray(e))throw d();return e}function Eo(e,t){if(typeof e!=`string`||e.length>t)throw d();return e}function Do(e){let t=To(e),n=To(t.browser);if(typeof n.enabled!=`boolean`||!Array.isArray(t.templates)||!Array.isArray(t.scopes))throw d();let r={},i=To(t.connections);for(let e of wo){if(e===`browser`||i[e]===void 0)continue;let t=i[e];if(t===null){r[e]=null;continue}let n=To(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=To(e),n=Eo(t.id,200);if(!n||a.has(n)||typeof t.enabled!=`boolean`||!Array.isArray(t.variables))throw d();a.add(n);let r={},i=To(t.channels);for(let e of wo){if(i[e]===void 0)continue;let t=To(i[e]);if(t.enabled!==void 0&&typeof t.enabled!=`boolean`)throw d();r[e]={content:Eo(t.content,12e3),...t.enabled===void 0?{}:{enabled:t.enabled}}}return{id:n,name:Eo(t.name,500),description:Eo(t.description,2e3),enabled:t.enabled,variables:t.variables.map(e=>Eo(e,200)),channels:r}}),s=t.scopes.map(e=>{let t=To(e);if(!wo.includes(t.platform))throw d();return{...t,platform:t.platform}});return{browser:{enabled:n.enabled},connections:r,scopes:s,templates:o}}function Oo(e){let t=To(e);if(typeof t.sent!=`number`||!Number.isInteger(t.sent)||t.sent<0)throw d();return{sent:t.sent,...t.title===void 0?{}:{title:Eo(t.title,2e3)},...t.body===void 0?{}:{body:Eo(t.body,12e3)},...t.preview===void 0?{}:{preview:Eo(t.preview,12e3)}}}function ko(e){return e.templates.length>0&&e.templates.every(e=>wo.every(t=>typeof e.channels[t]?.enabled==`boolean`))}var Ao=(e,t)=>`/api/settings/notifications/templates/${encodeURIComponent(e)}/${t}`,jo=(e,t,n,r)=>f(Ao(e,t),{method:`PUT`,body:n,...r,parse:Do}),Mo={load:(e={})=>f(`/api/settings/notifications`,{...e,parse:Do}),setBrowserEnabled:(e,t={})=>f(`/api/settings/notifications/browser`,{method:`PATCH`,body:{enabled:e},...t,parse:Do}),setEventEnabled:(e,t,n={})=>jo(e,`browser`,{enabled:t},n),setChannelEnabled:async(e,t,n,r={})=>{let i=await jo(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={})=>jo(e,t,{content:n},r),testSavedTemplate:(e,t,n={})=>f(`${Ao(e,t)}/test`,{method:`POST`,body:{},...n,parse:Oo})},No=e=>e instanceof Error?e.message:String(e),Po=(e,t)=>`${e}\0${t}`,Fo=e=>e.kind===`browser`?`browser`:e.kind===`event`?`event:${e.event}`:`channel:${e.event}:${e.platform}`;function Io(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 Lo(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 Ro(e){let[t,n]=(0,Z.useState)(null),r=(0,Z.useRef)(null),i=(0,Z.useRef)(e);i.current=e;let[a,o]=(0,Z.useState)(!0),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)({}),[f,p]=(0,Z.useState)({}),m=(0,Z.useRef)({}),[h,g]=(0,Z.useState)({}),[_,v]=(0,Z.useState)({}),y=(0,Z.useRef)(!1),b=(0,Z.useRef)(null),x=(0,Z.useRef)(new Map),S=(0,Z.useRef)(new Map),C=(0,Z.useRef)(new Set),w=(0,Z.useRef)(0),T=(0,Z.useRef)(0),E=(0,Z.useCallback)(e=>{r.current=e,T.current++,n(e),i.current?.(e)},[]),D=(0,Z.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 Mo.load({signal:e.signal});y.current&&!e.signal.aborted&&t===T.current&&E(n)}catch(t){y.current&&!e.signal.aborted&&c(No(t))}finally{y.current&&!e.signal.aborted&&o(!1)}},[E]);(0,Z.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=Fo(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(Io(r.current,e)!==t.value||C.current.has(n)){let i={signal:a.signal},o=e.kind===`browser`?await Mo.setBrowserEnabled(t.value,i):e.kind===`event`?await Mo.setEventEnabled(e.event,t.value,i):await Mo.setChannelEnabled(e.event,e.platform,t.value,i);if(!y.current||a.signal.aborted)return;E(Lo(r.current,e,Io(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:No(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=Lo(k,e.target,e.value));let A=(e,t,n)=>{let r=Po(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=Po(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?ko(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=Po(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 Mo.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:No(e)}})),!1}finally{x.current.get(i)===o&&x.current.delete(i)}},testTemplate:async(e,t)=>{let n=Po(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 Mo.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:No(e)}}))}finally{x.current.get(r)===i&&x.current.delete(r)}}}}function zo(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 Bo({settings:e,templates:t,eventId:n,platform:r,onSelectionChange:i,platformLabel:a,permissionGranted:o,onBrowserTest:s,notify:c}){let{t:l}=u(),d=(0,Z.useRef)(!0),[f,p]=(0,Z.useState)(``);(0,Z.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let m=t.find(e=>e.id===n)||t[0];if(!m||!e.data)return(0,Q.jsx)(`p`,{role:`status`,children:l(`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`?l(`config:notificationSettings.theTestNotificationWasSentCheckYourSystemNotificationCenter`):l(`config:notificationSettings.testNotificationSentToCountChats`,{count:t.sent}))}catch(e){d.current&&p(e instanceof Error?e.message:String(e))}};return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`h2`,{className:`text-[15px] leading-6 font-medium text-content`,children:l(`config:notificationSettings.notificationTemplates`)}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[l(`config:notificationSettings.notificationEvent`),(0,Q.jsx)(Y,{"aria-label":l(`config:notificationSettings.notificationEvent`),value:m.id,onChange:e=>i(e.target.value,r),children:t.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[l(`config:notificationSettings.notificationChannel`),(0,Q.jsx)(Y,{"aria-label":l(`config:notificationSettings.notificationChannel`),value:r,onChange:e=>{let t=wo.find(t=>t===e.target.value);t&&i(m.id,t)},children:wo.map(e=>(0,Q.jsx)(`option`,{value:e,children:a(e)},e))})]})]}),(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:m.description}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[l(`config:notificationSettings.messageContent`),(0,Q.jsx)(Nt,{"aria-label":l(`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,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-content-muted`,children:[(0,Q.jsx)(`span`,{children:l(`config:notificationSettings.availableVariables`)}),m.variables.map(e=>(0,Q.jsx)(`code`,{className:`rounded-xs bg-inline-code px-1.5 py-0.5 font-mono text-content-secondary`,children:`{{${e}}}`},e))]}),(0,Q.jsxs)(`div`,{className:`rounded-md border border-stroke bg-code p-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-content-muted`,children:l(`config:notificationSettings.preview`)}),(0,Q.jsx)(`pre`,{className:`mt-2 font-sans text-sm break-words whitespace-pre-wrap text-content`,children:zo(h.content,l)})]}),(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:h.dirty?l(`config:notificationSettings.saveBeforeTest`):l(`config:notificationSettings.testUsesSavedTemplate`)}),!_&&(0,Q.jsx)(`p`,{role:`status`,className:`text-xs text-content-muted`,children:l(`config:notificationSettings.channelTestUnavailable`)}),(h.save.error||h.test.error||f)&&(0,Q.jsx)(tn,{children:h.save.error||h.test.error||f}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,Q.jsx)(H,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:h.dirty||h.save.pending||!_,loading:h.test.pending,onClick:()=>void v(),children:l(`config:notificationSettings.sendTest`)}),(0,Q.jsx)(H,{"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(l(`config:notificationSettings.notificationTemplateSaved`))},children:l(`config:notificationSettings.saveTemplate`)})]})]})}function Vo(e,t){switch(t){case`chime`:return e(`config:notificationSounds.soundChime`);case`marimba`:return e(`config:notificationSounds.soundMarimba`);case`drop`:return e(`config:notificationSounds.soundDrop`);case`bell`:return e(`config:notificationSounds.soundBell`);default:return e(`config:notificationSounds.soundLow`)}}function Ho(e,t){return e(t===`waiting`?`config:notificationSounds.eventWaiting`:t===`finished`?`config:notificationSounds.eventFinished`:`config:notificationSounds.eventFailed`)}function Uo(e,t){return e(t===`waiting`?`config:notificationSounds.eventWaitingHint`:t===`finished`?`config:notificationSounds.eventFinishedHint`:`config:notificationSounds.eventFailedHint`)}function Wo(){let{t:e}=u(),t=gn(),[n,r]=(0,Z.useState)(null),i=n??t.volume,a=e=>{e!==`none`&&_n(e,t.volume)};return(0,Q.jsxs)(Zt,{"data-config-card":`notifications-sounds`,title:e(`config:notificationSounds.title`),description:e(`config:notificationSounds.description`),children:[(0,Q.jsx)(X,{title:e(`config:notificationSounds.enabled`),control:(0,Q.jsx)(st,{checked:t.enabled,"aria-label":e(`config:notificationSounds.enabled`),onCheckedChange:e=>t.update({enabled:e})})}),wn.map(n=>{let r=t.sounds[n];return(0,Q.jsx)(X,{"data-sound-event":n,title:Ho(e,n),description:Uo(e,n),control:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(Y,{value:r,className:`w-32`,"aria-label":Ho(e,n),disabled:!t.enabled,onChange:e=>{let r=e.target.value;t.setSound(n,r),a(r)},children:[(0,Q.jsx)(`option`,{value:`none`,children:e(`config:notificationSounds.soundNone`)}),bn.map(t=>(0,Q.jsx)(`option`,{value:t,children:Vo(e,t)},t))]}),(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`pointer-coarse:size-11`,disabled:!t.enabled||r===`none`,"aria-label":e(`config:notificationSounds.preview`,{event:Ho(e,n)}),title:e(`config:notificationSounds.preview`,{event:Ho(e,n)}),onClick:()=>a(r),children:(0,Q.jsx)(ue,{"aria-hidden":`true`})})]})},n)}),(0,Q.jsx)(X,{title:e(`config:notificationSounds.volume`),control:(0,Q.jsxs)(`div`,{className:`flex w-48 items-center gap-3`,children:[(0,Q.jsx)(ot,{min:0,max:100,step:5,value:[i],disabled:!t.enabled,"aria-label":e(`config:notificationSounds.volume`),valueText:`${i}%`,onValueChange:([e])=>r(e),onValueCommit:([e])=>{r(null),t.update({volume:e});let n=t.sounds.waiting;n!==`none`&&_n(n,e)}}),(0,Q.jsxs)(`span`,{className:`w-9 text-right text-xs text-content-muted tabular-nums`,children:[i,`%`]})]})}),(0,Q.jsx)(X,{title:e(`config:notificationSounds.whileFocused`),description:e(`config:notificationSounds.whileFocusedHint`),control:(0,Q.jsx)(st,{checked:t.whileFocused,disabled:!t.enabled,"aria-label":e(`config:notificationSounds.whileFocused`),onCheckedChange:e=>t.update({whileFocused:e})})})]})}function Go(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 Ko(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 qo(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 Jo(){return typeof window<`u`&&window.pisperDesktop?.showNotification?window.pisperDesktop.getNotificationStatus?`checking`:`granted`:typeof window<`u`&&Cn()?`checking`:Pn()}function Yo(e,t){return t(e===`system-disabled`||e===`app-disabled`?`config:notificationSettings.systemNotificationsAreOffAllowPisperToSendNotificationsInYourOperatingSystemSettings`:e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.theOperatingSystemDidNotAcceptTheNotificationCheckYourSystemNotificationSettings`)}function Xo(e){return e instanceof Error?e.message:String(e)}function Zo({notify:e,onBrowserNotificationChange:t}){let{t:r,language:i}=u(),a=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let o=Ro(t),{data:s,loading:c,loadError:l}=o,[d,f]=n(),p=!!window.pisperDesktop?.showNotification,m=Cn(),[h,g]=(0,Z.useState)(Jo),_=o.mutations.browser?.pending===!0,v=(0,Z.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,Z.useEffect)(()=>{if(!p)return;v();let e=()=>{v()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[p,v]);let y=(0,Z.useCallback)(async()=>{if(!(p||!m))try{let e=await yn();if(!a.current)return;g(e===!0?`granted`:e===!1?`denied`:`default`)}catch{a.current&&g(`unsupported`)}},[p,m]);(0,Z.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=Yo(`system-disabled`,r);else if(!p&&m){let e=`denied`;try{let t=await yn()===!0?`granted`:await xn();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 Nn();if(!a.current)return;if(g(e),e!==`granted`)n=r(e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`);else try{await Fn()}catch{n=r(`config:notificationSettings.theBrowserBackgroundNotificationServiceCouldNotBeRegistered`)}}}a.current&&(await o.setBrowserEnabled(t),n&&a.current&&e(n,`info`))},x=(0,Z.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(Yo(i.reason,r));return i}return m?(await hn(e,t),{shown:!0,transport:`tauri`}):Mn({title:e,body:t,tag:n,url:window.location.href})},[p,m,r]),C=async()=>{if(!(!o.confirmed?.browser.enabled||_)){if(h!==`granted`){e(h===`unsupported`?Yo(`unsupported`,r):p?Yo(`system-disabled`,r):r(`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`),`error`);return}try{await x(r(`config:notificationSettings.appNotificationTest`,{app:we}),r(`config:notificationSettings.notificationsAreWorking`)),e(r(`config:notificationSettings.theTestNotificationWasSentCheckYourSystemNotificationCenter`),`info`)}catch(t){e(Xo(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,Q.jsxs)(on,{children:[(0,Q.jsx)(V,{className:`size-6`}),(0,Q.jsx)(`h2`,{children:r(`config:notificationSettings.loadingNotificationSettings`)})]});if(!s)return(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(tn,{children:l}),(0,Q.jsx)(H,{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`,O=s.templates.map(e=>({...e,name:Ko(e.id,e.name,r),description:qo(e.id,e.description,r)}));if(E)return(0,Q.jsxs)(`div`,{"data-config-card":`notifications-templates`,className:`space-y-4`,children:[(0,Q.jsxs)(H,{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,Q.jsx)(D,{size:16,"aria-hidden":`true`}),r(`config:notificationSettings.backToCategories`)]}),(0,Q.jsx)(Bo,{settings:o,templates:O,eventId:d.get(`event`)||``,platform:wo.find(e=>e===d.get(`channel`))||`browser`,onSelectionChange:T,platformLabel:e=>Go(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,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[l&&(0,Q.jsx)(tn,{children:l}),Object.entries(o.mutations).filter(([,e])=>e.error).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(tn,{children:t.error}),(0,Q.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>void o.retryMutation(t),children:r(`common:pageTemplate.retry`)})]},e)),(0,Q.jsxs)(hi,{className:`browser-notification-card py-4`,"data-config-card":`notifications-browser`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:B(`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,Q.jsx)(S,{size:18}):(0,Q.jsx)(In,{size:18})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-content`,children:r(`config:notificationSettings.systemNotificationChannel`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs leading-[1.45] text-content-muted`,children:r(`config:notificationSettings.pisperUsesTheCurrentPlatformNotificationSystemWhenAnAgentCompletesOrFails`)})]}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[(0,Q.jsx)(_i,{tone:A,children:k}),(0,Q.jsx)(vi,{ariaLabel:r(`config:notificationSettings.systemNotificationChannel`),value:s.browser.enabled,disabled:_||h===`checking`,onChange:b})]})]}),(0,Q.jsxs)(en,{children:[(0,Q.jsx)(_e,{size:15}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:r(p?`config:notificationSettings.controlledByOperatingSystemNotificationSettings`:`config:notificationSettings.controlledByBrowserSitePermissions`)}),(0,Q.jsx)(`small`,{children:r(p?`config:notificationSettings.theDesktopAppUsesOperatingSystemNotificationsTurningThisOffDoesNotChangeTheOperatingSystemPermis`:`config:notificationSettings.theWebAppUsesBrowserSiteNotificationsTurningThisOffDoesNotChangeTheBrowserPermissionItself`)})]})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex gap-2 max-[650px]:flex-wrap`,children:[p&&h===`denied`&&(0,Q.jsxs)(H,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:w,children:[(0,Q.jsx)(_e,{size:14}),r(`config:notificationSettings.openSystemNotificationSettings`)]}),(0,Q.jsxs)(H,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:!s.browser.enabled||_||h!==`granted`,onClick:C,children:[(0,Q.jsx)(S,{size:14}),r(`config:notificationSettings.sendTestNotification`)]})]})]}),(0,Q.jsx)(Wo,{}),(0,Q.jsxs)(Zt,{title:r(`config:notificationSettings.notificationCategories`),description:r(`config:notificationSettings.channelPreferenceHint`),action:(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,className:`pointer-coarse:h-11`,onClick:()=>T(),children:r(`config:notificationSettings.editNotificationTemplates`)}),children:[!o.supportsChannels&&(0,Q.jsx)(`p`,{role:`status`,className:`py-2 text-sm text-content-muted`,children:r(`config:notificationSettings.channelPreferencesUnsupported`)}),O.length>0&&(0,Q.jsx)(yi,{children:O.map(e=>{let t=e.enabled?wo.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,Q.jsx)(X,{"data-notification-event":e.id,title:e.name,description:e.description,control:(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(Je,{asChild:!0,children:(0,Q.jsx)(H,{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,Q.jsx)(`span`,{className:`max-w-64 truncate`,children:t.length?t.map(e=>Go(e,r)).join(i===`zh-CN`?`、`:`, `):r(`config:notificationSettings.channelsOff`)})})}),(0,Q.jsxs)(Ye,{align:`end`,className:`max-w-[calc(100vw-40px)] min-w-56`,children:[(0,Q.jsx)(qe,{checked:e.enabled,onCheckedChange:t=>void o.setEventEnabled(e.id,t===!0),children:r(`config:notificationSettings.enableEvent`)}),(0,Q.jsx)(Ge,{}),wo.map(t=>{let n=t===`browser`?s.browser.enabled:s.connections[t]?.enabled===!0&&s.scopes.some(e=>e.platform===t);return(0,Q.jsxs)(qe,{checked:e.channels[t]?.enabled!==!1,disabled:!o.supportsChannels,onCheckedChange:n=>void o.setChannelEnabled(e.id,t,n===!0),children:[(0,Q.jsx)(`span`,{children:Go(t,r)}),!n&&(0,Q.jsx)(`small`,{className:`ml-2 text-muted-foreground`,children:r(`config:notificationSettings.channelNeedsSetup`)})]},t)}),(0,Q.jsx)(Ge,{}),(0,Q.jsx)(Ke,{onSelect:()=>T(e.id),children:r(`config:notificationSettings.editNotificationTemplates`)})]})]})},e.id)})}),!O.length&&(0,Q.jsx)(`p`,{role:`status`,className:`py-3 text-sm text-content-muted`,children:r(`config:notificationSettings.noNotificationEvents`)})]})]})}function Qo({notify:e}){let{t}=u(),n=window.pisperDesktop,[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``);(0,Z.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 l=!!(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=l&&!r,m=l?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,Q.jsxs)(K,{"data-config-card":`updates-cli`,title:t(`config:cliSettings.title`),description:t(`config:cliSettings.description`),actions:(0,Q.jsx)(`span`,{className:`text-xs text-content-secondary`,children:m}),children:[r&&(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3 border-t border-stroke py-3`,children:[r.installed&&!r.needsRepair?(0,Q.jsx)(A,{className:`mt-0.5 shrink-0 text-content-muted`,size:16,"aria-hidden":`true`}):(0,Q.jsx)(Xn,{className:`mt-0.5 shrink-0 text-content-muted`,size:16,"aria-hidden":`true`}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-0.5`,children:[(0,Q.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,Q.jsx)(`small`,{className:`font-mono text-xs [overflow-wrap:anywhere] text-content-muted`,children:r.installPath}),r.installed&&(0,Q.jsx)(`small`,{className:`text-xs text-content-muted`,children:r.pathConfigured?t(`config:cliSettings.pathConfigured`):t(`config:cliSettings.pathNeedsRepair`)})]})]}),s&&(0,Q.jsx)(q,{children:s}),l&&(0,Q.jsxs)(`div`,{className:`mt-3 flex gap-2 max-[650px]:flex-wrap`,children:[r?.installed&&(0,Q.jsxs)(H,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:!!a,onClick:()=>void f(),children:[a===`uninstall`?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(be,{size:14}),t(`config:cliSettings.uninstall`)]}),(!r?.installed||r.needsRepair)&&(0,Q.jsxs)(H,{type:`button`,className:`max-[650px]:h-11`,disabled:!!a||p||r?.supported===!1,onClick:()=>void d(),children:[a===`install`?(0,Q.jsx)(V,{className:`text-current`}):r?.needsRepair?(0,Q.jsx)(Se,{size:14}):(0,Q.jsx)(N,{size:14}),r?.needsRepair?t(`config:cliSettings.repair`):t(`config:cliSettings.install`)]})]}),l&&(0,Q.jsx)(`small`,{className:`mt-2 block text-xs text-content-muted`,children:t(`config:cliSettings.restartTerminal`)})]})}var $o=`0.6.41`;function es(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 ts(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 ns({notify:e,update:t}){let{t:n,language:r}=u(),i=t?.info||{desktop:!1,packaged:!1,version:$o,platform:`browser`,arch:``},a=t?.status||{state:`idle`},o=!!i.desktop,s=!!i.mobile,c=o||s,[l,d]=(0,Z.useState)({version:$o,date:``,notes:``}),[f,p]=(0,Z.useState)(``);(0,Z.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(t,n)=>{p(t);try{await n()}catch(t){e(t instanceof Error?t.message:String(t),`error`)}finally{p(``)}},h=()=>m(`check`,()=>t.check()),g=()=>m(`download`,()=>t.download()),_=()=>m(`install`,()=>t.install()),v=()=>t?.openReleases(),y=()=>t?.openUpdateLog?.(),b=o?t.shellInstaller:null,x=l.version===i.version?l:null,S=a.notes||(c?x?.notes||n(`config:updateSettings.noReleaseNotesAreAvailableForThisVersion`):a.state===`current`?n(`config:updateSettings.theCurrentWebSourceIsSyncedWithBranch`,{branch:a.branch||`release`}):n(`config:updateSettings.commitsThatHaveNotBeenSyncedWillAppearHereAfterTheCheck`)),C=a.rateLimited?a.retryAt?n(`config:updateSettings.githubRateLimitedUntil`,{time:new Intl.DateTimeFormat(r,{timeStyle:`short`}).format(new Date(a.retryAt*1e3))}):n(`config:updateSettings.githubRateLimited`):``,w=a.state===`unsupported`,T=a.state===`available`,E=a.state===`error`&&a.canResume&&a.canDownload,D=o&&a.state===`error`&&a.canDownload,O=a.state===`downloaded`,k=a.state===`checking`||f===`check`,j=a.state===`downloading`,M=f===`install`,P=k?`checking`:a.state,I=a.availableVersion?`v${a.availableVersion}`:``,L=c?`v${i.version}`:`v${i.version}${a.currentCommit?` · ${a.currentCommit.slice(0,7)}`:``}`,ee=c?`v${a.availableVersion||x?.version||i.version}`:a.availableCommit?.slice(0,7)||a.currentCommit?.slice(0,7)||l.version||i.version,te={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`),unsupported:n(`config:updateSettings.manualUpdateOnly`),error:n(E?`config:updateSettings.downloadPaused`:`config:updateSettings.checkFailed`)}[P]||n(`config:updateSettings.notChecked`),ne=w?n(`config:updateSettings.desktopNeedsReinstall`):o&&O?a.installKind===`installer`?n(`config:updateSettings.installerReadyHint`):n(`config:updateSettings.restartToUpdateHint`):``;return(0,Q.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col`,children:[(0,Q.jsxs)(K,{"data-config-card":`updates-main`,className:`mt-6`,title:n(`config:updateSettings.pisperAppUpdates`),actions:(0,Q.jsx)(`span`,{"data-update-status":P,className:`text-xs text-content-secondary tabular-nums`,children:te}),children:[(0,Q.jsxs)(`dl`,{className:`grid border-y border-stroke max-sm:divide-y max-sm:divide-stroke-soft sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`py-3 sm:pr-4`,children:[(0,Q.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(c?`config:updateSettings.currentVersion`:`config:updateSettings.currentSource`)}),(0,Q.jsx)(`dd`,{className:`mt-1 font-mono text-[12.5px] font-medium text-content`,children:L})]}),(0,Q.jsxs)(`div`,{className:`py-3 sm:border-l sm:border-stroke-soft sm:px-4`,children:[(0,Q.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(`config:updateSettings.platform`)}),(0,Q.jsx)(`dd`,{className:`mt-1 text-sm font-medium text-content`,children:es(i,n)})]}),(0,Q.jsxs)(`div`,{className:`py-3 sm:border-l sm:border-stroke-soft sm:pl-4`,children:[(0,Q.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(`config:updateSettings.updateChannel`)}),(0,Q.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,Q.jsx)(q,{children:C||a.message}):(0,Q.jsxs)(`p`,{className:`mt-4 flex items-start gap-2 text-sm text-content-secondary`,children:[(0,Q.jsx)(R,{className:`mt-0.5 shrink-0 text-content-muted`,size:15,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0`,children:a.message})]})),ne&&(0,Q.jsxs)(`p`,{className:`mt-4 flex items-start gap-2 text-sm text-content-secondary`,children:[(0,Q.jsx)(R,{className:`mt-0.5 shrink-0 text-content-muted`,size:15,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0`,children:ne})]}),E&&(0,Q.jsx)(`small`,{className:`mt-2 block text-xs text-content-muted`,children:n(`config:updateSettings.downloadedDataWasPreservedAndCanResumeFromTheInterruptionPoint`)}),j&&(0,Q.jsxs)(`div`,{className:`mt-4`,children:[(0,Q.jsxs)(`div`,{className:`flex justify-between text-xs text-content-muted`,children:[(0,Q.jsx)(`span`,{children:n(`config:updateSettings.downloadProgress`)}),(0,Q.jsx)(`span`,{className:`tabular-nums`,children:a.total?`${Math.round(a.percent||0)}% · ${ts(a.transferred,r)} / ${ts(a.total,r)}`:ts(a.transferred,r)})]}),(0,Q.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-surface-active`,children:(0,Q.jsx)(`i`,{className:`block h-full bg-star transition-[width]`,style:{width:`${a.percent||0}%`}})})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[!w&&(0,Q.jsxs)(H,{className:`max-[650px]:h-11`,disabled:k||j||!!f,onClick:O?_:T||E||D?g:h,children:[k||j||M?(0,Q.jsx)(V,{className:`text-current`}):O?(0,Q.jsx)(pe,{size:14}):T||E||D?a.canDownload?(0,Q.jsx)(N,{size:14}):(0,Q.jsx)(F,{size:14}):(0,Q.jsx)(fe,{size:14}),k?n(`config:updateSettings.checking2`):j?n(`config:updateSettings.downloadingUpdate`):O?o?a.installKind===`installer`?n(`config:updateSettings.installVersion`,{version:I}):n(`config:updateSettings.restartAndUpdate`,{version:I}):n(`config:updateSettings.restartAndInstall`):E?n(`config:updateSettings.resumeDownload`):D?n(`config:updateSettings.retryDownload`):T?a.canDownload?n(`config:updateSettings.downloadUpdate`):n(c?`config:updateSettings.viewRelease`:`config:updateSettings.viewSourceUpdates`):n(`config:updateSettings.checkForUpdates`)]}),(0,Q.jsxs)(H,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:v,children:[(0,Q.jsx)(F,{size:14}),c?`GitHub Releases`:`GitHub Compare`]}),o&&(0,Q.jsxs)(H,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:y,children:[(0,Q.jsx)(F,{size:14}),n(`config:updateSettings.viewUpdateDiagnosticLog`)]})]}),b&&(0,Q.jsx)(G,{className:`mt-4`,children:(0,Q.jsx)(W,{icon:(0,Q.jsx)(N,{}),name:n(`config:updateSettings.autoDownload`),description:n(`config:updateSettings.autoDownloadHint`),actions:(0,Q.jsx)(st,{checked:b.status.autoDownload,disabled:f===`toggle`,onCheckedChange:e=>void m(`toggle`,()=>b.setAutoDownload(e)),"aria-label":n(`config:updateSettings.autoDownload`)})})})]}),!s&&(0,Q.jsx)(Qo,{notify:e}),(0,Q.jsx)(K,{title:n(c?T||E||O||j?`config:updateSettings.newVersionReleaseNotes`:`config:updateSettings.currentReleaseNotes`:T?`config:updateSettings.commitsToSync`:`config:updateSettings.currentSourceStatus`),meta:(a.releaseDate||c&&x?.date)&&new Intl.DateTimeFormat(r,{dateStyle:`long`}).format(new Date(a.releaseDate||x?.date||``)),actions:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-xs text-content-muted`,children:[(0,Q.jsx)(A,{size:13,"aria-hidden":`true`}),T||E||O||j?ee:c?`v${x?.version||i.version}`:a.currentCommit?.slice(0,7)||n(`config:updateSettings.notChecked`)]}),children:(0,Q.jsx)(`div`,{className:`border-t border-stroke pt-3`,children:(0,Q.jsx)(Yt,{children:S})})})]})}function rs(e,t){switch(t){case`interface`:return e(`config:settingsShell.lede.interface`);case`notifications`:return e(`config:settingsShell.lede.notifications`);case`shortcuts`:return e(`config:settingsShell.lede.shortcuts`);case`updates`:return e(`config:settingsShell.lede.updates`);case`labs`:return e(`config:settingsShell.lede.labs`);case`about`:return e(`config:settingsShell.lede.about`);default:return e(`config:settingsShell.lede.models`)}}function is({notify:e,registerPrimaryAction:t,invokePrimaryAction:n,section:r,onBackToFeatures:i,onBrowserNotificationChange:a,requestConfirm:o,update:s,renderInterfaceSettings:c}){let{t:l}=u(),d=ft(r);if(r===`remote-access`||r===`mobile-server`||r===`desktop-pet`)return(0,Q.jsx)(ia,{section:r,notify:e,requestConfirm:o,onBack:i});let f=I(r)?r:`models`,p;if(f===`notifications`)p=(0,Q.jsx)(Zo,{notify:e,onBrowserNotificationChange:a});else if(f===`interface`){let t=(0,Q.jsx)(ga,{notify:e,defaultAdvancedExpanded:d?.expandGroup===`interface-advanced`,navigationKey:d?.navigationKey});p=c?c(t):t}else p=f===`shortcuts`?(0,Q.jsx)(_a,{requestConfirm:o}):f===`updates`?(0,Q.jsx)(ns,{notify:e,update:s}):f===`labs`?(0,Q.jsx)(mi,{notify:e}):f===`about`?(0,Q.jsx)(Ti,{update:s,notify:e}):(0,Q.jsx)(Co,{defaultAdvancedExpanded:d?.expandGroup===`models-advanced`,navigationKey:d?.navigationKey,notify:e,registerPrimaryAction:t,requestConfirm:o});let m=l(`navigation:pageHeader.quickSetup`);return(0,Q.jsx)(qt,{"data-settings-page":f,title:L(l,f),description:rs(l,f),toolbar:f===`models`?(0,Q.jsx)(Jt,{actions:(0,Q.jsxs)(H,{variant:`outline`,"data-settings-quick-setup":!0,onClick:n,children:[(0,Q.jsx)(de,{className:`size-4`,"aria-hidden":`true`}),m]})}):void 0,children:(0,Q.jsx)(`div`,{"data-config-card":pt,className:`mt-6 min-w-0 max-[650px]:mt-3`,children:p})})}export{is as ConfigPage};
|
|
7
|
+
`);b(Object.fromEntries(so.map((t,n)=>[t,e[n]]).filter(([,e])=>e)))},[v]),(0,Z.useEffect)(()=>{let e=!0;return co.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:`${Pt(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),l(!0),f(``);try{r(await co.saveModelTiers(o)),t(i(`config:subagents.tiersSaved`))}catch(e){b(a),f(e instanceof Error?e.message:String(e))}finally{l(!1)}},w=so.filter(e=>y[e]).length,T=p?.profiles||[],E=p?.errors||[];return(0,Q.jsx)(`section`,{"aria-labelledby":`${s}-heading`,"aria-busy":c||void 0,"data-config-card":`models-subagents`,"data-config-target":`models-subagents`,className:`min-w-0 border-t border-stroke`,children:(0,Q.jsx)(ro,{type:`single`,collapsible:!0,children:(0,Q.jsxs)(io,{value:`subagents`,children:[(0,Q.jsx)(ao,{children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,Q.jsx)(`span`,{id:`${s}-heading`,children:i(`config:subagents.title`)}),(0,Q.jsx)(`span`,{className:`truncate text-xs font-normal text-content-muted`,children:w?i(`config:subagents.configuredSummary`,{count:w}):i(`config:subagents.followSession`)})]})}),(0,Q.jsxs)(oo,{className:`h-auto`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`config:subagents.hint`)}),(0,Q.jsx)(`div`,{className:`mt-3 border-t border-stroke`,children:so.map(e=>{let t=y[e]||``;return(0,Q.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,Q.jsxs)(`div`,{className:`min-w-[min(240px,100%)] flex-1`,children:[(0,Q.jsxs)(`div`,{id:`${s}-${e}`,className:`text-sm text-content`,children:[a(e),(0,Q.jsx)(`code`,{className:`ml-2 font-mono text-xs text-content-muted`,children:e})]}),(0,Q.jsx)(`p`,{id:`${s}-${e}-hint`,className:`mt-0.5 text-xs text-content-muted`,children:o(e)})]}),(0,Q.jsx)(`div`,{className:`w-[min(280px,100%)] min-w-0 max-[650px]:w-full`,children:(0,Q.jsxs)(Y,{"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,Q.jsx)(`option`,{value:``,children:i(`config:subagents.followSession`)}),t&&!S.some(e=>e.value===t)&&(0,Q.jsx)(`option`,{value:t,children:t}),S.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value))]})})]},e)})}),d&&(0,Q.jsx)(q,{children:d}),(0,Q.jsx)(`h3`,{className:`mt-5 text-[13px] font-medium text-content`,children:i(`config:subagents.globalDefinitions`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-content-muted`,children:i(`config:subagents.definitionsHint`)}),p===null?(0,Q.jsxs)(`p`,{role:`status`,className:`mt-3 flex items-center gap-2 text-xs text-content-muted`,children:[(0,Q.jsx)(V,{className:`size-3`}),i(`config:subagents.loading`)]}):T.length===0&&E.length===0?(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-content-muted`,children:i(`config:subagents.empty`)}):(0,Q.jsxs)(`ul`,{className:`mt-3 flex min-w-0 flex-col border-t border-stroke`,children:[T.map(e=>(0,Q.jsxs)(`li`,{className:`min-w-0 border-b border-stroke py-2 text-[13px]`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`code`,{className:`shrink-0 font-mono text-content`,children:e.name}),(0,Q.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,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-content-secondary`,children:e.description})]},e.name)),E.map(e=>(0,Q.jsxs)(`li`,{className:`min-w-0 border-b border-stroke py-2 text-[13px]`,children:[(0,Q.jsx)(`code`,{className:`font-mono text-danger`,children:e.file||e.scope}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-danger`,children:e.message})]},`${e.scope}:${e.file}`))]}),h&&(0,Q.jsx)(q,{children:h})]})]})})})}function uo(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)||e}function fo({notify:e}){let{t}=u(),n=(0,Z.useId)(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[l,d]=(0,Z.useState)(`allow`),[f,p]=(0,Z.useState)(`bash`),[m,h]=(0,Z.useState)(``);(0,Z.useEffect)(()=>{let e=!0;return un.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(()=>un.add({effect:l,tool:f,pattern:e}),t(`config:permissionRules.added`))&&h(``)};return(0,Q.jsx)(`section`,{"aria-labelledby":`${n}-heading`,"data-config-card":`models-permission-rules`,"data-config-target":`models-permission-rules`,className:`min-w-0 border-b border-stroke`,children:(0,Q.jsx)(ro,{type:`single`,collapsible:!0,children:(0,Q.jsxs)(io,{value:`rules`,children:[(0,Q.jsx)(ao,{children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,Q.jsx)(`span`,{id:`${n}-heading`,children:t(`config:permissionRules.title`)}),(0,Q.jsx)(`span`,{className:`truncate text-xs font-normal text-content-muted`,children:r===null?``:r.length?t(`config:permissionRules.countSummary`,{count:r.length}):t(`config:permissionRules.noneSummary`)})]})}),(0,Q.jsxs)(oo,{className:`h-auto`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:t(`config:permissionRules.hint`)}),r===null?(0,Q.jsxs)(`p`,{role:`status`,className:`mt-3 flex items-center gap-2 text-xs text-content-muted`,children:[(0,Q.jsx)(V,{className:`size-3`}),t(`config:permissionRules.loading`)]}):r.length===0?(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-content-muted`,children:t(`config:permissionRules.empty`)}):(0,Q.jsx)(`ul`,{className:`mt-3 flex min-w-0 flex-col border-t border-stroke`,children:r.map(e=>(0,Q.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 border-b border-stroke py-2 text-[13px]`,children:[(0,Q.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,Q.jsx)(`span`,{className:`shrink-0 text-xs text-content-muted`,children:e.tool===`files`?t(`config:permissionRules.files`):t(`config:permissionRules.command`)}),(0,Q.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-content`,title:e.pattern,children:e.pattern}),(0,Q.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate text-xs text-content-muted`,title:e.cwd||void 0,children:e.cwd?uo(e.cwd):t(`config:permissionRules.global`)}),(0,Q.jsx)(H,{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(()=>un.remove(e.id),t(`config:permissionRules.removed`)),children:(0,Q.jsx)(be,{})})]},e.id))}),(0,Q.jsxs)(`form`,{className:`mt-3 flex min-w-0 flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,Q.jsxs)(Y,{"aria-label":t(`config:permissionRules.effectLabel`),className:`w-28`,disabled:s,value:l,onChange:e=>{let t=e.target.value===`deny`?`deny`:`allow`;d(t),t===`deny`&&p(`bash`)},children:[(0,Q.jsx)(`option`,{value:`allow`,children:t(`config:permissionRules.allow`)}),(0,Q.jsx)(`option`,{value:`deny`,children:t(`config:permissionRules.deny`)})]}),(0,Q.jsxs)(Y,{"aria-label":t(`config:permissionRules.toolLabel`),className:`w-32`,disabled:s||l===`deny`,value:f,onChange:e=>p(e.target.value===`files`?`files`:`bash`),children:[(0,Q.jsx)(`option`,{value:`bash`,children:t(`config:permissionRules.command`)}),(0,Q.jsx)(`option`,{value:`files`,children:t(`config:permissionRules.files`)})]}),(0,Q.jsx)(U,{"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,Q.jsxs)(H,{type:`submit`,variant:`secondary`,disabled:s||!m.trim(),className:`max-[650px]:min-h-11`,children:[s&&(0,Q.jsx)(V,{className:`size-3`}),t(`config:permissionRules.add`)]})]}),a&&(0,Q.jsx)(q,{children:a})]})]})})})}function po(e){return e instanceof Error?e.message:String(e)}function mo({notify:e,requestConfirm:t,t:n}){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!0),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(``),v=(0,Z.useRef)(0),y=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{let e=!0;y.current=!0;let t=v.current;return p(`/api/config`).then(n=>{if(e)return v.current===t&&i(n),o(!1),p(`/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(po(n)),o(!1))}),()=>{e=!1,y.current=!1,v.current+=1}},[]);let b=(0,Z.useCallback)(e=>{v.current+=1,i(e),o(!1),c(``)},[]),x=(0,Z.useCallback)(async()=>{let e=v.current,t=await p(`/api/config`);y.current&&v.current===e&&b(t)},[b]),S=(0,Z.useCallback)(async(t,r)=>{u(t.id),c(``);try{let i=await p(`/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(po(e))}finally{u(``)}},[b,e,n]),C=(0,Z.useCallback)(async t=>{f(t.id),c(``);try{let r=await p(`/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(po(e))}finally{f(``)}},[b,e,n]),w=(0,Z.useCallback)(async(t,r)=>{h(t.id),c(``);try{let i=await p(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:t.id,model:r,setAsDefault:!1})});b(i),e(n(`config:configPage.providerConnectionUpdated`))}catch(e){c(po(e))}finally{h(``)}},[b,e,n]),T=(0,Z.useCallback)(async(t,r)=>{f(t.id),c(``);try{let i=await p(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:t.id,model:r,setAsDefault:!1})});(i.defaultProvider||i.provider)!==t.id&&(i=await p(`/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(po(e))}finally{f(``)}},[b,e,n]),E=(0,Z.useCallback)(async()=>{o(!0),c(``);let e=v.current;try{let t=await p(`/api/config`);y.current&&v.current===e&&b(t)}catch(e){y.current&&c(po(e))}finally{y.current&&o(!1)}},[b]),D=(0,Z.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 wa.deleteModel(r.id,i.id)),e(n(`providers:modelEditor.deleted`))}catch(e){c(po(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,Z.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 p(`/api/providers/${encodeURIComponent(r.id)}`,{method:`DELETE`});b(t),e(n(`config:configPage.providerConnectionDeleted`))}catch(e){c(po(e))}}},[b,e,t,n]),deleteModel:D}}function ho({requestConfirm:e,onImported:t,onAutoImported:n,t:r}){let[i,a]=(0,Z.useState)({providers:[],errors:[]}),[o,s]=(0,Z.useState)(!0),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(``),[f,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)({imported:0,skipped:0}),_=(0,Z.useRef)(0),v=(0,Z.useRef)(n);v.current=n;let y=(0,Z.useCallback)(async()=>{let e=++_.current;s(!0),l(``);try{let t=await wa.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(po(t))}finally{e===_.current&&s(!1)}},[]);return(0,Z.useEffect)(()=>(y(),()=>{_.current+=1}),[y]),{discovery:i,autoImport:h,discovering:o,error:c,operationError:u,importing:f,refresh:y,importProvider:(0,Z.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 p(`/api/providers/${encodeURIComponent(n.id)}/import`,{method:`POST`,body:`{}`});a(e.discovery),t(e)}catch(e){d(po(e))}finally{m(``)}}},[t,e,r])}}function go({providers:e,defaultProviderId:t=``,toggling:n,settingDefault:r=``,settingModel:i=``,onConfigure:a,onClone:o,onSetDefault:s,onSetDefaultModel:c,onToggle:l,onDelete:d}){let{t:f}=u(),p=e.filter(e=>e.configured||e.custom);return(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:p.map(e=>{let u=Ca[e.id]||ge,p=e.id===t,m=e.configured?e.enabled?f(`config:configPage.authenticationReady`):f(`config:configPage.disabled2`):e.id===`openai-codex`?f(`config:configPage.codexCLILoginRequired`):f(`config:configPage.apiKeyRequired`);return(0,Q.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,Q.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,Q.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,Q.jsx)(u,{size:15})}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),p&&(0,Q.jsx)($t,{variant:`accent`,children:f(`config:configPage.defaultBadge`)})]}),c&&e.models.some(e=>e.kind===`chat`)?(0,Q.jsxs)(`label`,{className:`grid min-w-0 gap-1 text-xs text-content-muted`,children:[f(`config:configPage.providerDefaultModel`),(0,Q.jsxs)(Y,{"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,Q.jsx)(`option`,{value:e.defaultModel||``,disabled:!0,children:e.defaultModel||f(`config:configPage.selectModel`)}),e.models.filter(e=>e.kind===`chat`).map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}):e.defaultModel?(0,Q.jsxs)(`small`,{className:`truncate font-mono text-xs text-content-muted`,title:e.defaultModel,children:[f(`config:configPage.providerDefaultModel`),`: `,e.defaultModel]}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`small`,{className:`text-xs text-content-muted`,children:m}),(0,Q.jsxs)(`div`,{className:`flex flex-none items-center gap-1.5`,children:[s&&(0,Q.jsx)(H,{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,Q.jsx)(Jn,{size:13})}),(0,Q.jsx)(H,{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,Q.jsx)(M,{size:13})}),(0,Q.jsx)(vi,{ariaLabel:f(`config:configPage.providerEnabled`,{name:e.name}),value:e.configured&&e.enabled,disabled:!e.configured||n===e.id,onChange:t=>l(e,t)}),e.custom&&(0,Q.jsx)(H,{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,Q.jsx)(be,{size:13})})]})]})]},e.id)})})}var _o=`pisper.config.visualConnectionsOpen`,vo={running:null,result:null,error:``};function yo(){return i.getItem(_o)===`1`}function bo({config:e,notify:t,toggling:n,onToggleProvider:r,onDeleteProvider:a,onCloneProvider:o,onQuickSetup:s,onEditVisualProvider:c}){let{t:l}=u(),[d,f]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!0),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(``),[w,D]=(0,Z.useState)(yo),O=(0,Z.useCallback)(async()=>{try{f(await p(`/api/visual/models`)),C(``)}catch(e){C(e instanceof Error?e.message:String(e))}finally{h(!1)}},[]);(0,Z.useEffect)(()=>{O()},[O,e]),(0,Z.useEffect)(()=>{vo.result&&x(vo.result),vo.error&&C(vo.error);let e=vo.running;if(!e)return;y(!0);let t=!0;return e.then(e=>{t&&x(e)}).catch(()=>{t&&C(vo.error)}).finally(()=>{t&&y(!1)}),()=>{t=!1}},[]);let j=async(e,n)=>{_(e),C(``);try{f(await p(`/api/visual/models/${e}`,{method:`PUT`,body:JSON.stringify({model:n})})),t(l(`config:configPage.visualModelUpdated`))}catch(e){C(e instanceof Error?e.message:String(e))}finally{_(``)}},M=async()=>{if(vo.running)return;y(!0),C(``),x(null),vo.result=null,vo.error=``;let e=p(`/api/visual/test`,{method:`POST`,body:`{}`,timeout:21e4});vo.running=e;try{let n=await e;vo.result=n,x(n),t(l(`config:configPage.testSucceeded`))}catch(e){let n=e instanceof Error?e.message:String(e);vo.error=n,C(n),t(n)}finally{vo.running=null,y(!1)}},N=e=>{D(e),i.setItem(_o,e?`1`:`0`)},P=e.providers.filter(e=>e.type===`visual`),F=P.filter(e=>e.configured||e.custom),I=d?.imageModels||[],L=d?.videoModels||[];return(0,Q.jsxs)(`section`,{className:`mt-3`,children:[(0,Q.jsxs)(hi,{className:`mb-3 py-3.5`,"data-config-card":`models-visual`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:B(`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,Q.jsx)(ye,{size:18})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-content-muted`,children:l(`config:configPage.currentVisualModel`)}),m?(0,Q.jsxs)(`span`,{role:`status`,className:`flex items-center gap-2 text-xs text-content-muted`,children:[(0,Q.jsx)(V,{className:`size-3.5`}),l(`config:configPage.loadingVisualStatus`)]}):d?.image?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`truncate text-sm font-medium text-content`,children:[d.image.providerName,` / `,d.image.name]}),(0,Q.jsxs)(_i,{tone:`green`,children:[(0,Q.jsx)(A,{size:11,className:`mr-[3px] inline`}),l(`config:configPage.authenticationReady`)]})]}),d.video&&(0,Q.jsxs)(`small`,{className:`text-xs text-content-muted [overflow-wrap:anywhere]`,children:[l(`config:configPage.visualVideoModel`),`:`,d.video.providerName,` /`,` `,d.video.name]})]}):(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-warning-strong`,children:[(0,Q.jsx)(k,{size:14,"aria-hidden":`true`}),l(`config:configPage.visualNoneConfigured`)]}),(0,Q.jsx)(`small`,{className:`text-xs text-content-muted`,children:l(`config:configPage.visualEmptyHint`)})]})]}),(0,Q.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,Q.jsxs)(H,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:v,onClick:()=>void M(),children:[v?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(ee,{size:13}),l(v?`config:configPage.testingGeneration`:`config:configPage.testGeneration`)]}),(0,Q.jsxs)(H,{className:`max-[650px]:h-11`,onClick:s,children:[(0,Q.jsx)(Qn,{size:13}),l(`config:configPage.visualQuickSetup`)]})]})]}),b&&(0,Q.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,Q.jsx)(`img`,{src:b.previewDataUrl,alt:b.modelName,className:`size-11 flex-none rounded-xs object-cover`}):(0,Q.jsx)(T,{size:16,className:`flex-none text-success`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-px text-xs`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-success-strong`,children:l(`config:configPage.testSucceeded`)}),(0,Q.jsxs)(`span`,{className:`truncate font-mono text-content-muted`,children:[b.providerName,` / `,b.modelName,` · `,b.path]})]})]})]}),(0,Q.jsxs)(ze,{open:w,onOpenChange:N,children:[(0,Q.jsx)(Le,{asChild:!0,children:(0,Q.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,Q.jsx)(E,{size:16,"aria-hidden":`true`,className:`flex-none text-content-muted transition-transform group-data-[state=closed]:-rotate-90`}),(0,Q.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-content`,children:l(`config:configPage.visualConnections`)}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:l(`config:configPage.visualConnectionsHint`)})]})}),(0,Q.jsx)(Fe,{children:(0,Q.jsxs)(hi,{className:`mt-2 py-4`,children:[(0,Q.jsx)(go,{providers:P,toggling:n,onClone:o,onConfigure:e=>c(e.id),onToggle:r,onDelete:a}),F.length===0&&(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:l(`config:configPage.visualEmptyHint`)}),(I.length>0||L.length>0)&&(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 border-t border-stroke-soft pt-3`,children:[I.length>0&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`w-16 flex-none text-xs text-content-muted`,children:l(`config:configPage.visualImageModel`)}),(0,Q.jsxs)(Y,{className:`min-w-0 flex-1`,value:d?.imageSelection||``,disabled:g===`image`,"aria-label":l(`config:configPage.visualImageModel`),onChange:e=>void j(`image`,e.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:l(`config:configPage.visualAutoSelected`)}),I.map(e=>(0,Q.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),L.length>0&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`w-16 flex-none text-xs text-content-muted`,children:l(`config:configPage.visualVideoModel`)}),(0,Q.jsxs)(Y,{className:`min-w-0 flex-1`,value:d?.videoSelection||``,disabled:g===`video`,"aria-label":l(`config:configPage.visualVideoModel`),onChange:e=>void j(`video`,e.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:l(`config:configPage.visualAutoSelected`)}),L.map(e=>(0,Q.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),(0,Q.jsx)(`small`,{className:`text-xs text-content-muted`,children:l(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]})]})})]}),S&&(0,Q.jsx)(`div`,{className:`mt-2.5`,children:(0,Q.jsxs)(tn,{children:[(0,Q.jsx)(xe,{size:13}),S]})})]})}var xo=`pisper.config.manageConnectionsOpen`;function So(){let e=i.getItem(xo);return e===`1`||e!==`0`&&null}function Co({defaultAdvancedExpanded:e=!1,navigationKey:n,notify:r,registerPrimaryAction:a,requestConfirm:o}){let{t:s}=u(),c=t(),l=new URLSearchParams(c.search).get(`import`)===`1`,[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(()=>l||e?!0:So());(0,Z.useEffect)(()=>{l&&v(!0)},[l]),(0,Z.useEffect)(()=>{e&&v(!0)},[e,n]);let y=mo({notify:r,requestConfirm:o,t:s}),{config:b}=y,x=ho({requestConfirm:o,onAutoImported:y.refreshConfig,onImported:e=>{y.applyConfig(e.config);let t=e.config.providers.find(t=>t.id===e.providerId);r(e.kind===`authentication`?s(`config:configPage.nameLoginStateHasBeenLoadedIntoPisper`,{name:t?.name||e.providerId}):s(`config:configPage.nameConfigurationHasBeenLoadedIntoPisper`,{name:t?.name||e.providerId}))},t:s});if(va(a,()=>m({providerType:`chat`})),!b)return y.error&&!y.loading?(0,Q.jsx)(Ut,{kind:`error`,title:s(`config:providerWorkbench.loadFailed`),description:y.error,action:(0,Q.jsx)(H,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void y.reload(),children:s(`common:pageTemplate.retry`)})}):(0,Q.jsx)(Ut,{kind:`loading`,title:s(`config:configPage.loadingModelCatalog`),description:s(`config:configPage.readingProvidersAndAuthenticationStatus`)});let S=_??!1,C=Ha(x.discovery),w=e=>{v(e),i.setItem(xo,e?`1`:`0`)},T=e=>g(e);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(no,{config:b,notify:r,busy:!!(y.settingDefault||y.toggling),onConfigChanged:y.applyConfig,onSetDefaultModel:y.setDefaultChatModel}),(0,Q.jsx)(Ia,{config:b,selectedProviderId:d,onSelectProvider:f,toggling:y.toggling,settingDefault:y.settingDefault,settingModel:y.settingModel,onSave:e=>{y.applyConfig(e),r(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:(x.discovering||x.autoImport.imported>0||x.autoImport.skipped>0)&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,role:`status`,children:[x.discovering&&(0,Q.jsx)(V,{className:`size-3`}),x.discovering?s(`config:providerWorkbench.scanningLocal`):s(`config:providerWorkbench.localImportStatus`,{imported:x.autoImport.imported,skipped:x.autoImport.skipped})]})}),y.error&&(0,Q.jsx)(q,{children:y.error}),(0,Q.jsxs)(`div`,{className:`mt-8`,"data-config-advanced":!0,children:[(0,Q.jsx)(lo,{config:b,notify:r,busy:!!(y.settingDefault||y.toggling),onConfigChanged:y.applyConfig}),(0,Q.jsx)(fo,{notify:r})]}),C>0&&(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-2 gap-y-0 text-xs text-content-muted`,children:[(0,Q.jsx)(`span`,{children:s(`config:configPage.localProviderImportHint`,{count:C})}),(0,Q.jsx)(H,{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,Q.jsxs)(ze,{open:S,onOpenChange:w,"data-config-card":`models-advanced`,children:[(0,Q.jsx)(Le,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:`group flex min-h-9 w-full cursor-pointer items-center gap-2 border-0 border-b border-stroke bg-transparent py-2.5 text-left outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus max-[650px]:min-h-11`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-content`,children:s(`config:providerWorkbench.advanced`)}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:s(`config:providerWorkbench.advancedHint`)}),(0,Q.jsx)(E,{size:16,"aria-hidden":`true`,className:`ml-auto shrink-0 text-content-muted transition-transform group-data-[state=open]:rotate-180`})]})}),(0,Q.jsxs)(Fe,{id:`model-connection-management`,children:[(0,Q.jsx)(Ya,{discovery:x.discovery,discovering:x.discovering,error:x.error||x.operationError,importing:x.importing,forceVisible:l,onRefresh:x.refresh,onImport:x.importProvider}),(0,Q.jsx)(bo,{config:b,notify:r,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,Q.jsx)(Za,{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),r(s(`config:configPage.setupComplete`)),m(null)}}),h&&(0,Q.jsx)(Va,{initialProviderType:h.type,cloneProvider:h,onClose:()=>g(null),onCreated:e=>{y.applyConfig(e),e.createdProviderId&&f(e.createdProviderId),r(s(`config:configPage.providerConnectionCreated`)),g(null)}})]})}var wo=[`browser`,`feishu`,`weixin`,`qq`,`telegram`];function To(e){if(!e||typeof e!=`object`||Array.isArray(e))throw d();return e}function Eo(e,t){if(typeof e!=`string`||e.length>t)throw d();return e}function Do(e){let t=To(e),n=To(t.browser);if(typeof n.enabled!=`boolean`||!Array.isArray(t.templates)||!Array.isArray(t.scopes))throw d();let r={},i=To(t.connections);for(let e of wo){if(e===`browser`||i[e]===void 0)continue;let t=i[e];if(t===null){r[e]=null;continue}let n=To(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=To(e),n=Eo(t.id,200);if(!n||a.has(n)||typeof t.enabled!=`boolean`||!Array.isArray(t.variables))throw d();a.add(n);let r={},i=To(t.channels);for(let e of wo){if(i[e]===void 0)continue;let t=To(i[e]);if(t.enabled!==void 0&&typeof t.enabled!=`boolean`)throw d();r[e]={content:Eo(t.content,12e3),...t.enabled===void 0?{}:{enabled:t.enabled}}}return{id:n,name:Eo(t.name,500),description:Eo(t.description,2e3),enabled:t.enabled,variables:t.variables.map(e=>Eo(e,200)),channels:r}}),s=t.scopes.map(e=>{let t=To(e);if(!wo.includes(t.platform))throw d();return{...t,platform:t.platform}});return{browser:{enabled:n.enabled},connections:r,scopes:s,templates:o}}function Oo(e){let t=To(e);if(typeof t.sent!=`number`||!Number.isInteger(t.sent)||t.sent<0)throw d();return{sent:t.sent,...t.title===void 0?{}:{title:Eo(t.title,2e3)},...t.body===void 0?{}:{body:Eo(t.body,12e3)},...t.preview===void 0?{}:{preview:Eo(t.preview,12e3)}}}function ko(e){return e.templates.length>0&&e.templates.every(e=>wo.every(t=>typeof e.channels[t]?.enabled==`boolean`))}var Ao=(e,t)=>`/api/settings/notifications/templates/${encodeURIComponent(e)}/${t}`,jo=(e,t,n,r)=>f(Ao(e,t),{method:`PUT`,body:n,...r,parse:Do}),Mo={load:(e={})=>f(`/api/settings/notifications`,{...e,parse:Do}),setBrowserEnabled:(e,t={})=>f(`/api/settings/notifications/browser`,{method:`PATCH`,body:{enabled:e},...t,parse:Do}),setEventEnabled:(e,t,n={})=>jo(e,`browser`,{enabled:t},n),setChannelEnabled:async(e,t,n,r={})=>{let i=await jo(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={})=>jo(e,t,{content:n},r),testSavedTemplate:(e,t,n={})=>f(`${Ao(e,t)}/test`,{method:`POST`,body:{},...n,parse:Oo})},No=e=>e instanceof Error?e.message:String(e),Po=(e,t)=>`${e}\0${t}`,Fo=e=>e.kind===`browser`?`browser`:e.kind===`event`?`event:${e.event}`:`channel:${e.event}:${e.platform}`;function Io(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 Lo(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 Ro(e){let[t,n]=(0,Z.useState)(null),r=(0,Z.useRef)(null),i=(0,Z.useRef)(e);i.current=e;let[a,o]=(0,Z.useState)(!0),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)({}),[f,p]=(0,Z.useState)({}),m=(0,Z.useRef)({}),[h,g]=(0,Z.useState)({}),[_,v]=(0,Z.useState)({}),y=(0,Z.useRef)(!1),b=(0,Z.useRef)(null),x=(0,Z.useRef)(new Map),S=(0,Z.useRef)(new Map),C=(0,Z.useRef)(new Set),w=(0,Z.useRef)(0),T=(0,Z.useRef)(0),E=(0,Z.useCallback)(e=>{r.current=e,T.current++,n(e),i.current?.(e)},[]),D=(0,Z.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 Mo.load({signal:e.signal});y.current&&!e.signal.aborted&&t===T.current&&E(n)}catch(t){y.current&&!e.signal.aborted&&c(No(t))}finally{y.current&&!e.signal.aborted&&o(!1)}},[E]);(0,Z.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=Fo(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(Io(r.current,e)!==t.value||C.current.has(n)){let i={signal:a.signal},o=e.kind===`browser`?await Mo.setBrowserEnabled(t.value,i):e.kind===`event`?await Mo.setEventEnabled(e.event,t.value,i):await Mo.setChannelEnabled(e.event,e.platform,t.value,i);if(!y.current||a.signal.aborted)return;E(Lo(r.current,e,Io(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:No(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=Lo(k,e.target,e.value));let A=(e,t,n)=>{let r=Po(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=Po(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?ko(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=Po(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 Mo.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:No(e)}})),!1}finally{x.current.get(i)===o&&x.current.delete(i)}},testTemplate:async(e,t)=>{let n=Po(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 Mo.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:No(e)}}))}finally{x.current.get(r)===i&&x.current.delete(r)}}}}function zo(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 Bo({settings:e,templates:t,eventId:n,platform:r,onSelectionChange:i,platformLabel:a,permissionGranted:o,onBrowserTest:s,notify:c}){let{t:l}=u(),d=(0,Z.useRef)(!0),[f,p]=(0,Z.useState)(``);(0,Z.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let m=t.find(e=>e.id===n)||t[0];if(!m||!e.data)return(0,Q.jsx)(`p`,{role:`status`,children:l(`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`?l(`config:notificationSettings.theTestNotificationWasSentCheckYourSystemNotificationCenter`):l(`config:notificationSettings.testNotificationSentToCountChats`,{count:t.sent}))}catch(e){d.current&&p(e instanceof Error?e.message:String(e))}};return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`h2`,{className:`text-[15px] leading-6 font-medium text-content`,children:l(`config:notificationSettings.notificationTemplates`)}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[l(`config:notificationSettings.notificationEvent`),(0,Q.jsx)(Y,{"aria-label":l(`config:notificationSettings.notificationEvent`),value:m.id,onChange:e=>i(e.target.value,r),children:t.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[l(`config:notificationSettings.notificationChannel`),(0,Q.jsx)(Y,{"aria-label":l(`config:notificationSettings.notificationChannel`),value:r,onChange:e=>{let t=wo.find(t=>t===e.target.value);t&&i(m.id,t)},children:wo.map(e=>(0,Q.jsx)(`option`,{value:e,children:a(e)},e))})]})]}),(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:m.description}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-content`,children:[l(`config:notificationSettings.messageContent`),(0,Q.jsx)(Nt,{"aria-label":l(`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,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-content-muted`,children:[(0,Q.jsx)(`span`,{children:l(`config:notificationSettings.availableVariables`)}),m.variables.map(e=>(0,Q.jsx)(`code`,{className:`rounded-xs bg-inline-code px-1.5 py-0.5 font-mono text-content-secondary`,children:`{{${e}}}`},e))]}),(0,Q.jsxs)(`div`,{className:`rounded-md border border-stroke bg-code p-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-content-muted`,children:l(`config:notificationSettings.preview`)}),(0,Q.jsx)(`pre`,{className:`mt-2 font-sans text-sm break-words whitespace-pre-wrap text-content`,children:zo(h.content,l)})]}),(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:h.dirty?l(`config:notificationSettings.saveBeforeTest`):l(`config:notificationSettings.testUsesSavedTemplate`)}),!_&&(0,Q.jsx)(`p`,{role:`status`,className:`text-xs text-content-muted`,children:l(`config:notificationSettings.channelTestUnavailable`)}),(h.save.error||h.test.error||f)&&(0,Q.jsx)(tn,{children:h.save.error||h.test.error||f}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,Q.jsx)(H,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:h.dirty||h.save.pending||!_,loading:h.test.pending,onClick:()=>void v(),children:l(`config:notificationSettings.sendTest`)}),(0,Q.jsx)(H,{"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(l(`config:notificationSettings.notificationTemplateSaved`))},children:l(`config:notificationSettings.saveTemplate`)})]})]})}function Vo(e,t){switch(t){case`chime`:return e(`config:notificationSounds.soundChime`);case`marimba`:return e(`config:notificationSounds.soundMarimba`);case`drop`:return e(`config:notificationSounds.soundDrop`);case`bell`:return e(`config:notificationSounds.soundBell`);default:return e(`config:notificationSounds.soundLow`)}}function Ho(e,t){return e(t===`waiting`?`config:notificationSounds.eventWaiting`:t===`finished`?`config:notificationSounds.eventFinished`:`config:notificationSounds.eventFailed`)}function Uo(e,t){return e(t===`waiting`?`config:notificationSounds.eventWaitingHint`:t===`finished`?`config:notificationSounds.eventFinishedHint`:`config:notificationSounds.eventFailedHint`)}function Wo(){let{t:e}=u(),t=gn(),[n,r]=(0,Z.useState)(null),i=n??t.volume,a=e=>{e!==`none`&&_n(e,t.volume)};return(0,Q.jsxs)(Zt,{"data-config-card":`notifications-sounds`,title:e(`config:notificationSounds.title`),description:e(`config:notificationSounds.description`),children:[(0,Q.jsx)(X,{title:e(`config:notificationSounds.enabled`),control:(0,Q.jsx)(st,{checked:t.enabled,"aria-label":e(`config:notificationSounds.enabled`),onCheckedChange:e=>t.update({enabled:e})})}),wn.map(n=>{let r=t.sounds[n];return(0,Q.jsx)(X,{"data-sound-event":n,title:Ho(e,n),description:Uo(e,n),control:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(Y,{value:r,className:`w-32`,"aria-label":Ho(e,n),disabled:!t.enabled,onChange:e=>{let r=e.target.value;t.setSound(n,r),a(r)},children:[(0,Q.jsx)(`option`,{value:`none`,children:e(`config:notificationSounds.soundNone`)}),bn.map(t=>(0,Q.jsx)(`option`,{value:t,children:Vo(e,t)},t))]}),(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`pointer-coarse:size-11`,disabled:!t.enabled||r===`none`,"aria-label":e(`config:notificationSounds.preview`,{event:Ho(e,n)}),title:e(`config:notificationSounds.preview`,{event:Ho(e,n)}),onClick:()=>a(r),children:(0,Q.jsx)(ue,{"aria-hidden":`true`})})]})},n)}),(0,Q.jsx)(X,{title:e(`config:notificationSounds.volume`),control:(0,Q.jsxs)(`div`,{className:`flex w-48 items-center gap-3`,children:[(0,Q.jsx)(ot,{min:0,max:100,step:5,value:[i],disabled:!t.enabled,"aria-label":e(`config:notificationSounds.volume`),valueText:`${i}%`,onValueChange:([e])=>r(e),onValueCommit:([e])=>{r(null),t.update({volume:e});let n=t.sounds.waiting;n!==`none`&&_n(n,e)}}),(0,Q.jsxs)(`span`,{className:`w-9 text-right text-xs text-content-muted tabular-nums`,children:[i,`%`]})]})}),(0,Q.jsx)(X,{title:e(`config:notificationSounds.whileFocused`),description:e(`config:notificationSounds.whileFocusedHint`),control:(0,Q.jsx)(st,{checked:t.whileFocused,disabled:!t.enabled,"aria-label":e(`config:notificationSounds.whileFocused`),onCheckedChange:e=>t.update({whileFocused:e})})})]})}function Go(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 Ko(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 qo(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 Jo(){return typeof window<`u`&&window.pisperDesktop?.showNotification?window.pisperDesktop.getNotificationStatus?`checking`:`granted`:typeof window<`u`&&Cn()?`checking`:Pn()}function Yo(e,t){return t(e===`system-disabled`||e===`app-disabled`?`config:notificationSettings.systemNotificationsAreOffAllowPisperToSendNotificationsInYourOperatingSystemSettings`:e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.theOperatingSystemDidNotAcceptTheNotificationCheckYourSystemNotificationSettings`)}function Xo(e){return e instanceof Error?e.message:String(e)}function Zo({notify:e,onBrowserNotificationChange:t}){let{t:r,language:i}=u(),a=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let o=Ro(t),{data:s,loading:c,loadError:l}=o,[d,f]=n(),p=!!window.pisperDesktop?.showNotification,m=Cn(),[h,g]=(0,Z.useState)(Jo),_=o.mutations.browser?.pending===!0,v=(0,Z.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,Z.useEffect)(()=>{if(!p)return;v();let e=()=>{v()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[p,v]);let y=(0,Z.useCallback)(async()=>{if(!(p||!m))try{let e=await yn();if(!a.current)return;g(e===!0?`granted`:e===!1?`denied`:`default`)}catch{a.current&&g(`unsupported`)}},[p,m]);(0,Z.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=Yo(`system-disabled`,r);else if(!p&&m){let e=`denied`;try{let t=await yn()===!0?`granted`:await xn();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 Nn();if(!a.current)return;if(g(e),e!==`granted`)n=r(e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`);else try{await Fn()}catch{n=r(`config:notificationSettings.theBrowserBackgroundNotificationServiceCouldNotBeRegistered`)}}}a.current&&(await o.setBrowserEnabled(t),n&&a.current&&e(n,`info`))},x=(0,Z.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(Yo(i.reason,r));return i}return m?(await hn(e,t),{shown:!0,transport:`tauri`}):Mn({title:e,body:t,tag:n,url:window.location.href})},[p,m,r]),C=async()=>{if(!(!o.confirmed?.browser.enabled||_)){if(h!==`granted`){e(h===`unsupported`?Yo(`unsupported`,r):p?Yo(`system-disabled`,r):r(`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`),`error`);return}try{await x(r(`config:notificationSettings.appNotificationTest`,{app:we}),r(`config:notificationSettings.notificationsAreWorking`)),e(r(`config:notificationSettings.theTestNotificationWasSentCheckYourSystemNotificationCenter`),`info`)}catch(t){e(Xo(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,Q.jsxs)(on,{children:[(0,Q.jsx)(V,{className:`size-6`}),(0,Q.jsx)(`h2`,{children:r(`config:notificationSettings.loadingNotificationSettings`)})]});if(!s)return(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(tn,{children:l}),(0,Q.jsx)(H,{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`,O=s.templates.map(e=>({...e,name:Ko(e.id,e.name,r),description:qo(e.id,e.description,r)}));if(E)return(0,Q.jsxs)(`div`,{"data-config-card":`notifications-templates`,className:`space-y-4`,children:[(0,Q.jsxs)(H,{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,Q.jsx)(D,{size:16,"aria-hidden":`true`}),r(`config:notificationSettings.backToCategories`)]}),(0,Q.jsx)(Bo,{settings:o,templates:O,eventId:d.get(`event`)||``,platform:wo.find(e=>e===d.get(`channel`))||`browser`,onSelectionChange:T,platformLabel:e=>Go(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,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[l&&(0,Q.jsx)(tn,{children:l}),Object.entries(o.mutations).filter(([,e])=>e.error).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(tn,{children:t.error}),(0,Q.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>void o.retryMutation(t),children:r(`common:pageTemplate.retry`)})]},e)),(0,Q.jsxs)(hi,{className:`browser-notification-card py-4`,"data-config-card":`notifications-browser`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:B(`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,Q.jsx)(S,{size:18}):(0,Q.jsx)(In,{size:18})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-content`,children:r(`config:notificationSettings.systemNotificationChannel`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs leading-[1.45] text-content-muted`,children:r(`config:notificationSettings.pisperUsesTheCurrentPlatformNotificationSystemWhenAnAgentCompletesOrFails`)})]}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[(0,Q.jsx)(_i,{tone:A,children:k}),(0,Q.jsx)(vi,{ariaLabel:r(`config:notificationSettings.systemNotificationChannel`),value:s.browser.enabled,disabled:_||h===`checking`,onChange:b})]})]}),(0,Q.jsxs)(en,{children:[(0,Q.jsx)(_e,{size:15}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:r(p?`config:notificationSettings.controlledByOperatingSystemNotificationSettings`:`config:notificationSettings.controlledByBrowserSitePermissions`)}),(0,Q.jsx)(`small`,{children:r(p?`config:notificationSettings.theDesktopAppUsesOperatingSystemNotificationsTurningThisOffDoesNotChangeTheOperatingSystemPermis`:`config:notificationSettings.theWebAppUsesBrowserSiteNotificationsTurningThisOffDoesNotChangeTheBrowserPermissionItself`)})]})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex gap-2 max-[650px]:flex-wrap`,children:[p&&h===`denied`&&(0,Q.jsxs)(H,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:w,children:[(0,Q.jsx)(_e,{size:14}),r(`config:notificationSettings.openSystemNotificationSettings`)]}),(0,Q.jsxs)(H,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:!s.browser.enabled||_||h!==`granted`,onClick:C,children:[(0,Q.jsx)(S,{size:14}),r(`config:notificationSettings.sendTestNotification`)]})]})]}),(0,Q.jsx)(Wo,{}),(0,Q.jsxs)(Zt,{title:r(`config:notificationSettings.notificationCategories`),description:r(`config:notificationSettings.channelPreferenceHint`),action:(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,className:`pointer-coarse:h-11`,onClick:()=>T(),children:r(`config:notificationSettings.editNotificationTemplates`)}),children:[!o.supportsChannels&&(0,Q.jsx)(`p`,{role:`status`,className:`py-2 text-sm text-content-muted`,children:r(`config:notificationSettings.channelPreferencesUnsupported`)}),O.length>0&&(0,Q.jsx)(yi,{children:O.map(e=>{let t=e.enabled?wo.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,Q.jsx)(X,{"data-notification-event":e.id,title:e.name,description:e.description,control:(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(Je,{asChild:!0,children:(0,Q.jsx)(H,{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,Q.jsx)(`span`,{className:`max-w-64 truncate`,children:t.length?t.map(e=>Go(e,r)).join(i===`zh-CN`?`、`:`, `):r(`config:notificationSettings.channelsOff`)})})}),(0,Q.jsxs)(Ye,{align:`end`,className:`max-w-[calc(100vw-40px)] min-w-56`,children:[(0,Q.jsx)(qe,{checked:e.enabled,onCheckedChange:t=>void o.setEventEnabled(e.id,t===!0),children:r(`config:notificationSettings.enableEvent`)}),(0,Q.jsx)(Ge,{}),wo.map(t=>{let n=t===`browser`?s.browser.enabled:s.connections[t]?.enabled===!0&&s.scopes.some(e=>e.platform===t);return(0,Q.jsxs)(qe,{checked:e.channels[t]?.enabled!==!1,disabled:!o.supportsChannels,onCheckedChange:n=>void o.setChannelEnabled(e.id,t,n===!0),children:[(0,Q.jsx)(`span`,{children:Go(t,r)}),!n&&(0,Q.jsx)(`small`,{className:`ml-2 text-muted-foreground`,children:r(`config:notificationSettings.channelNeedsSetup`)})]},t)}),(0,Q.jsx)(Ge,{}),(0,Q.jsx)(Ke,{onSelect:()=>T(e.id),children:r(`config:notificationSettings.editNotificationTemplates`)})]})]})},e.id)})}),!O.length&&(0,Q.jsx)(`p`,{role:`status`,className:`py-3 text-sm text-content-muted`,children:r(`config:notificationSettings.noNotificationEvents`)})]})]})}function Qo({notify:e}){let{t}=u(),n=window.pisperDesktop,[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``);(0,Z.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 l=!!(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=l&&!r,m=l?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,Q.jsxs)(K,{"data-config-card":`updates-cli`,title:t(`config:cliSettings.title`),description:t(`config:cliSettings.description`),actions:(0,Q.jsx)(`span`,{className:`text-xs text-content-secondary`,children:m}),children:[r&&(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3 border-t border-stroke py-3`,children:[r.installed&&!r.needsRepair?(0,Q.jsx)(A,{className:`mt-0.5 shrink-0 text-content-muted`,size:16,"aria-hidden":`true`}):(0,Q.jsx)(Xn,{className:`mt-0.5 shrink-0 text-content-muted`,size:16,"aria-hidden":`true`}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-0.5`,children:[(0,Q.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,Q.jsx)(`small`,{className:`font-mono text-xs [overflow-wrap:anywhere] text-content-muted`,children:r.installPath}),r.installed&&(0,Q.jsx)(`small`,{className:`text-xs text-content-muted`,children:r.pathConfigured?t(`config:cliSettings.pathConfigured`):t(`config:cliSettings.pathNeedsRepair`)})]})]}),s&&(0,Q.jsx)(q,{children:s}),l&&(0,Q.jsxs)(`div`,{className:`mt-3 flex gap-2 max-[650px]:flex-wrap`,children:[r?.installed&&(0,Q.jsxs)(H,{type:`button`,variant:`secondary`,className:`max-[650px]:h-11`,disabled:!!a,onClick:()=>void f(),children:[a===`uninstall`?(0,Q.jsx)(V,{className:`text-current`}):(0,Q.jsx)(be,{size:14}),t(`config:cliSettings.uninstall`)]}),(!r?.installed||r.needsRepair)&&(0,Q.jsxs)(H,{type:`button`,className:`max-[650px]:h-11`,disabled:!!a||p||r?.supported===!1,onClick:()=>void d(),children:[a===`install`?(0,Q.jsx)(V,{className:`text-current`}):r?.needsRepair?(0,Q.jsx)(Se,{size:14}):(0,Q.jsx)(N,{size:14}),r?.needsRepair?t(`config:cliSettings.repair`):t(`config:cliSettings.install`)]})]}),l&&(0,Q.jsx)(`small`,{className:`mt-2 block text-xs text-content-muted`,children:t(`config:cliSettings.restartTerminal`)})]})}var $o=`0.6.43`;function es(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 ts(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 ns({notify:e,update:t}){let{t:n,language:r}=u(),i=t?.info||{desktop:!1,packaged:!1,version:$o,platform:`browser`,arch:``},a=t?.status||{state:`idle`},o=!!i.desktop,s=!!i.mobile,c=o||s,[l,d]=(0,Z.useState)({version:$o,date:``,notes:``}),[f,p]=(0,Z.useState)(``);(0,Z.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(t,n)=>{p(t);try{await n()}catch(t){e(t instanceof Error?t.message:String(t),`error`)}finally{p(``)}},h=()=>m(`check`,()=>t.check()),g=()=>m(`download`,()=>t.download()),_=()=>m(`install`,()=>t.install()),v=()=>t?.openReleases(),y=()=>t?.openUpdateLog?.(),b=o?t.shellInstaller:null,x=l.version===i.version?l:null,S=a.notes||(c?x?.notes||n(`config:updateSettings.noReleaseNotesAreAvailableForThisVersion`):a.state===`current`?n(`config:updateSettings.theCurrentWebSourceIsSyncedWithBranch`,{branch:a.branch||`release`}):n(`config:updateSettings.commitsThatHaveNotBeenSyncedWillAppearHereAfterTheCheck`)),C=a.rateLimited?a.retryAt?n(`config:updateSettings.githubRateLimitedUntil`,{time:new Intl.DateTimeFormat(r,{timeStyle:`short`}).format(new Date(a.retryAt*1e3))}):n(`config:updateSettings.githubRateLimited`):``,w=a.state===`unsupported`,T=a.state===`available`,E=a.state===`error`&&a.canResume&&a.canDownload,D=o&&a.state===`error`&&a.canDownload,O=a.state===`downloaded`,k=a.state===`checking`||f===`check`,j=a.state===`downloading`,M=f===`install`,P=k?`checking`:a.state,I=a.availableVersion?`v${a.availableVersion}`:``,L=c?`v${i.version}`:`v${i.version}${a.currentCommit?` · ${a.currentCommit.slice(0,7)}`:``}`,ee=c?`v${a.availableVersion||x?.version||i.version}`:a.availableCommit?.slice(0,7)||a.currentCommit?.slice(0,7)||l.version||i.version,te={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`),unsupported:n(`config:updateSettings.manualUpdateOnly`),error:n(E?`config:updateSettings.downloadPaused`:`config:updateSettings.checkFailed`)}[P]||n(`config:updateSettings.notChecked`),ne=w?n(`config:updateSettings.desktopNeedsReinstall`):o&&O?a.installKind===`installer`?n(`config:updateSettings.installerReadyHint`):n(`config:updateSettings.restartToUpdateHint`):``;return(0,Q.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col`,children:[(0,Q.jsxs)(K,{"data-config-card":`updates-main`,className:`mt-6`,title:n(`config:updateSettings.pisperAppUpdates`),actions:(0,Q.jsx)(`span`,{"data-update-status":P,className:`text-xs text-content-secondary tabular-nums`,children:te}),children:[(0,Q.jsxs)(`dl`,{className:`grid border-y border-stroke max-sm:divide-y max-sm:divide-stroke-soft sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`py-3 sm:pr-4`,children:[(0,Q.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(c?`config:updateSettings.currentVersion`:`config:updateSettings.currentSource`)}),(0,Q.jsx)(`dd`,{className:`mt-1 font-mono text-[12.5px] font-medium text-content`,children:L})]}),(0,Q.jsxs)(`div`,{className:`py-3 sm:border-l sm:border-stroke-soft sm:px-4`,children:[(0,Q.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(`config:updateSettings.platform`)}),(0,Q.jsx)(`dd`,{className:`mt-1 text-sm font-medium text-content`,children:es(i,n)})]}),(0,Q.jsxs)(`div`,{className:`py-3 sm:border-l sm:border-stroke-soft sm:pl-4`,children:[(0,Q.jsx)(`dt`,{className:`text-xs text-content-muted`,children:n(`config:updateSettings.updateChannel`)}),(0,Q.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,Q.jsx)(q,{children:C||a.message}):(0,Q.jsxs)(`p`,{className:`mt-4 flex items-start gap-2 text-sm text-content-secondary`,children:[(0,Q.jsx)(R,{className:`mt-0.5 shrink-0 text-content-muted`,size:15,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0`,children:a.message})]})),ne&&(0,Q.jsxs)(`p`,{className:`mt-4 flex items-start gap-2 text-sm text-content-secondary`,children:[(0,Q.jsx)(R,{className:`mt-0.5 shrink-0 text-content-muted`,size:15,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0`,children:ne})]}),E&&(0,Q.jsx)(`small`,{className:`mt-2 block text-xs text-content-muted`,children:n(`config:updateSettings.downloadedDataWasPreservedAndCanResumeFromTheInterruptionPoint`)}),j&&(0,Q.jsxs)(`div`,{className:`mt-4`,children:[(0,Q.jsxs)(`div`,{className:`flex justify-between text-xs text-content-muted`,children:[(0,Q.jsx)(`span`,{children:n(`config:updateSettings.downloadProgress`)}),(0,Q.jsx)(`span`,{className:`tabular-nums`,children:a.total?`${Math.round(a.percent||0)}% · ${ts(a.transferred,r)} / ${ts(a.total,r)}`:ts(a.transferred,r)})]}),(0,Q.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-surface-active`,children:(0,Q.jsx)(`i`,{className:`block h-full bg-star transition-[width]`,style:{width:`${a.percent||0}%`}})})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[!w&&(0,Q.jsxs)(H,{className:`max-[650px]:h-11`,disabled:k||j||!!f,onClick:O?_:T||E||D?g:h,children:[k||j||M?(0,Q.jsx)(V,{className:`text-current`}):O?(0,Q.jsx)(pe,{size:14}):T||E||D?a.canDownload?(0,Q.jsx)(N,{size:14}):(0,Q.jsx)(F,{size:14}):(0,Q.jsx)(fe,{size:14}),k?n(`config:updateSettings.checking2`):j?n(`config:updateSettings.downloadingUpdate`):O?o?a.installKind===`installer`?n(`config:updateSettings.installVersion`,{version:I}):n(`config:updateSettings.restartAndUpdate`,{version:I}):n(`config:updateSettings.restartAndInstall`):E?n(`config:updateSettings.resumeDownload`):D?n(`config:updateSettings.retryDownload`):T?a.canDownload?n(`config:updateSettings.downloadUpdate`):n(c?`config:updateSettings.viewRelease`:`config:updateSettings.viewSourceUpdates`):n(`config:updateSettings.checkForUpdates`)]}),(0,Q.jsxs)(H,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:v,children:[(0,Q.jsx)(F,{size:14}),c?`GitHub Releases`:`GitHub Compare`]}),o&&(0,Q.jsxs)(H,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:y,children:[(0,Q.jsx)(F,{size:14}),n(`config:updateSettings.viewUpdateDiagnosticLog`)]})]}),b&&(0,Q.jsx)(G,{className:`mt-4`,children:(0,Q.jsx)(W,{icon:(0,Q.jsx)(N,{}),name:n(`config:updateSettings.autoDownload`),description:n(`config:updateSettings.autoDownloadHint`),actions:(0,Q.jsx)(st,{checked:b.status.autoDownload,disabled:f===`toggle`,onCheckedChange:e=>void m(`toggle`,()=>b.setAutoDownload(e)),"aria-label":n(`config:updateSettings.autoDownload`)})})})]}),!s&&(0,Q.jsx)(Qo,{notify:e}),(0,Q.jsx)(K,{title:n(c?T||E||O||j?`config:updateSettings.newVersionReleaseNotes`:`config:updateSettings.currentReleaseNotes`:T?`config:updateSettings.commitsToSync`:`config:updateSettings.currentSourceStatus`),meta:(a.releaseDate||c&&x?.date)&&new Intl.DateTimeFormat(r,{dateStyle:`long`}).format(new Date(a.releaseDate||x?.date||``)),actions:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-xs text-content-muted`,children:[(0,Q.jsx)(A,{size:13,"aria-hidden":`true`}),T||E||O||j?ee:c?`v${x?.version||i.version}`:a.currentCommit?.slice(0,7)||n(`config:updateSettings.notChecked`)]}),children:(0,Q.jsx)(`div`,{className:`border-t border-stroke pt-3`,children:(0,Q.jsx)(Yt,{children:S})})})]})}function rs(e,t){switch(t){case`interface`:return e(`config:settingsShell.lede.interface`);case`notifications`:return e(`config:settingsShell.lede.notifications`);case`shortcuts`:return e(`config:settingsShell.lede.shortcuts`);case`updates`:return e(`config:settingsShell.lede.updates`);case`labs`:return e(`config:settingsShell.lede.labs`);case`about`:return e(`config:settingsShell.lede.about`);default:return e(`config:settingsShell.lede.models`)}}function is({notify:e,registerPrimaryAction:t,invokePrimaryAction:n,section:r,onBackToFeatures:i,onBrowserNotificationChange:a,requestConfirm:o,update:s,renderInterfaceSettings:c}){let{t:l}=u(),d=ft(r);if(r===`remote-access`||r===`mobile-server`||r===`desktop-pet`)return(0,Q.jsx)(ia,{section:r,notify:e,requestConfirm:o,onBack:i});let f=I(r)?r:`models`,p;if(f===`notifications`)p=(0,Q.jsx)(Zo,{notify:e,onBrowserNotificationChange:a});else if(f===`interface`){let t=(0,Q.jsx)(ga,{notify:e,defaultAdvancedExpanded:d?.expandGroup===`interface-advanced`,navigationKey:d?.navigationKey});p=c?c(t):t}else p=f===`shortcuts`?(0,Q.jsx)(_a,{requestConfirm:o}):f===`updates`?(0,Q.jsx)(ns,{notify:e,update:s}):f===`labs`?(0,Q.jsx)(mi,{notify:e}):f===`about`?(0,Q.jsx)(Ti,{update:s,notify:e}):(0,Q.jsx)(Co,{defaultAdvancedExpanded:d?.expandGroup===`models-advanced`,navigationKey:d?.navigationKey,notify:e,registerPrimaryAction:t,requestConfirm:o});let m=l(`navigation:pageHeader.quickSetup`);return(0,Q.jsx)(qt,{"data-settings-page":f,title:L(l,f),description:rs(l,f),toolbar:f===`models`?(0,Q.jsx)(Jt,{actions:(0,Q.jsxs)(H,{variant:`outline`,"data-settings-quick-setup":!0,onClick:n,children:[(0,Q.jsx)(de,{className:`size-4`,"aria-hidden":`true`}),m]})}):void 0,children:(0,Q.jsx)(`div`,{"data-config-card":pt,className:`mt-6 min-w-0 max-[650px]:mt-3`,children:p})})}export{is as ConfigPage};
|