@yuriai/web 0.3.6-beta.8 → 0.3.7-beta.2
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/README.md +19 -3
- package/bin/install-portable.sh +102 -0
- package/bin/install-portable.test.js +112 -0
- package/bin/lib/DOCUMENTATION.md +2 -0
- package/bin/lib/cli-startup.js +7 -2
- package/bin/lib/cli-startup.portable.test.js +30 -0
- package/bin/lib/commands-serve.js +4 -1
- package/bin/lib/commands-update.js +3 -0
- package/bin/lib/commands-update.test.js +18 -0
- package/dist/assets/{AgentAvatar-COZrpK6y.js → AgentAvatar-tB1klLEu.js} +1 -1
- package/dist/assets/{AgentSelector-7iPujobN.js → AgentSelector-DOJcQ1fS.js} +1 -1
- package/dist/assets/ArchivedSessionsDialog-Be-G3Bor.js +1 -0
- package/dist/assets/{AssistantConversationSurface-C6tCgfuc.js → AssistantConversationSurface-CDQRtRm1.js} +3 -3
- package/dist/assets/{AssistantSessionCard-BLKXoc6z.js → AssistantSessionCard-LeXloPe_.js} +2 -2
- package/dist/assets/{AssistantUnreadBadge-BSWBtgFe.js → AssistantUnreadBadge-Dz9e_tQ-.js} +1 -1
- package/dist/assets/{AssistantView-YdmEtDcb.js → AssistantView-CD8Lw7Wt.js} +1 -1
- package/dist/assets/{AssistantWorkingAvatar-Cnl5oL-I.js → AssistantWorkingAvatar-BcP47cyC.js} +1 -1
- package/dist/assets/{AssistantsSettingsPage-CqtitUB4.js → AssistantsSettingsPage-Bm6OLLVR.js} +1 -1
- package/dist/assets/{BinaryFileFallback-ITV09rfY.js → BinaryFileFallback-I9K6_JrA.js} +1 -1
- package/dist/assets/{BtwPanel-SwSsRp_l.js → BtwPanel-8x7EBxyV.js} +2 -2
- package/dist/assets/BusyDots-D9XbBhQY.js +4 -0
- package/dist/assets/{ChatContainer-C_-17prp.js → ChatContainer-CwOWGlfa.js} +23 -23
- package/dist/assets/ChatView-CQF1Urvr.js +3 -0
- package/dist/assets/{DiagramView-DDMO_6X5.js → DiagramView-DZES1YrW.js} +1 -1
- package/dist/assets/{DiffView-DCQrow3l.js → DiffView-BR6PnKaA.js} +2 -2
- package/dist/assets/{DiffViewToggle-uJM3Jn3y.js → DiffViewToggle-JgwYT5PH.js} +1 -1
- package/dist/assets/{ErrorBoundary-BFXVt5ct.js → ErrorBoundary-u6b8to7M.js} +1 -1
- package/dist/assets/{FadeInOnReveal-CrbIIB5N.js → FadeInOnReveal-_PrKnAzJ.js} +1 -1
- package/dist/assets/{GuiPluginMount-FFI3j0Vq.js → GuiPluginMount-Ic0Wnga-.js} +1 -1
- package/dist/assets/{GuiPluginPage-B9I2nkDa.js → GuiPluginPage-D7ipzH33.js} +1 -1
- package/dist/assets/{GuiPluginSurface-D_IoxXvc.js → GuiPluginSurface-Cf-PJ5U8.js} +1 -1
- package/dist/assets/{GuiPluginTitlebarItems-C4eqm-dM.js → GuiPluginTitlebarItems-D5coGxD7.js} +1 -1
- package/dist/assets/{GuiPluginWindow-BMeBjsJ4.js → GuiPluginWindow-BLiRWtv9.js} +1 -1
- package/dist/assets/{Icon-C1m8PihJ.js → Icon-C8DOeE74.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-CJmo4kkb.js → ImageLoadingPlaceholder-xQsmHffh.js} +1 -1
- package/dist/assets/{LoadingImage-956pmYDm.js → LoadingImage-Cq1mdmes.js} +1 -1
- package/dist/assets/{MarkdownRenderer-GdoxOy4f.js → MarkdownRenderer-D0wOr1FD.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-B0BDlD7a.js → MarkdownRendererImpl-BcZ2pmTj.js} +3 -3
- package/dist/assets/{MarkstreamRendererImpl-CNodTwpI.js → MarkstreamRendererImpl-DXz-3qS5.js} +2 -2
- package/dist/assets/{MobileAssistantSettingsPage-DMLyFaSP.js → MobileAssistantSettingsPage-Df5pjQKf.js} +1 -1
- package/dist/assets/{MobileAssistantTab-C8r9diC7.js → MobileAssistantTab-DCi8TWF8.js} +1 -1
- package/dist/assets/{MobileBtwPage-CoQGTHvz.js → MobileBtwPage-BVKkyYgo.js} +1 -1
- package/dist/assets/{MobileChangesSurface-CmZpDOwU.js → MobileChangesSurface-xglyMNk-.js} +1 -1
- package/dist/assets/{MobileChatScreen-Db2VIMuY.js → MobileChatScreen-DpGvSBih.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-DX3hD4c-.js → MobileDetailNavigation-DuNpv9x5.js} +1 -1
- package/dist/assets/{MobileFilesSurface-BERQLtDW.js → MobileFilesSurface-ic4RHVBu.js} +2 -2
- package/dist/assets/{MobileHtmlNetworkBoundary-5XyCoKjL.js → MobileHtmlNetworkBoundary-CBdR_liA.js} +2 -2
- package/dist/assets/{MobileOverlayPanel-XkMrn5-W.js → MobileOverlayPanel-DBFioo71.js} +1 -1
- package/dist/assets/{MobileResizableSheet-CcOOlg4R.js → MobileResizableSheet-D2RhJ_Dw.js} +1 -1
- package/dist/assets/{MobileSettingsTab-iRC8w_jI.js → MobileSettingsTab-KFT5FInQ.js} +1 -1
- package/dist/assets/{MobileShareBridge-DSL2iOvl.js → MobileShareBridge-oP8m4ROY.js} +1 -1
- package/dist/assets/{MobileSurface-CkgVejQ3.js → MobileSurface-Dd-HX7PU.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-DDqtoIoS.js → MobileTabPageHeader-CwlbPMRT.js} +1 -1
- package/dist/assets/{ModelLogo-DK6xHKii.js → ModelLogo-BM0-YvYg.js} +1 -1
- package/dist/assets/{ModelSelector-DMmMUIB2.js → ModelSelector-DH3YY4MO.js} +1 -1
- package/dist/assets/{MultiRunWindow-B6jL_lNE.js → MultiRunWindow-DLx-ykri.js} +1 -1
- package/dist/assets/{OnboardingScreen-BCIOJR5C.js → OnboardingScreen-DPq88MNB.js} +1 -1
- package/dist/assets/{OverlayScrollbar-CbdvcSXs.js → OverlayScrollbar-DghfdyOj.js} +1 -1
- package/dist/assets/{PierreDiffViewer-Dn1NIerc.js → PierreDiffViewer-CMWji23q.js} +1 -1
- package/dist/assets/{ProviderLogo-CmOgqmZH.js → ProviderLogo-DLQgT50F.js} +1 -1
- package/dist/assets/{RemoteAssistantSessionCard-BydwHPmQ.js → RemoteAssistantSessionCard-Cn8iC0bf.js} +1 -1
- package/dist/assets/{RemoteDesktopPanel-q0HrpV8w.js → RemoteDesktopPanel-nVm5cZi5.js} +1 -1
- package/dist/assets/ScheduledTasksDialog-aOojFJck.js +3 -0
- package/dist/assets/{ScrollableOverlay-DIkp2MKc.js → ScrollableOverlay-nib07nAV.js} +1 -1
- package/dist/assets/SettingsGroup-BZjaoNB3.js +1 -0
- package/dist/assets/{SettingsView-DLMfj0mQ.js → SettingsView-BKb62Xf4.js} +15 -15
- package/dist/assets/{SettingsWindow-DCPFcip-.js → SettingsWindow-BaQ-r52i.js} +1 -1
- package/dist/assets/{SetupTourDialog-0bzhfhsY.js → SetupTourDialog-DgP0ftT4.js} +1 -1
- package/dist/assets/{SyncActions-8f50jzAU.js → SyncActions-Bnr6hmC3.js} +1 -1
- package/dist/assets/TerminalView-DBedAEwq.js +9 -0
- package/dist/assets/{TextSelectionMenu-BozjXtuL.js → TextSelectionMenu-DSjG0v4v.js} +2 -2
- package/dist/assets/{ToolOutputDialog-BK0D8GxM.js → ToolOutputDialog-WAgIy70O.js} +2 -2
- package/dist/assets/{YuriLogo-KR0TAQlB.js → YuriLogo-1yVZFnVN.js} +1 -1
- package/dist/assets/{YuriWordmark-B0uXpGcz.js → YuriWordmark-CqkcfAJl.js} +1 -1
- package/dist/assets/{assistant-attachment-cache-BNDj8_aw.js → assistant-attachment-cache-CIij0OGm.js} +1 -1
- package/dist/assets/{assistantMessagePreview-Ccp5_-kq.js → assistantMessagePreview-Bsfy_0tR.js} +1 -1
- package/dist/assets/{assistantQueries-DDTlQu6m.js → assistantQueries-BrysCPho.js} +1 -1
- package/dist/assets/{auto-read-context-C8RimaOE.js → auto-read-context-CqyV7-Il.js} +1 -1
- package/dist/assets/{capgoAdapter-DvATpyxN.js → capgoAdapter-CE2tG1-G.js} +1 -1
- package/dist/assets/{card-alsnQayp.js → card-DVsK1bg4.js} +1 -1
- package/dist/assets/{chatUpwardIntent-D_Yt_quU.js → chatUpwardIntent-0bZdNDP3.js} +1 -1
- package/dist/assets/{checkbox-LzFeQCyX.js → checkbox-p14OGtt6.js} +1 -1
- package/dist/assets/{client-i5Q82JUc.js → client-CmtAKi5B.js} +1 -1
- package/dist/assets/{collapsible-HsY9X-Ve.js → collapsible-YyH7spLA.js} +1 -1
- package/dist/assets/{connection-hint-DsbzB6Ms.js → connection-hint-DjLiXeds.js} +1 -1
- package/dist/assets/{context-menu-Dpuzxt3o.js → context-menu-CaquuQPG.js} +1 -1
- package/dist/assets/{desktopHosts-DRAWu-NH.js → desktopHosts-COI-czjF.js} +1 -1
- package/dist/assets/{desktopRelayRestore-DFWsoSoG.js → desktopRelayRestore-BEPNc7qb.js} +1 -1
- package/dist/assets/device-TCHW5U2y.js +2 -0
- package/dist/assets/{diagram-COwAj2NM.js → diagram-CK9c-FX4.js} +1 -1
- package/dist/assets/dialog-B6B8FIrL.css +1 -0
- package/dist/assets/{dialog-Cv20xnEj.js → dialog-DHjQmYCZ.js} +1 -1
- package/dist/assets/{dropdown-menu-B_P1dDl7.js → dropdown-menu-wHGfotqg.js} +1 -1
- package/dist/assets/es-C1spVk4O.js +15 -0
- package/dist/assets/{fileMentionTouchSelection-BRu1cBlZ.js → fileMentionTouchSelection-BmSRExKi.js} +1 -1
- package/dist/assets/{fileReferenceActions-FVCTQlDH.js → fileReferenceActions-wN7mWY3w.js} +1 -1
- package/dist/assets/fr-yyP7Hlty.js +13 -0
- package/dist/assets/{gitApi-BH7j-M9u.js → gitApi-BrV9unI3.js} +1 -1
- package/dist/assets/{gitApiHttp-Be5VpQHC.js → gitApiHttp-ZjM4HkSo.js} +2 -2
- package/dist/assets/{githubAuthQueries-Dli4cDU7.js → githubAuthQueries-3AJp5LD5.js} +1 -1
- package/dist/assets/{historyImportQueries-SUqjfVSc.js → historyImportQueries-B_mfphxe.js} +1 -1
- package/dist/assets/host-fTclNJST.js +1 -0
- package/dist/assets/{i18n-CBCskgqa.js → i18n-Sh2Qk9nD.js} +1 -1
- package/dist/assets/{icons-BQMGp0ts.js → icons-54PVn3Nr.js} +1 -1
- package/dist/assets/{imageSource-DoyhaY3E.js → imageSource-qzgDdfT4.js} +1 -1
- package/dist/assets/{input-CY-NU-bG.js → input-C2I_T3cU.js} +1 -1
- package/dist/assets/{input-store-C4dE7Hgl.js → input-store-CzG_3qFv.js} +1 -1
- package/dist/assets/insertionBoundaries-Bk3zjnUJ.js +1 -0
- package/dist/assets/ja-ChftrfCh.js +15 -0
- package/dist/assets/{kbd-DJnHCHPh.js → kbd-BvxwoK5B.js} +1 -1
- package/dist/assets/ko-BrLgX_6B.js +15 -0
- package/dist/assets/main-BuqJ3O2H.js +2 -0
- package/dist/assets/main-Ded4HLay.js +169 -0
- package/dist/assets/{markdownHeightCache-BAuvVQZt.js → markdownHeightCache-DOk_2vb2.js} +1 -1
- package/dist/assets/{mcpQueries-lBUNZsO9.js → mcpQueries-CRMVNbiD.js} +1 -1
- package/dist/assets/miniChat-C_keuh7x.js +2 -0
- package/dist/assets/mobile-C-Xb-xCI.js +2 -0
- package/dist/assets/{mobileBackNavigation-BzQ0WYuk.js → mobileBackNavigation-DNAhdcTU.js} +1 -1
- package/dist/assets/{mobileConnections-CSyrEiXH.js → mobileConnections-B20qC6CR.js} +2 -2
- package/dist/assets/{multirun-BUjPLUCQ.js → multirun-BXD-vbh9.js} +1 -1
- package/dist/assets/{native-config-C-fqN2Cf.js → native-config-sbQqtLZx.js} +1 -1
- package/dist/assets/{nativeComposerCover-DT9d7IrX.js → nativeComposerCover-Js1b6_JZ.js} +1 -1
- package/dist/assets/{navigation-D2V5N7IH.js → navigation-C3z94oXZ.js} +2 -2
- package/dist/assets/openRemoteProjectSession-Do_U0Wjg.js +1 -0
- package/dist/assets/openSessionFromDeepLink-9v_-3Wec.js +2 -0
- package/dist/assets/pl-DlKDQDhl.js +15 -0
- package/dist/assets/platform-B2ylz14u.js +1 -0
- package/dist/assets/{pluginPresentation-CbOzLlWM.js → pluginPresentation-CoA2suJt.js} +2 -2
- package/dist/assets/{project-preview-ClK_VQFz.js → project-preview-yQerlKs2.js} +1 -1
- package/dist/assets/{projectActions-CD3dKulN.js → projectActions-B11KAI3f.js} +1 -1
- package/dist/assets/{prompt-attachment-upload-BG4nBKxi.js → prompt-attachment-upload-BzYqZdzd.js} +1 -1
- package/dist/assets/pt-BR-BldJPFQ5.js +15 -0
- package/dist/assets/pwa-bZZTVtSz.js +2 -0
- package/dist/assets/{queue-abort-optimistic-DcW7tzaK.js → queue-abort-optimistic-CRtH_pdQ.js} +1 -1
- package/dist/assets/{quota-Cyq21PUF.js → quota-jMPnmJTS.js} +1 -1
- package/dist/assets/{reference-history-BZIwpng4.js → reference-history-BXab-rhp.js} +1 -1
- package/dist/assets/{remote-input-store-CiwwBt7K.js → remote-input-store-DPw_n0MZ.js} +1 -1
- package/dist/assets/{remoteProjectQueries-CuuZggLJ.js → remoteProjectQueries-BQzoY_Y9.js} +1 -1
- package/dist/assets/{remoteSessionReference-DAt2R0UC.js → remoteSessionReference-BxtqP_LB.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-C7YpH2qP.js → renderElectronMiniChatApp-BID4sjRN.js} +2 -2
- package/dist/assets/renderMobileApp-DIfIlnMb.js +17 -0
- package/dist/assets/{runtime-file-download-RzAqq2xr.js → runtime-file-download-CaeLqIEY.js} +1 -1
- package/dist/assets/{runtime-file-resource-COtIWnSi.js → runtime-file-resource-BGZ4tGr5.js} +1 -1
- package/dist/assets/{runtimeConfig-Byc5NYTD.js → runtimeConfig-Cgj64Llx.js} +1 -1
- package/dist/assets/runtimeEndpointReset-C_jJz__z.js +4 -0
- package/dist/assets/{scheduledTaskNavigation-DuM1gQ9g.js → scheduledTaskNavigation-r3g3DfXq.js} +1 -1
- package/dist/assets/{select-DxI3wkmK.js → select-4PL3Ynr3.js} +1 -1
- package/dist/assets/{sessionLookup-UJH1iLm2.js → sessionLookup-BYsOsr9J.js} +1 -1
- package/dist/assets/{sessionOwnership-W4KQ8CbY.js → sessionOwnership-h393kE5w.js} +1 -1
- package/dist/assets/{shortcuts-FWBXko6F.js → shortcuts-wDaVtfuQ.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-Bq5JCAvR.js → sortable-tabs-strip-_B4FGd1y.js} +1 -1
- package/dist/assets/{speechSettingsQueries-Cybc1zo2.js → speechSettingsQueries-CuGvtDnZ.js} +1 -1
- package/dist/assets/src-B7qham90.css +2 -0
- package/dist/assets/{store-BRt8bo0A.js → store-BGuutgkJ.js} +5 -5
- package/dist/assets/{switch-BDwSWOjd.js → switch-Hzwmw5nt.js} +1 -1
- package/dist/assets/{terminalApi-BMMDklSX.js → terminalApi-wdwb9MVG.js} +1 -1
- package/dist/assets/{textarea-BshZJgqE.js → textarea-BqD15FDV.js} +1 -1
- package/dist/assets/{timeFormat-7kWOlby7.js → timeFormat-BaiPCZgf.js} +1 -1
- package/dist/assets/{tooltip-Cdy71vjH.js → tooltip-C4aKqJvN.js} +1 -1
- package/dist/assets/{truncated-path-YngMm0g8.js → truncated-path-BT64k7CU.js} +1 -1
- package/dist/assets/{types-CjZZGQvx.js → types-B8AS1Brf.js} +1 -1
- package/dist/assets/ui-By-75f8l.js +13 -0
- package/dist/assets/uk-Cw2L_unr.js +15 -0
- package/dist/assets/useAppFontEffects-QkfQ00lp.js +7 -0
- package/dist/assets/{useAssistantUIStore-LaS5RREA.js → useAssistantUIStore-BUWPTwNV.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-Icn9KYUk.js → useDesktopWindowControlsLayout-DrBkTYrX.js} +1 -1
- package/dist/assets/{useDictation-C1sdxoEy.js → useDictation-83-qDgkn.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-BnoYSkb7.js → useEffectiveDirectory-CrsINMiX.js} +1 -1
- package/dist/assets/useFontPreferences-C4dQT72k.js +1 -0
- package/dist/assets/{useGitStore-FAEWrkVE.js → useGitStore-Dx9gq2Eh.js} +1 -1
- package/dist/assets/{useInlineCommentDraftStore-CjyZgWKx.js → useInlineCommentDraftStore-De-6mDMI.js} +1 -1
- package/dist/assets/useMcpConfigStore-gKHepAcH.js +1 -0
- package/dist/assets/{useMobileSwipeActions-3JgGyG-s.js → useMobileSwipeActions-GD9WaonR.js} +1 -1
- package/dist/assets/useMobileTranscriptSyncHint-hJZIsqRQ.js +10 -0
- package/dist/assets/{useModelLists-Cz7CBWNr.js → useModelLists-DJPjgwUx.js} +1 -1
- package/dist/assets/{useOpenCodeReadiness-DSTj-ijS.js → useOpenCodeReadiness-Cn4yc2Bm.js} +1 -1
- package/dist/assets/usePluginsStore-Dg2vCCgh.js +1 -0
- package/dist/assets/{useProjectGitActions-C0z5ldH7.js → useProjectGitActions-Ul9GEWII.js} +1 -1
- package/dist/assets/{useProjectGitStore-C6ZCDvmO.js → useProjectGitStore-votrXA4y.js} +1 -1
- package/dist/assets/{useProjectRuntimeAPIs-Fi6XrG43.js → useProjectRuntimeAPIs-IIGjzxCs.js} +1 -1
- package/dist/assets/{useQuotaStore-yM_EeU_A.js → useQuotaStore-CHxR2ZkD.js} +1 -1
- package/dist/assets/{useSessionBtwStore-1yHVqSCf.js → useSessionBtwStore-CQb-pbBw.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-BbawjMGN.js → useStreamingTextThrottle-DsYHMrpn.js} +1 -1
- package/dist/assets/useTerminalStore-C_QzSEgP.js +1 -0
- package/dist/assets/{useUIStore-Dz0bOfkB.js → useUIStore-68ZPpgYA.js} +1 -1
- package/dist/assets/worktreeManager-Svy4mfp-.js +1 -0
- package/dist/assets/{worktreeSourceBranchPreference-BJrbhZ4m.js → worktreeSourceBranchPreference-Bt_e3_MW.js} +1 -1
- package/dist/assets/zh-CN-BQXjCmNe.js +15 -0
- package/dist/assets/zh-TW-Y0lErpEY.js +15 -0
- package/dist/index.html +16 -16
- package/dist/mini-chat.html +16 -16
- package/dist/mobile.html +2 -2
- package/package.json +2 -1
- package/server/index.js +22 -10
- package/server/lib/assistants/DOCUMENTATION.md +11 -6
- package/server/lib/assistants/builtin-skills.js +19 -3
- package/server/lib/assistants/builtin-skills.test.js +17 -0
- package/server/lib/assistants/contact-tools.js +47 -3
- package/server/lib/assistants/contact-tools.test.js +59 -0
- package/server/lib/assistants/harness.js +5 -2
- package/server/lib/assistants/harness.test.js +1 -1
- package/server/lib/assistants/routes.js +1 -0
- package/server/lib/assistants/service.js +7 -2
- package/server/lib/assistants/yuri-tools.js +1 -1
- package/server/lib/assistants/yuri-tools.test.js +1 -1
- package/server/lib/gui-customization/DOCUMENTATION.md +32 -7
- package/server/lib/gui-customization/projects-client.mjs +1 -1
- package/server/lib/gui-customization/projects.js +6 -6
- package/server/lib/gui-customization/projects.test.js +13 -2
- package/server/lib/gui-customization/remote-connections-client.mjs +1 -1
- package/server/lib/gui-customization/remote-connections.js +7 -6
- package/server/lib/gui-customization/remote-connections.test.js +17 -0
- package/server/lib/gui-customization/session-skill.js +16 -4
- package/server/lib/gui-customization/session-skill.test.js +16 -0
- package/server/lib/gui-customization/skill/SKILL.md +2 -2
- package/server/lib/gui-customization/skill/references/deep-links.md +15 -11
- package/server/lib/gui-customization/skill/references/gui-api.md +50 -1
- package/server/lib/gui-customization/skill/references/projects.md +19 -0
- package/server/lib/gui-customization/skill/references/remote-connections.md +3 -0
- package/server/lib/gui-customization/skill-caller.js +18 -0
- package/server/lib/host-update/DOCUMENTATION.md +5 -0
- package/server/lib/host-update/cli.js +5 -2
- package/server/lib/host-update/cli.test.js +15 -2
- package/server/lib/opencode/DOCUMENTATION.md +2 -1
- package/server/lib/opencode/custom-provider.test.js +41 -0
- package/server/lib/opencode/feature-routes-runtime.js +20 -3
- package/server/lib/opencode/settings-helpers.js +5 -0
- package/server/lib/opencode/settings-helpers.test.js +10 -0
- package/server/lib/package-manager.js +14 -0
- package/server/lib/package-manager.test.js +7 -0
- package/server/lib/portable-installation.js +34 -0
- package/server/lib/portable-installation.test.js +38 -0
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/relay-server.e2e.test.ts +12 -0
- package/server/lib/session-index/DOCUMENTATION.md +8 -0
- package/server/lib/session-index/adopt-unindexed-session.js +46 -0
- package/server/lib/session-index/adopt-unindexed-session.test.js +77 -0
- package/server/lib/session-index/event-ingest.js +14 -1
- package/server/lib/session-index/event-ingest.test.js +18 -0
- package/server/lib/ui-auth/DOCUMENTATION.md +1 -1
- package/server/lib/ui-auth/ui-auth.js +2 -0
- package/server/lib/ui-auth/ui-auth.test.js +20 -1
- package/dist/assets/ArchivedSessionsDialog-DLZzsdyB.js +0 -1
- package/dist/assets/BusyDots-C2pMtufA.js +0 -4
- package/dist/assets/ChatView-CNNGCekk.js +0 -3
- package/dist/assets/ScheduledTasksDialog-DY9GJF-s.js +0 -3
- package/dist/assets/SettingsGroup-YUId7nD5.js +0 -1
- package/dist/assets/TerminalView-B9AFgs54.js +0 -8
- package/dist/assets/device-gKeFQDLT.js +0 -2
- package/dist/assets/dialog-D9CkSNCA.css +0 -1
- package/dist/assets/es-BuXtFKUW.js +0 -15
- package/dist/assets/fr-BaZeffY9.js +0 -13
- package/dist/assets/host-CgzhgNKF.js +0 -1
- package/dist/assets/insertionBoundaries-DUMGOIsz.js +0 -1
- package/dist/assets/ja-CGVx5A8U.js +0 -15
- package/dist/assets/ko-C663nzbf.js +0 -15
- package/dist/assets/main-CSPEphQ0.js +0 -169
- package/dist/assets/main-VozcdE4o.js +0 -2
- package/dist/assets/miniChat-DuIhQwv6.js +0 -2
- package/dist/assets/mobile-zYF3NcbJ.js +0 -2
- package/dist/assets/openRemoteProjectSession-Dz9GJCUz.js +0 -1
- package/dist/assets/openSessionFromDeepLink-DHu8AmBy.js +0 -2
- package/dist/assets/pl-CeBOMwg9.js +0 -15
- package/dist/assets/platform-z1TeG-ky.js +0 -1
- package/dist/assets/pt-BR-r8268Pk6.js +0 -15
- package/dist/assets/pwa-Dc46OTi7.js +0 -2
- package/dist/assets/renderMobileApp-DkFS7I4O.js +0 -17
- package/dist/assets/runtimeEndpointReset-BOfBQwJk.js +0 -4
- package/dist/assets/src-DYCPWwUH.css +0 -2
- package/dist/assets/ui-DeV7Us1B.js +0 -13
- package/dist/assets/uk-CeQ1XJ99.js +0 -15
- package/dist/assets/useAppFontEffects-CWZFjoHJ.js +0 -7
- package/dist/assets/useFontPreferences-CLUZvRho.js +0 -1
- package/dist/assets/useMcpConfigStore-n8Iyj2v9.js +0 -1
- package/dist/assets/useMobileTranscriptSyncHint-CgAaYuLF.js +0 -10
- package/dist/assets/usePluginsStore-CsChIifx.js +0 -1
- package/dist/assets/worktreeManager-XchvRN9O.js +0 -1
- package/dist/assets/zh-CN-Bv854olO.js +0 -15
- package/dist/assets/zh-TW-gx8cO-Cx.js +0 -15
|
@@ -26,6 +26,9 @@ const withDirectory = (session, directory) => {
|
|
|
26
26
|
* @param {(sessionID: string) => void | Promise<void>} [options.onSessionDeleted]
|
|
27
27
|
* @param {() => boolean} [options.isHostReady]
|
|
28
28
|
* When false, session lifecycle upserts are skipped until metadata is ready.
|
|
29
|
+
* @param {(sessionID: string, directory: string, activityAt: number) => void} [options.onUnindexedUserActivity]
|
|
30
|
+
* Called when a user message targets a session the index does not hold (an old
|
|
31
|
+
* session outside the newest-20 window); the owner adopts it asynchronously.
|
|
29
32
|
*/
|
|
30
33
|
export const applySessionIndexEvent = (service, event, observedAt = Date.now(), options = {}) => {
|
|
31
34
|
if (!service || !event || typeof event !== 'object') return false;
|
|
@@ -35,6 +38,9 @@ export const applySessionIndexEvent = (service, event, observedAt = Date.now(),
|
|
|
35
38
|
const projectSession = typeof options.projectSession === 'function' ? options.projectSession : null;
|
|
36
39
|
const onSessionDeleted = typeof options.onSessionDeleted === 'function' ? options.onSessionDeleted : null;
|
|
37
40
|
const isHostReady = typeof options.isHostReady === 'function' ? options.isHostReady : null;
|
|
41
|
+
const onUnindexedUserActivity = typeof options.onUnindexedUserActivity === 'function'
|
|
42
|
+
? options.onUnindexedUserActivity
|
|
43
|
+
: null;
|
|
38
44
|
|
|
39
45
|
const baseType = normalizeSessionEventType(payload.type);
|
|
40
46
|
|
|
@@ -127,14 +133,21 @@ export const applySessionIndexEvent = (service, event, observedAt = Date.now(),
|
|
|
127
133
|
const activityAt = typeof info.time?.created === 'number' ? info.time.created : observedAt;
|
|
128
134
|
const activityChanged = service.touchActivity(info.sessionID, activityAt);
|
|
129
135
|
const settleCleared = service.clearSettleOverride?.(info.sessionID) ?? false;
|
|
136
|
+
if (!activityChanged && onUnindexedUserActivity && !service.findBySessionId?.(info.sessionID)) {
|
|
137
|
+
onUnindexedUserActivity(info.sessionID, directory, activityAt);
|
|
138
|
+
}
|
|
130
139
|
return activityChanged || settleCleared;
|
|
131
140
|
}
|
|
132
141
|
|
|
133
142
|
if (baseType === 'session.inbox.enqueued') {
|
|
134
143
|
const data = payload.data ?? properties;
|
|
135
144
|
if (data.item?.type !== 'user' || typeof data.sessionID !== 'string') return false;
|
|
136
|
-
const
|
|
145
|
+
const activityAt = data.item.time?.created ?? payload.created ?? observedAt;
|
|
146
|
+
const activityChanged = service.touchActivity(data.sessionID, activityAt);
|
|
137
147
|
const settleCleared = service.clearSettleOverride?.(data.sessionID) ?? false;
|
|
148
|
+
if (!activityChanged && onUnindexedUserActivity && !service.findBySessionId?.(data.sessionID)) {
|
|
149
|
+
onUnindexedUserActivity(data.sessionID, directory, activityAt);
|
|
150
|
+
}
|
|
138
151
|
return activityChanged || settleCleared;
|
|
139
152
|
}
|
|
140
153
|
|
|
@@ -61,6 +61,24 @@ describe('session index event ingest', () => {
|
|
|
61
61
|
expect(applySessionIndexEvent(service, { payload: { type: 'session.idle', properties: { sessionID: 'ses_a' } } }, 30)).toBe(false);
|
|
62
62
|
expect(service.clearSettleOverride).not.toHaveBeenCalled();
|
|
63
63
|
});
|
|
64
|
+
it('hands user input for a session the index does not hold to the adopter, once per event', () => {
|
|
65
|
+
const adopt = vi.fn();
|
|
66
|
+
const service = { touchActivity: vi.fn(() => false), findBySessionId: vi.fn(() => null), clearSettleOverride: vi.fn(() => false) };
|
|
67
|
+
const user = { directory: '/repo', payload: { type: 'message.updated', properties: { info: { role: 'user', sessionID: 'ses_old', time: { created: 5 } } } } };
|
|
68
|
+
applySessionIndexEvent(service, user, 30, { onUnindexedUserActivity: adopt });
|
|
69
|
+
expect(adopt).toHaveBeenCalledWith('ses_old', '/repo', 5);
|
|
70
|
+
adopt.mockClear();
|
|
71
|
+
applySessionIndexEvent(service, { directory: '/repo', payload: { type: 'session.inbox.enqueued', data: { sessionID: 'ses_old', item: { type: 'user', time: { created: 7 } } } } }, 30, { onUnindexedUserActivity: adopt });
|
|
72
|
+
expect(adopt).toHaveBeenCalledWith('ses_old', '/repo', 7);
|
|
73
|
+
});
|
|
74
|
+
it('does not adopt a session the index already holds, or assistant messages', () => {
|
|
75
|
+
const adopt = vi.fn();
|
|
76
|
+
const service = { touchActivity: vi.fn(() => false), findBySessionId: vi.fn(() => ({ id: 'ses_held' })), clearSettleOverride: vi.fn(() => false) };
|
|
77
|
+
const user = { payload: { type: 'message.updated', properties: { info: { role: 'user', sessionID: 'ses_held', time: { created: 5 } } } } };
|
|
78
|
+
applySessionIndexEvent(service, user, 30, { onUnindexedUserActivity: adopt });
|
|
79
|
+
applySessionIndexEvent({ ...service, findBySessionId: () => null }, { payload: { type: 'message.updated', properties: { info: { role: 'assistant', sessionID: 'ses_old' } } } }, 30, { onUnindexedUserActivity: adopt });
|
|
80
|
+
expect(adopt).not.toHaveBeenCalled();
|
|
81
|
+
});
|
|
64
82
|
it('takes moved ownership from native data rather than the old event envelope directory', () => {
|
|
65
83
|
const service = { move: vi.fn(() => true) };
|
|
66
84
|
expect(applySessionIndexEvent(service, { directory: '/old', payload: {
|
|
@@ -18,7 +18,7 @@ gate. Clients must recheck `/auth/session` before interpreting a feature API's
|
|
|
18
18
|
401/403 as a UI logout; Relay pairing admission failure and Relay socket routing
|
|
19
19
|
authentication failure are distinct from UI password expiry.
|
|
20
20
|
|
|
21
|
-
Relay admission additionally requires an active client record with `usesRelay: true`, `authMethod: 'pairing'`, and a pairing ID. `authorizeRelayRequest` enforces this before the tunnel forwards
|
|
21
|
+
Relay admission additionally requires an active client record with `usesRelay: true`, `authMethod: 'pairing'`, and a pairing ID. `authorizeRelayRequest` enforces this before the tunnel forwards authenticated HTTP/SSE requests or WebSocket upgrades, including when the Host has no UI password. SSH/password/passkey credentials, owner cookies, and direct-only pairings do not grant Relay access. URL tokens resolve back to their issuing client and recheck current revocation/expiry and Relay permission. Before a credential exists, only the public `GET /health` (without a WebSocket upgrade) and `POST /api/client-auth/pairing/redeem` are admitted. Mobile 0.2.31 probes health before redemption; this reachability response grants no session or business API access. Redemption's one-time secret validation also requires a Relay-enabled pairing when arriving through Relay. Direct authentication behavior is unchanged.
|
|
22
22
|
|
|
23
23
|
Pairing v2 is implemented by `packages/web/server/lib/client-auth/pairing.js`. It stores short-lived one-time pairing sessions with hashed secrets, exposes create/cancel/redeem routes under `/api/client-auth/pairing/*`, and redeems a valid pairing secret into the same remote client token used by password/passkey trusted-device flows.
|
|
24
24
|
|
|
@@ -533,6 +533,8 @@ export const createUiAuth = ({
|
|
|
533
533
|
|
|
534
534
|
const authorizeRelayRequest = async (req) => {
|
|
535
535
|
const pathname = new URL(req.url, 'http://127.0.0.1').pathname;
|
|
536
|
+
// 0.2.31 mobile probes this public route before redeeming a pairing secret.
|
|
537
|
+
if (req.method === 'GET' && pathname === '/health' && !req.headers?.upgrade) return true;
|
|
536
538
|
// Pairing redeems its one-time secret before a client credential exists.
|
|
537
539
|
if (req.method === 'POST' && pathname === '/api/client-auth/pairing/redeem') return true;
|
|
538
540
|
try {
|
|
@@ -130,7 +130,7 @@ describe('ui auth client credential seam', () => {
|
|
|
130
130
|
expect(await auth.authorizeRelayRequest(wsReq)).toBe(false);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
expect(await auth.authorizeRelayRequest({ method: 'GET', url: '/health', headers: {} })).toBe(
|
|
133
|
+
expect(await auth.authorizeRelayRequest({ method: 'GET', url: '/health', headers: {} })).toBe(true);
|
|
134
134
|
expect(await auth.authorizeRelayRequest({ method: 'POST', url: '/auth/session', headers: { cookie: 'yuri_ui_session=owner' } })).toBe(false);
|
|
135
135
|
expect(await auth.authorizeRelayRequest({ method: 'POST', url: '/api/client-auth/pairing/redeem', headers: {} })).toBe(true);
|
|
136
136
|
expect(await auth.authorizeRelayRequest({ method: 'GET', url: '/api/client-auth/pairing/redeem', headers: {} })).toBe(false);
|
|
@@ -138,6 +138,25 @@ describe('ui auth client credential seam', () => {
|
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
it('admits only the legacy mobile public health probe before pairing', async () => {
|
|
142
|
+
const createUiAuth = await loadCreateUiAuth();
|
|
143
|
+
const auth = createUiAuth({ requireClientAuth: true });
|
|
144
|
+
try {
|
|
145
|
+
expect(await auth.authorizeRelayRequest({ method: 'GET', url: '/health', headers: {} })).toBe(true);
|
|
146
|
+
for (const [method, url, headers] of [
|
|
147
|
+
['POST', '/health', {}],
|
|
148
|
+
['HEAD', '/health', {}],
|
|
149
|
+
['GET', '/health/extra', {}],
|
|
150
|
+
['GET', '/auth/session', {}],
|
|
151
|
+
['GET', '/api/version', {}],
|
|
152
|
+
['GET', '/api/session', {}],
|
|
153
|
+
['GET', '/health', { upgrade: 'websocket' }],
|
|
154
|
+
]) {
|
|
155
|
+
expect(await auth.authorizeRelayRequest({ method, url, headers })).toBe(false);
|
|
156
|
+
}
|
|
157
|
+
} finally { auth.dispose(); }
|
|
158
|
+
});
|
|
159
|
+
|
|
141
160
|
it('accepts bearer client credentials when UI password auth is enabled', async () => {
|
|
142
161
|
const createUiAuth = await loadCreateUiAuth();
|
|
143
162
|
const auth = createUiAuth({
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,o as n}from"./runtime-switch-DEPKHgdL.js";import{L as r}from"./platform-z1TeG-ky.js";import{a as i,i as a}from"./vendor-zustand-CTekDqaS.js";import{it as o,ot as s,st as c}from"./vendor-base-ui-wXsskyKm.js";import{St as l,Ut as u}from"./gitApiHttp-Be5VpQHC.js";import{n as d}from"./vendor-react-BkccXcWz.js";import{r as f}from"./useUIStore-Dz0bOfkB.js";import{B as p,E as m,F as h,G as g,K as _,R as v,U as y,V as b,W as x,X as S,Y as C,Z as w,a as T,f as E,g as D,ht as O,j as k,l as ee,lt as A,mt as j,pt as M,st as N,tt as P}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{c as F,o as I,r as L}from"./vendor-codemirror-lang-angular-Cm7vBE3E.js";import{n as R,r as z}from"./vendor-codemirror-lang-json-DowyFczU.js";import{n as te}from"./vendor-codemirror-lang-markdown-npWBZIoE.js";import{n as ne}from"./vendor-codemirror-lang-python-OPRdU26g.js";import{O as B}from"./vendor-codemirror-legacy-modes-DwltVFbT.js";import{Ba as V,Fa as re,Fi as H,Mi as U,Ti as ie,Yn as W,ar as ae,bt as oe,f as se,io as G,no as K,t as q,un as ce}from"./ui-DeV7Us1B.js";import{n as J}from"./Icon-C1m8PihJ.js";import{t as le}from"./i18n-CBCskgqa.js";import{a as ue,n as de,o as fe,t as pe}from"./dialog-Cv20xnEj.js";import{i as me,n as he,t as ge}from"./tooltip-Cdy71vjH.js";import{n as _e}from"./useThemeSystem-BIXghnHj.js";import{r as ve}from"./device-gKeFQDLT.js";import{n as ye,r as be,t as xe}from"./collapsible-HsY9X-Ve.js";import{t as Se}from"./gitApi-BH7j-M9u.js";import{t as Ce}from"./input-CY-NU-bG.js";import{B as we,G as Te,H as Y,J as X,Q as Ee,U as De,V as Oe,W as ke,h as Ae,n as je}from"./pwa-Dc46OTi7.js";import{t as Me}from"./MobileOverlayPanel-XkMrn5-W.js";import{r as Ne}from"./worktreeManager-XchvRN9O.js";import{a as Pe,n as Fe,r as Ie,t as Le}from"./projectMeta-vIaGFaQr.js";import{r as Re}from"./markdown-worker-oBGEB9Eg.js";import{c as ze,l as Be,o as Ve,r as He}from"./quota-Cyq21PUF.js";import{t as Ue}from"./sessionOwnership-W4KQ8CbY.js";import{n as We,r as Ge}from"./SettingsGroup-YUId7nD5.js";import{t as Ke}from"./ModelSelector-DMmMUIB2.js";import{a as qe,d as Je,o as Ye,s as Xe}from"./vendor-codemirror-commands-5saeUOVY.js";import{a as Ze,c as Qe,i as $e,l as et,o as tt,r as nt,s as rt}from"./vendor-codemirror-search-hZY-L2l8.js";import{n as it,t as at}from"./vendor-replit-codemirror-vim-BmQmU1lR.js";import{t as ot}from"./vendor-codemirror-language-data-B3pLWvv-.js";var st=`/mcp/oauth/callback`,ct=e=>{if(typeof window>`u`)return null;try{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t.length%4==0?``:`=`.repeat(4-t.length%4),r=window.atob(t+n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return new TextDecoder().decode(i)}catch{return null}},lt=e=>{let t=dt(e.get(`state`));if(t)return t;let n=e.get(`server`);if(typeof n!=`string`||!n.trim())return null;let r=e.get(`directory`);return{name:n.trim(),directory:typeof r==`string`&&r.trim()?r.trim():null}},ut=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},dt=e=>{if(typeof e!=`string`||!e.trim())return null;let t=ct(e.trim());if(!t)return null;try{let e=JSON.parse(t);return e?.v!==1||typeof e.n!=`string`||!e.n.trim()?null:{name:e.n.trim(),directory:typeof e.d==`string`&&e.d.trim()?e.d.trim():null}}catch{return null}},Z=e(c(),1),ft=e(o(),1),pt=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,mt=e=>{let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=at(e);if(!n)return{top:!1,dom:t};n.state.statusbar=t;let r=n.state.vimPlugin;return pt(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function ht(e){return e?[it(),P.of(mt),_()]:[]}var Q=s(),gt={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},_t={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function vt(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries(gt)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(_t)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var yt=new WeakMap;function bt(e,t){let n=$e(e.state);if(!n.valid)return yt.delete(e),0;let r=yt.get(e);if(!t&&r?.doc===e.state.doc&&r.query.eq(n))return r.total;let i=n.getCursor(e.state),a=0;for(let e=i.next();!e.done;e=i.next())a+=1;return yt.set(e,{query:n,doc:e.state.doc,total:a}),a}function xt(e){let t=$e(e.state);if(!t.valid)return 0;let n=e.state.selection.main,r=t.getCursor(e.state),i=0,a=0;for(let e=r.next();!e.done;e=r.next()){let t=e.value;if(i+=1,a===0&&(a=i),n.from===t.from&&n.to===t.to||n.from<t.to&&n.to>t.from||t.from>=n.head)return i}return a}function St(e,t,n=!1){let r=e.querySelector(`.cm-search`);if(!r)return;let i=r.querySelector(`.cm-search-message`);if(!i){i=document.createElement(`span`),i.className=`cm-search-message`,i.setAttribute(`aria-live`,`polite`);let e=r.querySelector(`button[name="next"]`),t=e?.parentNode===r?e:r.firstChild;r.insertBefore(i,t)}let a=bt(t,n),o=a===0?0:xt(t);i.textContent=a===0?``:`${o}/${a}`}var Ct=new N,wt=new N,Tt=new N,Et=new N,Dt=new N,Ot=new N,kt=new N,At=(e=>e)(Qe.filter(e=>e.run!==Ze)),jt=m,Mt=tt,Nt=nt,Pt=class extends g{id;containerMap;constructor(e,t){super(),this.id=e,this.containerMap=t}toDOM(){let e=this.containerMap.get(this.id);return e||(e=document.createElement(`div`),e.className=`yuri-block-widget`,e.dataset.widgetId=this.id,this.containerMap.set(this.id,e)),e}eq(e){return e.id===this.id}destroy(){}},Ft=(e,t)=>!e||e.length===0?[]:O.define({create(n){let r=new M,i=[...e].sort((e,t)=>e.afterLine-t.afterLine);for(let e of i){let i=n.doc.lines;if(e.afterLine>i)continue;let a=n.doc.line(e.afterLine);r.add(a.to,a.to,b.widget({widget:new Pt(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>y.decorations.from(e)}),It=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return x.fromClass(class{decorations;constructor(e){this.decorations=this.build(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=this.build(e.view))}build(e){let r=new M;for(let i=t;i<=n&&i<=e.state.doc.lines;i+=1){let t=e.state.doc.line(i);r.add(t.from,t.from,b.line({class:`yuri-cm-selected-line`}))}return r.finish()}},{decorations:e=>e.decorations})};function Lt({value:e,onChange:t,extensions:n,className:r,readOnly:i,lineNumbersConfig:a,highlightLines:o,onViewReady:s,onViewDestroy:c,blockWidgets:l,enableSearch:u,searchOpen:d,onSearchOpenChange:f,vimMode:p}){let m=Z.useRef(null),h=Z.useRef(null),g=Z.useRef(e),_=Z.useRef(t),v=Z.useRef(s),b=Z.useRef(c),x=Z.useRef(f),T=Z.useRef(l),E=Z.useRef(p),D=Z.useRef(new Map),[O,ee]=Z.useState([]),j=Z.useCallback(e=>{let t=(e??[]).map(e=>{let t=D.current.get(e.id);return t?{id:e.id,content:e.content,container:t}:null}).filter(e=>e!==null);ee(e=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.content===r.content&&e.container===r.container})?e:t)},[]),M=Z.useCallback(e=>{let t=m.current,n=e??h.current;if(!t||!n)return;let r=n.dom.querySelector(`.cm-gutters`),i=r instanceof HTMLElement?r.getBoundingClientRect().width:0;t.style.setProperty(`--yuri-editor-gutter-width`,`${i}px`)},[]);return Z.useEffect(()=>{g.current=e},[e]),Z.useEffect(()=>{_.current=t},[t]),Z.useEffect(()=>{v.current=s,b.current=c},[s,c]),Z.useEffect(()=>{x.current=f},[f]),Z.useEffect(()=>{T.current=l,j(l)},[l,j]),Z.useEffect(()=>{if(!m.current)return;let e=(()=>{if(typeof document>`u`)return null;let e=document.querySelector(`meta[name="csp-nonce"]`)?.getAttribute(`content`);if(e)return e;let t=window.__YURI_CSP_NONCE__;return typeof t==`string`&&t.length>0?t:null})(),t=A.create({doc:g.current,extensions:[...e?[y.cspNonce.of(e)]:[],C({fixed:!0}),Ct.of(w(a)),Ye(),k.of(` `),kt.of(ht(p)),S.of([Je,...qe,...Xe]),y.updateListener.of(e=>{M(e.view),(e.viewportChanged||e.geometryChanged)&&j(T.current);let t=et(e.startState),n=et(e.state);t!==n&&x.current?.(n);let r=!$e(e.startState).eq($e(e.state));if(n&&(t!==n||r||e.docChanged||e.selectionSet)&&St(e.view.dom,e.view,t!==n||r||e.docChanged),!e.docChanged)return;let i=e.state.doc.toString();g.current=i,_.current(i),j(T.current)}),wt.of(y.editable.of(!i)),Tt.of(n??[]),Et.of(It(o)),Dt.of(Ft(l,D.current)),Ot.of(u?[rt({top:!0}),S.of(At)]:[])]});return h.current=new y({state:t,parent:m.current}),jt(h.current,h.current.state.doc.length,200),h.current.requestMeasure(),requestAnimationFrame(()=>{M(h.current),j(T.current)}),h.current&&v.current?.(h.current),()=>{b.current?.(),h.current?.destroy(),h.current=null,ee([])}},[T,M,j]),Z.useEffect(()=>{let e=h.current;e&&(e.dispatch({effects:[Ct.reconfigure(w(a)),wt.reconfigure(y.editable.of(!i)),Tt.reconfigure(n??[]),Et.reconfigure(It(o)),Dt.reconfigure(Ft(l,D.current)),Ot.reconfigure(u?[rt({top:!0}),S.of(At)]:[])]}),jt(e,e.state.doc.length,200),e.requestMeasure(),requestAnimationFrame(()=>{M(e),j(T.current)}))},[n,o,a,i,l,u,M,j]),Z.useEffect(()=>{let e=h.current;if(!e){E.current=p;return}E.current!==p&&(E.current=p,e.dispatch({effects:kt.reconfigure(ht(p))}))},[p]),Z.useEffect(()=>{let e=h.current;!e||u===!1||(d?(Mt(e),requestAnimationFrame(()=>{vt(e.dom),St(e.dom,e,!0)})):Nt(e))},[d,u]),Z.useEffect(()=>{let t=h.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),jt(t,t.state.doc.length,300),t.requestMeasure(),requestAnimationFrame(()=>M(t)))},[e,M]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:m,className:K(`h-full w-full`,`[&_.cm-editor]:h-full [&_.cm-editor]:w-full`,`[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6`,`[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]`,r)}),O.map(e=>(0,ft.createPortal)(e.content,e.container,e.id))]})}var Rt=E.define(B),zt=z.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function Bt(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return Rt;case`json`:case`jsonc`:case`json5`:return R().language;case`js`:case`javascript`:return I().language;case`jsx`:return I({jsx:!0}).language;case`ts`:case`typescript`:return I({typescript:!0}).language;case`tsx`:return I({typescript:!0,jsx:!0}).language;case`html`:return L().language;case`css`:return F().language;case`py`:case`python`:return ne().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return te().language;case`heex`:case`eex`:case`leex`:return L().language;default:return ee.matchLanguageName(ot,t,!0)}}var Vt=e=>e.split(`/`).pop()?.toLowerCase()??``,Ht=e=>{let t=Vt(e);return t?ee.matchFilename(ot,t):null},Ut=()=>h(T.define([{tag:[p.heading1,p.heading2,p.heading3,p.heading4,p.heading5,p.heading6],fontWeight:`600`},{tag:p.strong,fontWeight:`600`},{tag:p.emphasis,fontStyle:`italic`},{tag:p.strikethrough,textDecoration:`line-through`},{tag:[p.link,p.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:p.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:p.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:p.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:p.heading,color:`var(--markdown-heading1, currentColor)`}]));function Wt(e){let t=e.toLowerCase();switch(Vt(t)){case`makefile`:case`gnumakefile`:return Rt}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return I({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return I({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[R(),zt];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return R();case`css`:case`scss`:case`sass`:case`less`:return F();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return L();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[te({codeLanguages:Bt}),Ut()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return Rt;case`py`:case`pyw`:case`pyi`:return ne();default:return null}}async function Gt(e){let t=Ht(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}function Kt(e,t){let n=e.metadata.variant===`dark`,r=e.config?.fonts?.mono||`monospace`,i=e.colors.syntax.highlights||{},a=e.colors.syntax.tokens||{},o=t?.fontSize?`${t.fontSize}px`:`var(--text-code)`,s=y.theme({"&":{backgroundColor:`var(--background)`,color:e.colors.syntax.base.foreground,fontSize:o,lineHeight:`1.5`,position:`relative`},".cm-scroller":{fontFamily:r,backgroundColor:`var(--background)`},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:a.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:a.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:a.boolean||e.colors.syntax.base.number},".cm-builtin":{color:a.functionCall||e.colors.syntax.base.function},".cm-def":{color:a.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:a.variableOther||a.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:a.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:a.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:a.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:a.tag||e.colors.syntax.base.keyword},".cm-link":{color:a.url||e.colors.syntax.base.keyword,textDecoration:`underline`},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:`var(--background)`,color:i.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:`sticky`,paddingRight:`8px`,left:0,zIndex:2,boxShadow:`0 0 0 var(--background)`},".cm-gutter":{backgroundColor:`var(--background)`},".cm-gutterElement":{backgroundColor:`var(--background)`},".cm-lineNumbers":{backgroundColor:`var(--background)`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`8px`,paddingRight:`8px`,minWidth:`42px`},".cm-activeLineGutter":{color:i.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-foldPlaceholder":{backgroundColor:e.colors.surface.muted,color:e.colors.surface.foreground,borderColor:e.colors.interactive.border},".cm-panels":{backgroundColor:`transparent`,color:e.colors.surface.foreground,position:`absolute`,top:`0`,right:`0`,left:`auto`,width:`auto`,zIndex:10,pointerEvents:`none`},".cm-panels-top":{borderBottom:`none`,position:`absolute`,top:`6px`,right:`14px`,left:`auto`,width:`auto`},".cm-panels-bottom":{position:`static`,width:`100%`,pointerEvents:`auto`},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.mutedForeground,fontFamily:`var(--font-mono)`,fontSize:`12px`,minHeight:`22px`,padding:`2px 8px`},".cm-panel.cm-search":{pointerEvents:`auto`,padding:`4px`,backgroundColor:`color-mix(in srgb, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:`10px`,boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:`auto`,minWidth:`360px`,maxWidth:`480px`},".cm-search":{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`0`,width:`100%`,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`13px`,lineHeight:`1`},".cm-search br":{display:`none`},".cm-search .cm-textfield":{appearance:`none`,height:`26px`,margin:0,padding:`0 8px`,borderRadius:`6px !important`,border:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`12px`,lineHeight:`1`,outline:`none`,transition:`border-color 150ms ease`},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:`1 1 120px`,maxWidth:`calc(100% - 142px)`,minWidth:`100px`},".cm-search label":{order:2,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`1px solid transparent`,backgroundColor:`transparent`,color:`transparent`,cursor:`pointer`,userSelect:`none`,fontSize:`1px`,lineHeight:`0`,overflow:`hidden`,position:`relative`,transition:`background-color 120ms ease, border-color 120ms ease`},".cm-search label:hover":{backgroundColor:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:`none`,WebkitAppearance:`none`,width:`0`,height:`0`,margin:`0`,padding:`0`,border:`none`,position:`absolute`,opacity:`0`,pointerEvents:`none`},".cm-search label::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`13px`,fontWeight:`600`,lineHeight:`1`,fontFamily:`inherit`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:`"Aa"`,fontSize:`12px`,letterSpacing:`-0.5px`},'.cm-search label:has(input[name="re"])::after':{content:`".*"`,fontSize:`13px`,fontFamily:`monospace`},'.cm-search label:has(input[name="word"])::after':{content:`"ab"`,fontSize:`12px`,textDecoration:`underline`,textUnderlineOffset:`2px`},".cm-search .cm-search-message":{order:3,color:e.colors.surface.mutedForeground,backgroundColor:`transparent`,border:`none`,borderRadius:`0`,padding:`0 6px`,fontSize:`11px`,whiteSpace:`nowrap`,lineHeight:`26px`},".cm-search .cm-button":{appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:`transparent`,cursor:`pointer`,fontSize:`1px`,fontWeight:`400`,lineHeight:`0`,overflow:`hidden`,position:`relative`,boxShadow:`none`,transition:`background-color 120ms ease`},".cm-search .cm-button::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`15px`,lineHeight:`1`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:`none`,boxShadow:`0 0 0 1px ${e.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:`default`,pointerEvents:`none`},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:`2px`},'.cm-search .cm-button[name="prev"]::after':{content:`"↑"`},'.cm-search .cm-button[name="next"]':{order:22,marginTop:`2px`},'.cm-search .cm-button[name="next"]::after':{content:`"↓"`},'.cm-search .cm-button[name="select"]':{order:23,marginTop:`2px`},'.cm-search .cm-button[name="select"]::after':{content:`"≡"`,fontSize:`17px`},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:`0 0 0 auto`,padding:`0`,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:e.colors.surface.mutedForeground,cursor:`pointer`,fontSize:`16px`,lineHeight:`1`,boxShadow:`none`,position:`relative`,overflow:`visible`,transition:`background-color 120ms ease, color 120ms ease`},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:e.colors.interactive.hover,color:e.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:`2px`},'.cm-search .cm-button[name="replace"]::after':{content:`"⇄"`},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:`2px`},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:`"⇉"`},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:`1 1 100%`,maxWidth:`calc(100% - 142px)`,minWidth:`80px`,marginTop:`2px`},".cm-searchMatch":{backgroundColor:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:`2px`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:`none`}},{dark:n}),c=T.define([{tag:[p.comment,p.docComment,p.meta,p.documentMeta],class:`cm-comment`},{tag:[p.keyword,p.controlKeyword,p.moduleKeyword,p.definitionKeyword,p.modifier],class:`cm-keyword`},{tag:[p.operatorKeyword,p.operator,p.derefOperator,p.updateOperator,p.definitionOperator,p.typeOperator,p.controlOperator,p.logicOperator,p.bitwiseOperator,p.arithmeticOperator,p.compareOperator],class:`cm-operator`},{tag:[p.punctuation,p.separator,p.bracket,p.paren,p.brace,p.squareBracket,p.angleBracket],class:`cm-punctuation`},{tag:[p.string,p.regexp,p.attributeValue,p.special(p.string),p.monospace],class:`cm-string`},{tag:p.escape,class:`cm-string-2`},{tag:[p.number,p.bool,p.atom,p.null,p.self],class:`cm-number`},{tag:[p.function(p.variableName),p.function(p.definition(p.variableName)),p.function(p.propertyName),p.standard(p.variableName),p.special(p.variableName)],class:`cm-builtin`},{tag:p.definition(p.variableName),class:`cm-def`},{tag:[p.variableName,p.local(p.variableName),p.constant(p.variableName),p.literal],class:`cm-variable`},{tag:p.propertyName,class:`cm-property`},{tag:p.attributeName,class:`cm-attribute`},{tag:[p.className,p.typeName,p.namespace],class:`cm-variable-3`},{tag:[p.tagName,p.labelName,p.annotation,p.macroName],class:`cm-tag`},{tag:p.link,class:`cm-link`},{tag:[p.heading,p.heading1,p.heading2,p.heading3,p.heading4,p.heading5,p.heading6],class:`cm-keyword`}]),l=T.define([{tag:[p.comment,p.docComment,p.meta,p.documentMeta],color:e.colors.syntax.base.comment},{tag:[p.keyword,p.controlKeyword,p.moduleKeyword,p.definitionKeyword,p.modifier],color:e.colors.syntax.base.keyword},{tag:[p.operatorKeyword,p.operator,p.derefOperator,p.updateOperator,p.definitionOperator,p.typeOperator,p.controlOperator,p.logicOperator,p.bitwiseOperator,p.arithmeticOperator,p.compareOperator],color:e.colors.syntax.base.operator},{tag:[p.string,p.regexp,p.attributeValue,p.special(p.string),p.monospace],color:e.colors.syntax.base.string},{tag:p.escape,color:a.stringEscape||e.colors.syntax.base.string},{tag:[p.number,p.bool,p.atom,p.null,p.self],color:e.colors.syntax.base.number},{tag:[p.function(p.variableName),p.function(p.definition(p.variableName)),p.function(p.propertyName),p.standard(p.variableName),p.special(p.variableName)],color:e.colors.syntax.base.function},{tag:p.definition(p.variableName),color:a.variableGlobal||e.colors.syntax.base.variable},{tag:[p.variableName,p.local(p.variableName),p.constant(p.variableName),p.literal],color:e.colors.syntax.base.variable},{tag:p.propertyName,color:a.variableProperty||e.colors.syntax.base.variable},{tag:p.attributeName,color:a.variableOther||e.colors.syntax.base.variable},{tag:[p.className,p.typeName,p.namespace],color:e.colors.syntax.base.type},{tag:[p.tagName,p.labelName,p.annotation,p.macroName],color:a.tag||e.colors.syntax.base.keyword},{tag:p.link,color:a.url||e.colors.syntax.base.function,textDecoration:`underline`},{tag:[p.punctuation,p.separator,p.bracket,p.paren,p.brace,p.squareBracket,p.angleBracket],color:a.punctuation||e.colors.syntax.base.comment}]);return t?.syntaxColors===!1?[s]:[s,h(D,{fallback:!0}),h(v),h(c),h(l)]}var qt=180,Jt=j.define(),Yt=1,Xt=2,Zt=4,Qt=new Map,$t=(e,t)=>{let n=`${e}|${t}`,r=Qt.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&Yt&&(i+=`font-style:italic;`),t&Xt&&(i+=`font-weight:bold;`),t&Zt&&(i+=`text-decoration:underline;`);let a=b.mark({attributes:{style:i}});return Qt.set(n,a),a},en=(e,t)=>{let n=new M,r=e.state.doc,i=Math.min(t.length,r.lines);for(let e=0;e<i;e+=1){let i=t[e];if(!i||i.length===0)continue;let a=r.line(e+1),o=a.from;for(let[e,t,r]of i){if(e<=0)continue;let i=o,s=Math.min(o+e,a.to);o+=e,!(s<=i)&&(!t&&!r||n.add(i,s,$t(t,r)))}}return n.finish()},tn=O.define({create(){return b.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(Jt)&&(n=e.value);return n},provide:e=>y.decorations.from(e)}),nn=e=>x.fromClass(class{timer;generation=0;abortController;constructor(e){this.tokenize(e)}update(e){e.docChanged&&this.schedule(e.view)}schedule(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(e)},qt)}async tokenize(t){let n=++this.generation;this.abortController?.abort();let r=new AbortController;this.abortController=r;let i=t.state.doc.toString(),a=await Re(i,e.language,e.themeName,e.theme,{signal:r.signal,priority:`visible`});a&&(r.signal.aborted||n===this.generation&&t.state.doc.length===i.length&&t.dispatch({effects:Jt.of(en(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),rn=e=>[tn,nn(e)],an=d(),on=e=>{let t=(0,an.c)(11),{currentMode:n,onToggle:r}=e,i=n===`preview`,a=i?`Switch to edit mode`:`Switch to preview mode`,o=i?`Edit`:`Preview`,s;t[0]===i?s=t[1]:(s=i?(0,Q.jsx)(J,{name:`eye`,className:`size-4`,"aria-hidden":`true`}):(0,Q.jsx)(J,{name:`eye-off`,className:`size-4`,"aria-hidden":`true`}),t[0]=i,t[1]=s);let c;t[2]!==a||t[3]!==r||t[4]!==s?(c=(0,Q.jsx)(me,{asChild:!0,children:(0,Q.jsx)(W,{variant:`ghost`,size:`sm`,onClick:r,"aria-label":a,className:`h-5 w-5 p-0`,children:s})}),t[2]=a,t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,Q.jsx)(he,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Q.jsxs)(ge,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},sn=e=>{let t=(0,an.c)(27),{title:n,settingsItem:r,children:i,collapsible:a,count:o}=e,s=a!==void 0&&a,[c,l]=Z.useState(!1);if(s){let e;t[0]===n?e=t[1]:(e=(0,Q.jsx)(`span`,{className:`typography-ui-label min-w-0 truncate`,children:n}),t[0]=n,t[1]=e);let a;t[2]===o?a=t[3]:(a=o===void 0?null:(0,Q.jsx)(`span`,{className:`typography-meta tabular-nums`,children:o}),t[2]=o,t[3]=a);let s=c?`arrow-down-s`:`arrow-right-s`,u;t[4]===s?u=t[5]:(u=(0,Q.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center`,children:(0,Q.jsx)(J,{name:s,className:`size-4`})}),t[4]=s,t[5]=u);let d;t[6]!==a||t[7]!==u?(d=(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-muted-foreground`,children:[a,u]}),t[6]=a,t[7]=u,t[8]=d):d=t[8];let f;t[9]!==e||t[10]!==d?(f=(0,Q.jsx)(`div`,{className:`yuri-settings-group-row flex items-center gap-2`,children:(0,Q.jsxs)(be,{className:`min-w-0 flex-1 gap-2 p-0 hover:bg-transparent focus-visible:ring-[var(--interactive-focus-ring)]`,children:[e,d]})}),t[9]=e,t[10]=d,t[11]=f):f=t[11];let p;t[12]===i?p=t[13]:(p=(0,Q.jsx)(ye,{keepMounted:!0,children:(0,Q.jsx)(`div`,{className:`yuri-settings-group-row`,children:i})}),t[12]=i,t[13]=p);let m;t[14]!==f||t[15]!==p?(m=(0,Q.jsxs)(We,{children:[f,p]}),t[14]=f,t[15]=p,t[16]=m):m=t[16];let h;return t[17]!==c||t[18]!==r||t[19]!==m?(h=(0,Q.jsx)(xe,{open:c,onOpenChange:l,"data-settings-item":r,children:m}),t[17]=c,t[18]=r,t[19]=m,t[20]=h):h=t[20],h}let u;t[21]===i?u=t[22]:(u=(0,Q.jsx)(`div`,{className:`yuri-settings-group-row`,children:i}),t[21]=i,t[22]=u);let d;return t[23]!==r||t[24]!==u||t[25]!==n?(d=(0,Q.jsx)(We,{label:n,itemId:r,children:u}),t[23]=r,t[24]=u,t[25]=n,t[26]=d):d=t[26],d},cn=({projectRef:e=null,collapsible:t=!1})=>{let{t:n}=le(),{isMobile:r,isTablet:i}=ve(),a=r||i,o=V(e=>e.getActiveProject()),s=e?.path??o?.path??null,c=se(e=>e.getWorktreeMetadata),u=oe(),d=l(e=>e.homeDirectory),[f,p]=Z.useState(null),[m,h]=Z.useState([]),[g,_]=Z.useState(!1),v=Z.useMemo(()=>e?.id&&e?.path?{id:e.id,path:e.path}:!o?.id||!s?null:{id:o.id,path:s},[o?.id,s,e?.id,e?.path]),y=Z.useCallback(async()=>{if(!(!v||f===!1))try{let e=await Ne(v);h(e)}catch{}},[v,f]);Z.useEffect(()=>{if(!s)return;let e=!1;return p(null),(async()=>{try{let t=await Se(s);if(e)return;p(t)}catch{}})(),()=>{e=!0}},[s]),Z.useEffect(()=>{if(!v){h([]),_(!1);return}if(f===!1){h([]),_(!1);return}let e=!1;return _(!0),h([]),(async()=>{try{let t=await Ne(v);if(e)return;h(t)}catch{}finally{e||_(!1)}})(),()=>{e=!0}},[v,f]);let b=Z.useCallback(e=>{let t=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t(e.path),r=u.filter(e=>{let r=c(e.id);if(r?.path&&t(r.path)===n)return!0;let i=e.directory;return!!(i&&t(i)===n)}),i=new Set(r.map(e=>e.id)),a=[...H.getState().activeSessions,...H.getState().archivedSessions],o=e=>{let t=a.filter(t=>{let n=t.parentID;return n&&e.has(n)});if(t.length===0)return[];let n=new Set(t.map(e=>e.id));return[...t,...o(n)]},s=o(i),l=new Set,d=[...r,...s].filter(e=>!l.has(e.id)&&(l.add(e.id),!0));ae.requestDelete({sessions:d,mode:`worktree`,worktree:e})},[u,c]),x=Z.useMemo(()=>u.map(e=>e.id).join(`,`),[u]);return Z.useEffect(()=>{f&&s&&y()},[x,f,s,y]),s?f===!1?(0,Q.jsx)(sn,{title:n(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n(`settings.yuri.worktrees.state.gitOnly`)})}):(0,Q.jsx)(sn,{title:n(`settings.yuri.worktrees.list.title`),settingsItem:`projects.worktree`,collapsible:t,count:g?void 0:m.length,children:g?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n(`settings.yuri.worktrees.list.loading`)}):m.length===0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground/70`,children:n(`settings.yuri.worktrees.list.empty`)}):(0,Q.jsx)(`div`,{className:`w-full space-y-1`,children:m.map(e=>(0,Q.jsxs)(`div`,{className:`group flex w-full items-center gap-2 py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Q.jsx)(`p`,{className:`typography-meta min-w-0 truncate text-foreground`,children:e.label||e.branch||n(`settings.yuri.worktrees.list.detachedHead`)})}),(0,Q.jsx)(`p`,{className:`typography-micro truncate text-muted-foreground/60`,children:G(e.path,d)})]}),(0,Q.jsx)(W,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>b(e),className:K(`text-muted-foreground transition-opacity focus-visible:opacity-100`,a?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":n(`settings.yuri.worktrees.list.deleteWorktreeAria`,{name:e.branch||e.label||e.path}),children:(0,Q.jsx)(J,{name:`delete-bin`,className:`h-4 w-4`})})]},e.path))})}):(0,Q.jsx)(sn,{title:n(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n(`settings.yuri.worktrees.state.selectProject`)})})},ln=e=>{let t=(0,an.c)(127),{form:n}=e,{t:r}=le(),{currentTheme:i}=_e(),{name:a,setName:o,icon:s,setIcon:c,color:l,setColor:u,iconBackground:d,setIconBackground:f,parsedDefaultModel:p,handleDefaultModelChange:m,isUploadingIcon:h,isRemovingCustomIcon:g,isDiscoveringIcon:_,pendingRemoveImageIcon:v,setPendingRemoveImageIcon:y,pendingUploadIconPreviewUrl:b,setPreviewImageFailed:x,hasPendingUploadImageIcon:S,hasCustomIcon:C,effectiveHasImageIcon:w,hasRemovableImageIcon:T,showImagePreview:E,fileInputRef:D,handleUploadIcon:O,handleRemoveImageIcon:k,handleDiscoverIcon:ee,currentIconImage:A,project:j}=n;if(!j)return null;let M=l?Fe[l]??null:null,N;t[0]===r?N=t[1]:(N=r(`settings.projects.page.field.projectName`),t[0]=r,t[1]=N);let P;t[2]===o?P=t[3]:(P=e=>o(e.target.value),t[2]=o,t[3]=P);let F;t[4]===r?F=t[5]:(F=r(`settings.projects.page.field.projectNamePlaceholder`),t[4]=r,t[5]=F);let I;t[6]===r?I=t[7]:(I=r(`settings.projects.page.field.projectName`),t[6]=r,t[7]=I);let L;t[8]!==a||t[9]!==P||t[10]!==F||t[11]!==I?(L=(0,Q.jsx)(Ce,{value:a,onChange:P,placeholder:F,"aria-label":I}),t[8]=a,t[9]=P,t[10]=F,t[11]=I,t[12]=L):L=t[12];let R;t[13]!==N||t[14]!==L?(R=(0,Q.jsx)(Ge,{label:N,itemId:`projects.name`,children:L}),t[13]=N,t[14]=L,t[15]=R):R=t[15];let z;t[16]===r?z=t[17]:(z=r(`settings.yuri.defaults.field.defaultModel`),t[16]=r,t[17]=z);let te=p.providerId,ne=p.modelId,B;t[18]===r?B=t[19]:(B=r(`settings.yuri.defaults.option.default`),t[18]=r,t[19]=B);let V;t[20]!==m||t[21]!==p.modelId||t[22]!==p.providerId||t[23]!==B?(V=(0,Q.jsx)(Ke,{providerId:te,modelId:ne,onChange:m,className:`yuri-settings-inline-value`,placeholder:B,showIcon:!1}),t[20]=m,t[21]=p.modelId,t[22]=p.providerId,t[23]=B,t[24]=V):V=t[24];let re;t[25]!==V||t[26]!==z?(re=(0,Q.jsx)(Ge,{label:z,itemId:`projects.default-model`,children:V}),t[25]=V,t[26]=z,t[27]=re):re=t[27];let H;t[28]===r?H=t[29]:(H=r(`settings.projects.page.field.accentColor`),t[28]=r,t[29]=H);let U;t[30]===u?U=t[31]:(U=()=>u(null),t[30]=u,t[31]=U);let ie=l===null,ae;t[32]===r?ae=t[33]:(ae=r(`settings.projects.page.field.none`),t[32]=r,t[33]=ae);let oe;t[34]===r?oe=t[35]:(oe=r(`settings.projects.page.field.none`),t[34]=r,t[35]=oe);let se;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsx)(J,{name:`close`,className:`size-4 text-muted-foreground`}),t[36]=se):se=t[36];let G;t[37]!==U||t[38]!==ie||t[39]!==ae||t[40]!==oe?(G=(0,Q.jsx)(W,{type:`button`,variant:`chip`,size:`icon`,onClick:U,"aria-pressed":ie,"aria-label":ae,title:oe,children:se}),t[37]=U,t[38]=ie,t[39]=ae,t[40]=oe,t[41]=G):G=t[41];let K;t[42]!==l||t[43]!==u?(K=Le.map(e=>(0,Q.jsx)(W,{type:`button`,variant:`chip`,size:`icon`,onClick:()=>u(e.key),"aria-pressed":l===e.key,"aria-label":e.label,title:e.label,children:(0,Q.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full`,style:{backgroundColor:e.cssVar},children:l===e.key?(0,Q.jsx)(J,{name:`check`,className:`size-3 text-foreground`}):null})},e.key)),t[42]=l,t[43]=u,t[44]=K):K=t[44];let q;t[45]!==G||t[46]!==K?(q=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pt-2`,children:[G,K]}),t[45]=G,t[46]=K,t[47]=q):q=t[47];let ce;t[48]!==H||t[49]!==q?(ce=(0,Q.jsx)(Ge,{label:H,itemId:`projects.accent-color`,footer:q,children:null}),t[48]=H,t[49]=q,t[50]=ce):ce=t[50];let ue;t[51]===r?ue=t[52]:(ue=r(`settings.projects.page.field.projectIcon`),t[51]=r,t[52]=ue);let de;t[53]===O?de=t[54]:(de=e=>{let t=e.target.files?.[0]??null;O(t),e.currentTarget.value=``},t[53]=O,t[54]=de);let fe;t[55]!==D||t[56]!==de?(fe=(0,Q.jsx)(`input`,{ref:D,type:`file`,accept:`image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg`,className:`hidden`,onChange:de}),t[55]=D,t[56]=de,t[57]=fe):fe=t[57];let pe;t[58]===c?pe=t[59]:(pe=()=>c(null),t[58]=c,t[59]=pe);let me=s===null,he;t[60]===r?he=t[61]:(he=r(`settings.projects.page.field.none`),t[60]=r,t[61]=he);let ge;t[62]===r?ge=t[63]:(ge=r(`settings.projects.page.field.none`),t[62]=r,t[63]=ge);let ve;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,Q.jsx)(J,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[64]=ve):ve=t[64];let ye;t[65]!==pe||t[66]!==me||t[67]!==he||t[68]!==ge?(ye=(0,Q.jsx)(W,{type:`button`,variant:`chip`,size:`icon`,onClick:pe,"aria-pressed":me,"aria-label":he,title:ge,children:ve}),t[65]=pe,t[66]=me,t[67]=he,t[68]=ge,t[69]=ye):ye=t[69];let be;t[70]!==M||t[71]!==s||t[72]!==c?(be=Ie.map(e=>{let t=e.Icon;return(0,Q.jsx)(W,{type:`button`,variant:`chip`,size:`icon`,onClick:()=>c(e.key),"aria-pressed":s===e.key,"aria-label":e.label,title:e.label,children:(0,Q.jsx)(J,{name:t,className:`w-4 h-4`,style:M&&s===e.key?{color:M}:void 0})},e.key)}),t[70]=M,t[71]=s,t[72]=c,t[73]=be):be=t[73];let xe;t[74]!==ye||t[75]!==be?(xe=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[ye,be]}),t[74]=ye,t[75]=be,t[76]=xe):xe=t[76];let Se;t[77]!==A||t[78]!==i||t[79]!==w||t[80]!==S||t[81]!==d||t[82]!==b||t[83]!==j||t[84]!==x||t[85]!==E?(Se=w&&E&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2 pt-1`,children:(0,Q.jsx)(`span`,{className:`inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1`,children:(0,Q.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]`,style:d?{backgroundColor:d}:void 0,children:S&&b?(0,Q.jsx)(`img`,{src:b,alt:``,className:`h-full w-full object-contain`,draggable:!1,onError:()=>x(!0)}):(0,Q.jsx)(Pe,{project:{...j,iconImage:A??j.iconImage},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:`h-full w-full object-contain`,onError:()=>x(!0)})})})}),t[77]=A,t[78]=i,t[79]=w,t[80]=S,t[81]=d,t[82]=b,t[83]=j,t[84]=x,t[85]=E,t[86]=Se):Se=t[86];let we;t[87]!==w||t[88]!==d||t[89]!==f||t[90]!==r?(we=w&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`color`,value:d??`#000000`,onChange:e=>f(e.target.value),className:`h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1`,"aria-label":r(`settings.projects.page.field.projectIconBackgroundAria`)}),(0,Q.jsx)(Ce,{value:d??``,onChange:e=>f(e.target.value),"aria-label":r(`settings.projects.page.field.projectIconBackgroundAria`),placeholder:`#000000`,className:`h-7 w-[8rem]`}),(0,Q.jsx)(W,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>f(null),"aria-label":r(`settings.projects.page.field.clearIconBackgroundAria`),title:r(`settings.projects.page.field.clearBackground`),disabled:!d,children:(0,Q.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]}),t[87]=w,t[88]=d,t[89]=f,t[90]=r,t[91]=we):we=t[91];let Te;t[92]!==D||t[93]!==ee||t[94]!==C||t[95]!==_||t[96]!==h||t[97]!==r?(Te=!C&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(W,{size:`xs`,onClick:()=>D.current?.click(),disabled:h,children:r(h?`settings.projects.page.actions.uploading`:`settings.projects.page.actions.uploadIcon`)}),(0,Q.jsx)(W,{size:`xs`,variant:`outline`,onClick:()=>void ee(),disabled:_,children:r(_?`settings.projects.page.actions.discovering`:`settings.projects.page.actions.discoverFavicon`)})]}),t[92]=D,t[93]=ee,t[94]=C,t[95]=_,t[96]=h,t[97]=r,t[98]=Te):Te=t[98];let Y;t[99]!==k||t[100]!==T||t[101]!==g||t[102]!==r?(Y=T&&(0,Q.jsx)(W,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>void k(),disabled:g,children:r(g?`settings.projects.page.actions.removing`:`settings.projects.page.actions.removeProjectIcon`)}),t[99]=k,t[100]=T,t[101]=g,t[102]=r,t[103]=Y):Y=t[103];let X;t[104]!==g||t[105]!==v||t[106]!==y||t[107]!==r?(X=v&&(0,Q.jsx)(W,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>y(!1),disabled:g,children:r(`settings.projects.page.actions.undoRemove`)}),t[104]=g,t[105]=v,t[106]=y,t[107]=r,t[108]=X):X=t[108];let Ee;t[109]!==Te||t[110]!==Y||t[111]!==X?(Ee=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[Te,Y,X]}),t[109]=Te,t[110]=Y,t[111]=X,t[112]=Ee):Ee=t[112];let De;t[113]!==fe||t[114]!==xe||t[115]!==Se||t[116]!==we||t[117]!==Ee?(De=(0,Q.jsxs)(`div`,{className:`flex w-full flex-col items-start gap-2 pt-2`,children:[fe,xe,Se,we,Ee]}),t[113]=fe,t[114]=xe,t[115]=Se,t[116]=we,t[117]=Ee,t[118]=De):De=t[118];let Oe;t[119]!==ue||t[120]!==De?(Oe=(0,Q.jsx)(Ge,{label:ue,itemId:`projects.icon`,footer:De,children:null}),t[119]=ue,t[120]=De,t[121]=Oe):Oe=t[121];let ke;return t[122]!==re||t[123]!==ce||t[124]!==Oe||t[125]!==R?(ke=(0,Q.jsxs)(We,{children:[R,re,ce,Oe]}),t[122]=re,t[123]=ce,t[124]=Oe,t[125]=R,t[126]=ke):ke=t[126],ke},un=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,dn=e=>{if(!e)return null;let t=e.trim();return t&&un.test(t)?t.toLowerCase():null},fn=e=>{let{t}=le(),n=V(e=>e.uploadProjectIcon),r=V(e=>e.removeProjectIcon),i=V(e=>e.discoverProjectIcon),a=V(t=>e?t.projects.find(t=>t.id===e.id)?.iconImage??null:null),[o,s]=Z.useState(``),[c,l]=Z.useState(null),[u,d]=Z.useState(null),[f,p]=Z.useState(null),[m,h]=Z.useState(void 0),[g,_]=Z.useState(!1),[v,y]=Z.useState(!1),[b,x]=Z.useState(!1),[S,C]=Z.useState(!1),[w,T]=Z.useState(null),[E,D]=Z.useState(null),[O,k]=Z.useState(!1),ee=Z.useRef(null),A=Z.useCallback(()=>{T(null),D(e=>(e&&URL.revokeObjectURL(e),null))},[]),j=e?.id??null;Z.useEffect(()=>{if(!e){s(``),l(null),d(null),p(null),h(void 0);return}s(e.label??``),l(e.icon??null),d(e.color??null),p(e.iconBackground??null),h(e.defaultModel),C(!1),A(),k(!1)},[e,A]),Z.useEffect(()=>()=>{A()},[A]);let M=Z.useMemo(()=>re(m)??{providerId:``,modelId:``},[m]),N=!!e?.iconImage,P=!!(w&&E),F=e?.iconImage?.source===`custom`,I=N&&!S||P,L=I,R=!!(e&&N&&!S),z=!O&&(P||R),te=!!e&&(o.trim()!==(e?.label??``).trim()||c!==(e?.icon??null)||u!==(e?.color??null)||f!==(e?.iconBackground??null)||(m??void 0)!==(e?.defaultModel??void 0)||S||!!w),ne=Z.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),B=Z.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),H=Z.useCallback(()=>{!e||!L||v||(P&&A(),C(!!N),k(!1))},[A,P,L,N,v,e]),U=Z.useCallback(async()=>{if(!(!e||b)){A(),C(!1),k(!1),x(!0);try{let n=await i(e.id);if(!n.ok){q.error(n.error||t(`settings.projects.page.toast.discoverIconFailed`));return}if(n.skipped){q.success(t(`settings.projects.page.toast.customIconAlreadySet`));return}q.success(t(`settings.projects.page.toast.iconDiscovered`))}finally{x(!1)}}},[A,i,b,e,t]),ie=Z.useCallback(async i=>{let a=i?.silent===!0;if(!e)return null;let s=o.trim();if(!s)return null;if(w){_(!0);let r=await n(e.id,w);if(_(!1),!r.ok)return q.error(r.error||t(`settings.projects.page.toast.uploadIconFailed`)),null;a||q.success(t(`settings.projects.page.toast.iconUpdated`)),A(),C(!1)}let l=S&&!!e.iconImage;if(l){y(!0);let n=await r(e.id);if(y(!1),!n.ok)return q.error(n.error||t(`settings.projects.page.toast.removeIconFailed`)),null;a||q.success(t(`settings.projects.page.toast.iconRemoved`)),C(!1),p(null)}return{label:s,icon:c,color:u,iconBackground:dn(l?null:f),defaultModel:m??null}},[A,u,m,c,f,o,S,w,e,r,t,n]);return Z.useEffect(()=>{k(!1)},[j,a?.updatedAt]),{name:o,setName:s,icon:c,setIcon:l,color:u,setColor:d,iconBackground:f,setIconBackground:p,defaultModel:m,parsedDefaultModel:M,handleDefaultModelChange:ne,isUploadingIcon:g,isRemovingCustomIcon:v,isDiscoveringIcon:b,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:C,pendingUploadIconFile:w,pendingUploadIconPreviewUrl:E,previewImageFailed:O,setPreviewImageFailed:k,hasStoredImageIcon:N,hasPendingUploadImageIcon:P,hasCustomIcon:F,effectiveHasImageIcon:I,hasRemovableImageIcon:L,showStoredImagePreview:R,showImagePreview:z,fileInputRef:ee,clearPendingUploadIcon:A,handleUploadIcon:B,handleRemoveImageIcon:H,handleDiscoverIcon:U,hasChanges:te,prepareSaveData:ie,currentIconImage:a,project:e}},pn=450,mn=(e,t)=>{let{t:n}=le(),{hasChanges:r,name:i,icon:a,color:o,iconBackground:s,defaultModel:c,pendingRemoveImageIcon:l,pendingUploadIconFile:u,isUploadingIcon:d,isRemovingCustomIcon:f,prepareSaveData:p}=e,m=Z.useRef(!1);Z.useEffect(()=>{if(!r||!i.trim()||d||f||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{let e=await p({silent:!0});if(e)try{await t(e)}catch{q.error(n(`settings.projects.page.toast.saveFailed`))}}finally{m.current=!1}})())},pn);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},hn=e=>{let t=(0,an.c)(22),{project:n,onIdentitySave:r,compact:i}=e,a=i!==void 0&&i,{t:o}=le(),s=fn(n),c;bb0:{if(!n){c=null;break bb0}let e;t[0]!==n.id||t[1]!==n.path?(e={id:n.id,path:n.path},t[0]=n.id,t[1]=n.path,t[2]=e):e=t[2],c=e}let l=c;if(mn(s,r),!n||!l)return null;let u;t[3]!==n.path||t[4]!==o?(u=n.path.split(/[\\/]/).filter(Boolean).at(-1)??o(`settings.projects.page.title.default`),t[3]=n.path,t[4]=o,t[5]=u):u=t[5];let d=u,f;t[6]===d?f=t[7]:(f=(0,Q.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:d}),t[6]=d,t[7]=f);let p;t[8]===n.path?p=t[9]:(p=(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,title:n.path,children:n.path}),t[8]=n.path,t[9]=p);let m;t[10]!==f||t[11]!==p?(m=(0,Q.jsxs)(`div`,{className:`min-w-0 pr-6`,children:[f,p]}),t[10]=f,t[11]=p,t[12]=m):m=t[12];let h;t[13]===s?h=t[14]:(h=(0,Q.jsx)(ln,{form:s}),t[13]=s,t[14]=h);let g;t[15]!==a||t[16]!==l?(g=(0,Q.jsx)(cn,{projectRef:l,collapsible:a}),t[15]=a,t[16]=l,t[17]=g):g=t[17];let _;return t[18]!==m||t[19]!==h||t[20]!==g?(_=(0,Q.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[m,h,g]}),t[18]=m,t[19]=h,t[20]=g,t[21]=_):_=t[21],_},gn=(e,t)=>t.updatedAtMs-e.updatedAtMs,_n=i((e,t)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!t().isLoading){e({isLoading:!0,error:null});try{let[n,r]=await Promise.all([ke(),X()]),i={};for(let e of r.sort(gn))i[e.id]=e;t().listenerReady||await Ee(t=>{e(e=>({statusesById:{...e.statusesById,[t.id]:t}}))}),e({instances:n.instances,statusesById:i,isLoading:!1,initialized:!0,listenerReady:!0})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:String(t)})}}},loadImports:async()=>{if(!t().isImportsLoading){e({isImportsLoading:!0,error:null});try{e({importCandidates:await De(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await X(),n={};for(let e of t.sort(gn))n[e.id]=e;e({statusesById:n})}catch(t){e({error:t instanceof Error?t.message:String(t)})}},setInstances:async n=>{e({isSaving:!0,error:null});try{await Te({instances:n}),e({instances:n,isSaving:!1}),await t().refreshStatuses()}catch(t){throw e({isSaving:!1,error:t instanceof Error?t.message:String(t)}),t}},upsertInstance:async e=>{let n=t().instances,r=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n];await t().setInstances(r)},createFromCommand:async(e,n,r)=>{let i=we(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await Y(n).catch(()=>void 0);let r=t().instances.filter(e=>e.id!==n);await t().setInstances(r),e(e=>{let t={...e.statusesById};return delete t[n],{statusesById:t}})},connect:async n=>{e({error:null});try{await Oe(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},disconnect:async n=>{e({error:null});try{await Y(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},retry:async e=>{await t().connect(e)},getStatus:e=>t().statusesById[e]||null,clearError:()=>e({error:null})})),vn=e=>{let t=(0,an.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=He(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=Be(c),t[2]=c,t[3]=l);let u=l,d=a==null?null:Math.max(0,Math.min(100,a)),f;t[4]===u?f=t[5]:(f=u===`critical`?{backgroundColor:`var(--status-error)`}:u===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`},t[4]=u,t[5]=f);let p=f,m;t[6]===i?m=t[7]:(m=K(`relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden`,i),t[6]=i,t[7]=m);let h=`${s}%`,g;t[8]!==p||t[9]!==h?(g={...p,width:h},t[8]=p,t[9]=h,t[10]=g):g=t[10];let _;t[11]!==s||t[12]!==g?(_=(0,Q.jsx)(`div`,{className:`h-full transition-all duration-300`,style:g,role:`progressbar`,"aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100}),t[11]=s,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d!=null&&d>0&&d<100&&(0,Q.jsx)(`div`,{className:`absolute top-0 h-full w-0.5 bg-foreground`,style:{left:`${d}%`},title:`Expected usage if spread evenly: ${Math.round(d)}% of quota`,"aria-hidden":`true`}),t[14]=d,t[15]=v);let y;return t[16]!==m||t[17]!==_||t[18]!==v?(y=(0,Q.jsxs)(`div`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},yn=e=>{let t=(0,an.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=le(),s;t[0]===n.status?s=t[1]:(s=ze(n.status),t[0]=n.status,t[1]=s);let c=s,l;bb0:{switch(n.status){case`on-track`:{let e;t[2]===o?e=t[3]:(e=o(`settings.usage.pace.status.onTrack`),t[2]=o,t[3]=e),l=e;break bb0}case`slightly-fast`:{let e;t[4]===o?e=t[5]:(e=o(`settings.usage.pace.status.slightlyFast`),t[4]=o,t[5]=e),l=e;break bb0}case`too-fast`:{let e;t[6]===o?e=t[7]:(e=o(`settings.usage.pace.status.tooFast`),t[6]=o,t[7]=e),l=e;break bb0}case`exhausted`:{let e;t[8]===o?e=t[9]:(e=o(`settings.usage.pace.status.usedUp`),t[8]=o,t[9]=e),l=e;break bb0}}l=void 0}let u=l,d;t[10]!==n.predictText||t[11]!==o?(d=o(`settings.usage.pace.predictionTooltip`,{prediction:n.predictText}),t[10]=n.predictText,t[11]=o,t[12]=d):d=t[12];let f=d;if(a){let e;t[13]===r?e=t[14]:(e=K(`flex items-center gap-1.5`,r),t[13]=r,t[14]=e);let i;t[15]===c?i=t[16]:(i={backgroundColor:c},t[15]=c,t[16]=i);let a;t[17]!==u||t[18]!==i?(a=(0,Q.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:i,title:u}),t[17]=u,t[18]=i,t[19]=a):a=t[19];let s;t[20]===c?s=t[21]:(s={color:c},t[20]=c,t[21]=s);let l=n.isExhausted?void 0:f,d;t[22]!==n.isExhausted||t[23]!==n.predictText||t[24]!==n.remainingSeconds||t[25]!==o?(d=n.isExhausted?(0,Q.jsx)(Q.Fragment,{children:o(`settings.usage.pace.wait`,{duration:Ve(n.remainingSeconds)})}):(0,Q.jsx)(Q.Fragment,{children:o(`settings.usage.pace.prediction`,{prediction:n.predictText})}),t[22]=n.isExhausted,t[23]=n.predictText,t[24]=n.remainingSeconds,t[25]=o,t[26]=d):d=t[26];let p;t[27]!==d||t[28]!==s||t[29]!==l?(p=(0,Q.jsx)(`span`,{className:`typography-micro tabular-nums`,style:s,title:l,children:d}),t[27]=d,t[28]=s,t[29]=l,t[30]=p):p=t[30];let m;return t[31]!==p||t[32]!==e||t[33]!==a?(m=(0,Q.jsxs)(`div`,{className:e,children:[a,p]}),t[31]=p,t[32]=e,t[33]=a,t[34]=m):m=t[34],m}let p;t[35]===r?p=t[36]:(p=K(`flex items-center justify-between gap-2`,r),t[35]=r,t[36]=p);let m;t[37]!==n.isExhausted||t[38]!==n.paceRateText||t[39]!==o?(m=!n.isExhausted&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:o(`settings.usage.pace.rate`,{rate:n.paceRateText})}),t[37]=n.isExhausted,t[38]=n.paceRateText,t[39]=o,t[40]=m):m=t[40];let h;t[41]===m?h=t[42]:(h=(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5`,children:m}),t[41]=m,t[42]=h);let g;t[43]===c?g=t[44]:(g={color:c},t[43]=c,t[44]=g);let _;t[45]!==n.isExhausted||t[46]!==n.predictText||t[47]!==n.remainingSeconds||t[48]!==f||t[49]!==u||t[50]!==o?(_=n.isExhausted?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:u}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.waitSeparator`)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:Ve(n.remainingSeconds)})]}):(0,Q.jsxs)(`span`,{title:f,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.predictionLabel`)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:n.predictText})]}),t[45]=n.isExhausted,t[46]=n.predictText,t[47]=n.remainingSeconds,t[48]=f,t[49]=u,t[50]=o,t[51]=_):_=t[51];let v;t[52]!==g||t[53]!==_?(v=(0,Q.jsx)(`span`,{className:`typography-micro tabular-nums`,style:g,children:_}),t[52]=g,t[53]=_,t[54]=v):v=t[54];let y;t[55]===c?y=t[56]:(y={backgroundColor:c},t[55]=c,t[56]=y);let b;t[57]!==u||t[58]!==y?(b=(0,Q.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:y,title:u}),t[57]=u,t[58]=y,t[59]=b):b=t[59];let x;t[60]!==v||t[61]!==b?(x=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[v,b]}),t[60]=v,t[61]=b,t[62]=x):x=t[62];let S;return t[63]!==x||t[64]!==p||t[65]!==h?(S=(0,Q.jsxs)(`div`,{className:p,children:[h,x]}),t[63]=x,t[64]=p,t[65]=h,t[66]=S):S=t[66],S},bn={displayMode:`browser`,installed:!1,browserTab:!0},xn=new Set,Sn=bn,Cn=!1,wn,Tn=()=>{let e=je();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},En=()=>(!Cn&&typeof window<`u`&&(Sn=Tn(),Cn=!0),Sn),$=()=>{let e=Tn();Cn=!0,e.displayMode!==Sn.displayMode&&(Sn=e,xn.forEach(e=>e()))},Dn=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=[window.matchMedia(`(display-mode: standalone)`),window.matchMedia(`(display-mode: minimal-ui)`),window.matchMedia(`(display-mode: fullscreen)`),window.matchMedia(`(display-mode: window-controls-overlay)`)];for(let t of e)typeof t.addEventListener==`function`?t.addEventListener(`change`,$):typeof t.addListener==`function`&&t.addListener($);return window.addEventListener(`appinstalled`,$),window.addEventListener(`focus`,$),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,$):typeof t.removeListener==`function`&&t.removeListener($);window.removeEventListener(`appinstalled`,$),window.removeEventListener(`focus`,$)}},On=e=>(xn.add(e),wn??=Dn(),$(),()=>{xn.delete(e),xn.size===0&&(wn?.(),wn=void 0)}),kn=()=>Z.useSyncExternalStore(On,En,An);function An(){return bn}var jn=`Yuri`,Mn=i()(a(e=>({sidebarBrandName:jn,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:u(),version:3,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n={...e};return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=jn),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=jn),t<3&&(n.sidebarBrandName===`OPEN CHAMBER`||n.sidebarBrandName===`Open Chamber`)&&(n.sidebarBrandName=jn),n}}));typeof window<`u`&&t(e=>{n(e)&&Mn.persist.rehydrate()});var Nn=`__other__`;function Pn(e){return e.time?.updated??e.time?.archived??e.time?.created??0}function Fn({mode:e=`dialog`}){let{t}=le(),{isMobile:n,isTablet:i,hasTouchInput:a}=ve(),o=n||i||a,s=e===`page`,c=f(e=>e.isArchivedSessionsDialogOpen),l=f(e=>e.setArchivedSessionsDialogOpen),u=s||c,d=V(e=>e.projects),p=H(e=>e.archivedSessions),m=se(e=>e.setCurrentSession),h=f(e=>e.setSettingsDialogOpen),[g,_]=Z.useState(!1),[v,y]=Z.useState(null),[b,x]=Z.useState(null);Z.useEffect(()=>{if(!u){y(null),x(null);return}let e=!1;return _(!0),ie().catch(()=>{e||q.error(t(`settings.yuri.archivedSessions.toast.loadFailed`))}).finally(()=>{e||_(!1)}),()=>{e=!0}},[u,t]);let S=Z.useMemo(()=>{let e=d.map(e=>({id:e.id,normalizedPath:e.path})),n=Ue([],e,new Map,r(),p),i=new Map;for(let[e,t]of n.archivedSessionsByProject)i.set(e,[...t].sort((e,t)=>Pn(t)-Pn(e)));let a=new Set;for(let e of i.values())for(let t of e)a.add(t.id);let o=p.filter(e=>!a.has(e.id)).sort((e,t)=>Pn(t)-Pn(e));o.length>0&&i.set(Nn,o);let s=[];for(let e of d){let t=i.get(e.id)??[];t.length!==0&&s.push({projectId:e.id,label:e.label||e.path,path:e.path,sessions:t})}let c=i.get(Nn);return c&&c.length>0&&s.push({projectId:Nn,label:t(`settings.yuri.archivedSessions.otherProjects`),path:null,sessions:c}),s.sort((e,t)=>t.sessions.length-e.sessions.length||e.label.localeCompare(t.label)),s},[p,d,t]),C=p.length,w=v?S.find(e=>e.projectId===v)??null:null,T=Z.useCallback(async e=>{x(e.id);try{await ce(e.id)?q.success(t(`settings.yuri.archivedSessions.toast.restored`)):q.error(t(`settings.yuri.archivedSessions.toast.restoreFailed`))}finally{x(null)}},[t]),E=Z.useCallback(e=>{let t=U(e);m(e.id,t),l(!1),h(!1)},[m,l,h]),D=w?w.label:t(`settings.yuri.archivedSessions.dialog.title`),O=w?w.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:w.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:w.sessions.length}):t(`settings.yuri.archivedSessions.dialog.description`),k=(0,Q.jsxs)(`div`,{className:`yuri-picker-list space-y-3`,children:[w?(0,Q.jsxs)(W,{type:`button`,variant:`ghost`,size:`sm`,className:`!h-7 !px-2 !font-normal text-muted-foreground`,onClick:()=>y(null),children:[(0,Q.jsx)(J,{name:`arrow-left-s`,className:`mr-1 h-4 w-4`}),t(`settings.yuri.archivedSessions.dialog.backToProjects`)]}):null,g?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground py-6`,children:[(0,Q.jsx)(J,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),t(`settings.yuri.archivedSessions.dialog.loading`)]}):w?w.sessions.length===0?(0,Q.jsx)(`div`,{className:`yuri-picker-empty rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.emptyProject`)}):(0,Q.jsx)(`div`,{className:`yuri-picker-rows space-y-1.5`,children:w.sessions.map(e=>{let n=U(e),r=Pn(e),i=b===e.id;return(0,Q.jsxs)(`div`,{className:`yuri-picker-row flex flex-col gap-2 rounded-lg border border-border/60 px-3 py-2.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`yuri-picker-label typography-ui-label font-medium text-foreground truncate`,children:e.title||t(`sessions.sidebar.session.untitled`)}),(0,Q.jsxs)(`div`,{className:`yuri-picker-meta typography-meta text-muted-foreground truncate`,children:[r>0?Ae(r):null,r>0&&n?` · `:null,n?G(n):null]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,Q.jsx)(W,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>E(e),children:t(`settings.yuri.archivedSessions.actions.preview`)}),(0,Q.jsxs)(W,{type:`button`,variant:`default`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>void T(e),children:[i?(0,Q.jsx)(J,{name:`loader-4`,className:`mr-1 h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(J,{name:`inbox-unarchive`,className:`mr-1 h-3.5 w-3.5`}),t(`settings.yuri.archivedSessions.actions.restore`)]})]})]},e.id)})}):S.length===0?(0,Q.jsx)(`div`,{className:`yuri-picker-empty rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.empty`)}):(0,Q.jsx)(`div`,{className:`yuri-picker-rows space-y-1.5`,children:S.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>y(e.projectId),className:K(`yuri-picker-row flex w-full items-center gap-3 rounded-lg border border-border/60 px-3 py-2.5 text-left`,`hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),children:[(0,Q.jsx)(J,{name:`folder`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`yuri-picker-label typography-ui-label font-medium text-foreground truncate`,children:e.label}),e.path?(0,Q.jsx)(`div`,{className:`yuri-picker-meta typography-meta text-muted-foreground truncate`,children:G(e.path)}):null]}),(0,Q.jsx)(`span`,{className:`typography-meta tabular-nums text-muted-foreground shrink-0`,children:e.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:e.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:e.sessions.length})}),(0,Q.jsx)(J,{name:`arrow-right-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]},e.projectId))}),!w&&!g&&C>0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(C===1?`settings.yuri.archivedSessions.summarySingle`:`settings.yuri.archivedSessions.summaryPlural`,{count:C})}):null]});return s?(0,Q.jsxs)(`div`,{"data-settings-item":`archived-sessions.manage`,className:`yuri-settings-section-stack`,children:[(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.description`)}),k]}):o?(0,Q.jsx)(Me,{open:c,title:D,onClose:()=>l(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:D}),e]}),(0,Q.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:O})]}),children:k}):(0,Q.jsx)(pe,{open:c,onOpenChange:l,children:(0,Q.jsxs)(de,{presentation:`picker`,children:[(0,Q.jsx)(ue,{className:`yuri-picker-header`,children:(0,Q.jsx)(fe,{className:`yuri-picker-title truncate`,children:D})}),k]})})}function In(){let e=(0,an.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(Fn,{mode:`dialog`}),e[0]=t):t=e[0],t}export{ut as _,yn as a,hn as c,Kt as d,Wt as f,lt as g,st as h,kn as i,on as l,Lt as m,Fn as n,vn as o,Gt as p,Mn as r,_n as s,In as t,rn as u};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-input-store-CiwwBt7K.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-switch-DEPKHgdL.js","assets/runtime-auth-DA-qfGHk.js","assets/platform-z1TeG-ky.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-zustand-CTekDqaS.js","assets/vendor-base-ui-wXsskyKm.js","assets/prompt-attachment-upload-BG4nBKxi.js","assets/runtime-fetch-V-iMWR8t.js","assets/reasoning-projection-client-BEhVknv9.js","assets/runtime-file-resource-COtIWnSi.js","assets/vendor-react-BkccXcWz.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/vendor-tanstack-react-query-DIb_ItL-.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-DjKFMfz7.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/summaries-BQMyJaaw.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/input-store-C4dE7Hgl.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/uuid-D-SDZijH.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEPKHgdL.js";import{a as r}from"./vendor-zustand-CTekDqaS.js";import{ot as i,st as a}from"./vendor-base-ui-wXsskyKm.js";import{St as o}from"./gitApiHttp-Be5VpQHC.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{Jt as s,R as c,Wt as l,Xt as u,at as d,dr as f,en as p,it as m,n as h,nr as g,on as _,rt as v,tn as y,tr as b}from"./client-i5Q82JUc.js";import{t as x}from"./pathNormalization-ewtPqJWn.js";import{n as S}from"./vendor-react-BkccXcWz.js";import{o as C,s as w}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{A as T,E as ee,I as E,R as D,W as O,k}from"./runtime-file-resource-COtIWnSi.js";import{r as te}from"./vendor-reactuses-core-DjKFMfz7.js";import{o as A}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as j}from"./useUIStore-Dz0bOfkB.js";import{s as M}from"./spacedFileMention-Ds4GtgiF.js";import{An as N,Ba as P,Bn as F,Fa as ne,Gi as I,Ir as L,Ji as R,Ki as re,Lr as ie,Pr as ae,Rn as oe,Rr as z,Tt as se,U as B,Ua as V,V as ce,Vn as le,W as ue,Yi as de,Yn as H,Yt as fe,_i as pe,_t as me,dn as he,f as U,ft as ge,gi as _e,gt as ve,hi as ye,ht as be,ir as xe,j as Se,kn as Ce,mi as we,mn as W,mt as Te,ni as Ee,no as G,oi as De,pt as Oe,ri as ke,t as K,ta as Ae,ti as je,ur as Me,ut as Ne,vi as q,vr as J,xt as Pe,zn as Fe}from"./ui-DeV7Us1B.js";import{n as Y}from"./Icon-C1m8PihJ.js";import{i as Ie,m as Le,n as Re}from"./remoteProjectQueries-CuuZggLJ.js";import{t as ze}from"./i18n-CBCskgqa.js";import{t as Be}from"./toolHelpers-iEHVHQ9p.js";import{t as Ve}from"./ScrollableOverlay-DIkp2MKc.js";import{t as He}from"./MobileResizableSheet-CcOOlg4R.js";import{a as Ue,i as We,n as Ge,o as Ke,t as qe}from"./dialog-Cv20xnEj.js";import{i as Je,n as Ye,t as Xe}from"./tooltip-Cdy71vjH.js";import{c as Ze,n as Qe,t as $e}from"./dropdown-menu-B_P1dDl7.js";import{n as et}from"./useProjectRuntimeAPIs-Fi6XrG43.js";import{b as tt,p as nt,t as rt,v as it}from"./gitApi-BH7j-M9u.js";import{o as at,t as ot}from"./useProjectGitStore-C6ZCDvmO.js";import{t as st}from"./input-CY-NU-bG.js";import{t as ct}from"./useDebouncedValue-BHlMPqY8.js";import{t as lt}from"./checkbox-LzFeQCyX.js";import{t as ut}from"./MobileOverlayPanel-XkMrn5-W.js";import{t as dt}from"./githubAuthQueries-Dli4cDU7.js";import{a as ft,i as pt,s as mt,t as ht}from"./worktreeManager-XchvRN9O.js";import{a as gt,i as _t,n as vt,o as yt,r as bt,t as xt}from"./worktreeSourceBranchPreference-BJrbhZ4m.js";import{s as St}from"./remote-input-store-CiwwBt7K.js";import{t as Ct}from"./vendor-cmdk-BDWoZLve.js";import{t as wt}from"./sortable-tabs-strip-Bq5JCAvR.js";import{f as Tt,m as Et}from"./auto-read-context-C8RimaOE.js";var Dt=2e3,Ot=r((e,t)=>({pending:!1,expiresAt:null,arm:(t=Dt)=>{let n=Date.now()+t;return e({pending:!0,expiresAt:n}),n},clear:()=>{!t().pending&&t().expiresAt===null||e({pending:!1,expiresAt:null})}})),X=e(a(),1),kt=new class{inFlightByScope=new WeakMap;generationByScope=new WeakMap;run(e){let t=this.inFlightByScope.get(e.scope);t||(t=new Map,this.inFlightByScope.set(e.scope,t));let n=t.get(e.key);if(n)return n;let r=this.generationByScope.get(e.scope);r||(r=new Map,this.generationByScope.set(e.scope,r));let i=(r.get(e.key)??0)+1;r.set(e.key,i);let a=e.request(()=>r?.get(e.key)!==i);return t.set(e.key,a),a.finally(()=>{t?.get(e.key)===a&&t.delete(e.key)}).catch(()=>{}),a}},At=e=>C({queryKey:[e.transport,`sessionChildren`,e.generation,x(e.directory),e.sessionID],queryFn:({signal:t})=>e.request(t),staleTime:0,gcTime:6e4,retry:!1}),jt=e=>O.fetchQuery(At(e)),Mt=(e,t)=>e.id<t.id?-1:+(e.id>t.id),Nt=(e,t,n)=>{let r=new Set(e.map(e=>e.id)),i=t.filter(e=>!e?.id||r.has(e.id)||e.parentID!==n?!1:(r.add(e.id),!0));return i.length===0?e:[...e,...i].sort(Mt)},Pt=30,Ft=new Map;function It(e,t=!1){return{limit:e.loadedTurns,cursor:e.kind===`has-more`?e.cursor:void 0,complete:e.kind===`exhausted`,loading:t}}function Lt(e,t){let n=u();if(!n)return!1;let r=n.getTranscript(_(e,t));return r.messageOrder.length!==0&&r.messageOrder.length>z()}function Rt(e){return!!e.force||!e.hasSession||e.shouldLoadMessages}function zt(e,t,n){let r=[...e.getState().session],i=le.search(r,t,e=>e.id);i.found?r[i.index]=n:r.splice(i.index,0,n),e.setState({session:r})}function Bt(){let e=Pe(),r=B(),i=ce(),a=(0,X.useCallback)((t,n=e)=>`${n}\n${t}`,[e]),o=(0,X.useCallback)((t,n=e)=>{let r=u();if(!r||!t)return It({kind:`unknown`,loadedTurns:0},!1);let i=_(n,t),a=r.getPagination(i),o=r.getRequestState?.(i);return It(a.boundary,o?.status===`loading`)},[e]),c=(0,X.useCallback)((e,t)=>{if(t.length===0)return;let n=i.getChild(e);if(!n)return;let r=n.getState(),a={session_status:{...r.session_status},session_status_observed_at:{...r.session_status_observed_at},session_error_at:{...r.session_error_at},session_diff:{...r.session_diff},todo:{...r.todo},permission:{...r.permission},question:{...r.question}};oe(a,t),Se(n,t),n.setState(a);for(let n of t)p(e,n)},[i]),d=(0,X.useCallback)((t=e)=>{let n=Ft.get(t);if(n)return Ft.delete(t),Ft.set(t,n),n;let r=new Set;for(Ft.set(t,r);Ft.size>Pt;){let e=Ft.keys().next().value;if(!e)break;let t=[...Ft.get(e)??[]];Ft.delete(e),c(e,t)}return r},[e,c]),m=(0,X.useCallback)((t,n=e)=>{let a=n===e?r:i.ensureChild(n,{bootstrap:!1}),o=d(n),s=Fe(a.getState()),l=L(),f=F({seen:o,keep:t,limit:l,preserve:s});if(c(n,f),ie()){let e=new Set([t,...o,...s]),r=(u()?.getCacheBudget?.().listCanonical({directory:n})??[]).map(e=>e.scope.sessionID),i=(r.length>0?r:Array.from(o)).filter(r=>r===t||e.has(r)?!1:Lt(n,r));if(i.length>0){for(let e of i)o.delete(e);c(n,i)}}},[i,e,d,c,r]),g=(0,X.useCallback)(async(t,n)=>{let a=n?.directory??e;if(!t||!a||a===`global`)return;let o=a===e?r:i.ensureChild(a,{bootstrap:!1}),c=o.getState(),l=c.session_status?.[t],d=c.session_status_observed_at?.[t];try{n?.purpose===`prepend`||n?.before?await s(a,t):await y(a,t,{background:!0})}catch{return}if(n?.isStale?.())return;let f=u()?.getTranscript(_(a,t));W({directory:a,sessionID:t,store:o,transcript:f,isStale:n?.isStale}),await J({directory:a,sessionID:t,store:o,statusBeforePull:l,statusObservedAtBeforePull:d,hasMessages:(f?.messageOrder.length??0)>0,isTailPage:!n?.before,isStale:n?.isStale})},[i,r,e]),v=(0,X.useCallback)(async(t,n)=>{await se();let r=typeof n==`boolean`?n:n?.force,o=typeof n==`object`?n.directory??e:e,s=i.ensureChild(o,{bootstrap:!1}),c=h.getScopedSdkClient(o);m(t,o);let l=a(t,o);return kt.run({scope:s,key:l,request:async e=>{let n=s.getState(),i=u(),a=_(o,t),l=i?.hasSession?.(a)??(i?.getTranscript(a).messageOrder.length??0)>0,d=i?.getPagination(a)?.boundary??{kind:`unknown`,loadedTurns:0},p=le.search(n.session,t,e=>e.id).found,m=i?.getRequestState?.(a);if(!r&&l&&d.kind!==`unknown`&&m?.status!==`error`&&p&&ae(o,t)){W({directory:o,sessionID:t,store:s,isStale:e});return}let h=!!(r||!l||p),v=Rt({hasSession:p,shouldLoadMessages:h,force:!!r});await Promise.all([v?(async()=>{try{let n=await re(async()=>c.session.get({sessionID:t}));if(n&&!e()){let r=I(f(n));e()||zt(s,t,r)}}catch(e){console.error(`[sync] failed to fetch session`,t,e)}})():Promise.resolve(),h?g(t,{isStale:e,directory:o}):Promise.resolve()])}})},[i,a,m,g,e]),b=te(async(r,a)=>{let o=a||e;if(!r||!o)return;let s=i.ensureChild(o,{bootstrap:!1}),c=h.getScopedSdkClient(o),l=n(),u=t(),d=()=>l!==n()||u!==t()||i.getChild(o)!==s,p=await jt({transport:u,generation:l,directory:o,sessionID:r,request:async e=>{let i=[],a=new Set,s;do{if(e.throwIfAborted(),l!==n()||u!==t())throw new DOMException(`Session children runtime changed`,`AbortError`);let d=await c.session.list(s?{cursor:s,limit:50}:{directory:o,parentID:r,limit:50},{signal:e});if(!Array.isArray(d?.data))throw Error(`session.list children returned no data`);if(i.push(...d.data.map(f)),d.data.length<50)break;if(s=d.cursor?.next??void 0,!s||a.has(s))throw Error(`session.list children pagination did not advance`);a.add(s)}while(s);return i}}).catch(e=>{if(d())return null;throw e});!p||d()||s.setState(e=>{let t=Nt(e.session,p,r);return t===e.session?e:{session:t,limit:Math.max(e.limit,t.length)}})}),x=(0,X.useCallback)((t,n)=>{let r=o(t,n?.directory??e);return!r.complete&&!!r.cursor},[e,o]),S=(0,X.useCallback)((t,n)=>o(t,n?.directory??e).loading,[e,o]),C=(0,X.useCallback)((t,n)=>o(t,n?.directory??e).complete,[e,o]),w=(0,X.useCallback)(t=>{let n=t.directory||e;l(_(n,t.sessionID),{type:`optimistic-add`,message:t.message,parts:t.parts})},[e]),T=(0,X.useCallback)(t=>{let n=t.directory||e;l(_(n,t.sessionID),{type:`optimistic-remove`,messageID:t.messageID})},[e]),ee=(0,X.useCallback)(t=>{let n=t.directory||e;l(_(n,t.sessionID),{type:`optimistic-confirm`,messageID:t.messageID})},[e]),E=te(async(r,a)=>{if(!r)return;await se();let o=a?.directory??e;if(!o||o===`global`)return;let s=i.ensureChild(o,{bootstrap:!1}),c=n(),l=t(),d=()=>c!==n()||l!==t()||i.ensureChild(o,{bootstrap:!1})!==s,f=s.getState();try{if(await y(o,r),d())return;W({directory:o,sessionID:r,store:s}),await J({directory:o,sessionID:r,store:s,statusBeforePull:f.session_status?.[r],statusObservedAtBeforePull:f.session_status_observed_at?.[r],hasMessages:(u()?.getTranscript(_(o,r)).messageOrder.length??0)>0,isStale:d})}catch{throw Error(`refresh transcript failed`)}});return(0,X.useMemo)(()=>({ensureSessionRenderable:v,syncSession:v,loadChildren:b,hasMore:x,isLoading:S,isComplete:C,refreshSessionTranscript:E,optimistic:{add:w,remove:T,confirm:ee}}),[v,b,x,S,C,E,w,T,ee])}var Z=S(),Q=i(),Vt=(e,t)=>{if(!e)return t;let n=e.ready&&!e.loading;return{modelsReady:!e.error&&(e.modelsReady??n),agentsReady:!e.error&&(e.agentsReady??n)}},Ht=e=>{let t=e?.variants;if(!t)return[];if(Array.isArray(t)){let e=[],n=new Set;for(let r of t){let t=typeof r==`string`?r:r&&typeof r==`object`&&!Array.isArray(r)&&typeof r.id==`string`?r.id:``;!t||n.has(t)||(n.add(t),e.push(t))}return e}return typeof t==`object`?Object.keys(t):[]},Ut=(e,t,n,r)=>{if(e.providerID!==n||e.modelID!==r||t?.variantsReady===!1)return[];if(t?.variants)return[...t.variants];let i=(t?.providers?.find(e=>e.id===n))?.models?.find(e=>e.id===r);return Ht(i)},Wt=()=>!0,Gt=(e,t)=>(e.commandPolicy??Wt)(t),Kt=X.createContext(null),qt=()=>X.useContext(Kt),Jt=e=>e,Yt=(e,t)=>t??e,Xt=e=>{if(e.kind!==`primary`&&(!e.sessionID||!e.directory||!e.draftKey||!e.transportIdentity||!Number.isSafeInteger(e.runtimeGeneration)||!e.resources||typeof e.resources.busy!=`boolean`||!e.activity||!e.commands||!e.shortcuts))throw Error(`chat-input-secondary-surface-incomplete`)},Zt=(e,t)=>e.kind===`secondary`?e.resources?.busy??!1:t,Qt=e=>!e.sessionID||!e.directory?null:{deliveryTarget:e.deliveryTarget,sessionID:e.queueSessionID??e.sessionID,directory:e.directory,transportIdentity:e.transportIdentity,runtimeGeneration:e.runtimeGeneration},$t=(e,t,n)=>{if(e.kind===`secondary`){if(!e.commands)throw Error(`chat-input-secondary-commands-incomplete`);return e.commands}return e.commands?e.commands:{sessionID:e.sessionID,hasMessages:t,hasNewDraft:n}},en={phase:`idle`,isWorking:!1,isBusy:!1,isCooldown:!1},tn=e=>e.hasPendingAssistant?e.messages.some(e=>e.role===`assistant`&&typeof e.time?.completed==`number`):!1;function nn(e,t){let n=(0,Z.c)(6),r=be(e??``,t),i=ve(e??``,t),a=Ne(e??``,t),o=Oe(e??``,t),s=Te(e??``,t),c=me(t),l;bb0:{if(!e){l=en;break bb0}if(o.length>0||s.length>0){l=en;break bb0}let t=r?.type??`idle`,u=a[a.length-1],d=!!(u&&u.role===`assistant`&&typeof u.time?.completed!=`number`),f=a,p;n[0]!==d||n[1]!==f?(p=tn({messages:f,hasPendingAssistant:d}),n[0]=d,n[1]=f,n[2]=p):p=n[2];let m=p,h=u?.time?.created,g=!!(m&&typeof c==`number`&&typeof h==`number`&&h<=c),_=r!==void 0,v=_&&t!==`idle`,y=v||m&&!g;if(_&&!v&&(!m||_&&!v&&typeof i==`number`&&typeof h==`number`&&h<=i)){l=en;break bb0}if(!y){l=en;break bb0}let b=v?t:`busy`,x=t===`busy`||!v&&m,S;n[3]!==b||n[4]!==x?(S={phase:b,isWorking:!0,isBusy:x,isCooldown:!1},n[3]=b,n[4]=x,n[5]=S):S=n[5],l=S}return l}var rn=`data-mobile-overlay-active`,an=e=>Array.from(e).some(e=>e.getAttribute(rn)!==`false`),on=`artful.bionic.cosmic.disco.focal.groovy.jammy.kinetic.lunar.noble.bold.brave.calm.eager.gentle.happy.keen.lively.merry.swift.warm.wise.bright.clever.daring.agile.crisp.fresh.lucid.quick.sharp.vivid.zealous`.split(`.`),sn=`aardvark.beaver.chipmunk.dolphin.falcon.gopher.hedgehog.jackal.koala.lemur.mongoose.narwhal.otter.pangolin.quokka.raccoon.salamander.toucan.walrus.yak.zebra.badger.condor.dingo.egret.ferret.gecko.heron.iguana`.split(`.`);function cn(){return`${on[Math.floor(Math.random()*on.length)]}-${sn[Math.floor(Math.random()*sn.length)]}`}function ln(e){let t=cn();return e&&e.trim()?`${e.trim().replace(/\/+$/,``)}/${t}`:t}async function un(e,t,n){if(!e.hostId||!e.hubId)throw Error(`Remote Project Host scope is unavailable`);let r=V.getState().remoteSession,i=E(),a=await Re();if(i.assertCurrent(),!a.supported||a.hubId!==e.hubId||!a.projects.some(t=>t.id===e.id&&t.hostId===e.hostId&&t.path===e.path))throw Error(`Remote Project is not referenced by the current Hub`);let o=Ie(a);await o.connectHost(e.hostId);let s=o.resolve({hubId:e.hubId,hostId:e.hostId,directory:e.path}),c=E(s),l=xe(s);if(!await l.checkIsGitRepository(e.path))throw Error(`Worktrees can only be created in Git repositories`);let u=await Ee(e,s),f=u.commands,p=Array.isArray(f)?f.filter(e=>typeof e==`string`&&!!e.trim()).map(t=>De(t.trim(),{rootWorktreePath:e.path})).join(` && `):void 0,h=await l.getGitStatus(e.path),g=await l.getGitBranches(e.path),_=await l.listGitWorktrees(e.path),y=x(e.path),b=_.map(e=>x(e.path)).filter(e=>y===e||y.startsWith(`${e}/`)).sort((e,t)=>t.length-e.length)[0],S=b?y.slice(b.length):``,C=(g.branches?.[h.current]?.tracking||h.tracking)?.replace(/^remotes\//,``).split(`/`)[0],w=t.branchName||t.existingBranch?.replace(/^remotes\//,``),T={...t,...p?{startCommand:p}:{},...C&&w?{setUpstream:t.setUpstream??!0,upstreamRemote:t.upstreamRemote||C,upstreamBranch:t.upstreamBranch||w}:{},returnAfterDirectoryCreated:!1},ee=await l.previewGitWorktree(e.path,T);if(!ee.path)throw Error(`Remote worktree preview missing path`);let D=ye();q(D).catch(()=>void 0);let O=S?`${ee.path.replace(/[\\/]+$/,``)}${S}`:ee.path,k={...s.location,directory:O},te={title:n.title,initialPrompt:n.initialPrompt,bootstrapWaitEnabled:u.wait,defaultModel:e.defaultModel??void 0,pendingWorktreeRequestId:D,bootstrapPendingDirectory:O,preserveDirectoryOverride:!0,bootstrapStatus:{status:`pending`,error:null,updatedAt:Date.now()}};try{n.initialPrompt&&await St(k,n.initialPrompt),c.assertCurrent()}catch(e){throw _e(D,e instanceof Error?e:Error(String(e))),e}n.isSelected()&&V.getState().remoteSession===r&&V.getState().openRemoteSession(e,k,null,te);let j=V.getState().remoteSession,M=j?.draft?.pendingWorktreeRequestId===D,N=()=>{if(!n.isSelected()||!M)return!1;let t=V.getState().remoteSession;return t?.sessionId===null&&t.projectId===e.id&&t.location.hubId===e.hubId&&t.location.hostId===e.hostId&&t.draft?.pendingWorktreeRequestId===D?(j=t,!0):t===j};try{let r=await l.createGitWorktree(e.path,T);if(!r.path||!r.name)throw Error(`Remote worktree create missing name/path`);let i=r.bootstrapStatus,a=Date.now()+12e4;for(;i?.status===`pending`&&u.wait;){if(Date.now()>=a)throw Error(`Remote worktree setup timed out; the existing draft was retained`);await new Promise(e=>setTimeout(e,500)),c.assertCurrent(),i=await l.getGitWorktreeBootstrapStatus(r.path)}if(i?.status===`failed`)throw Error(i.error||`Remote worktree setup failed`);c.assertCurrent();let f=S?`${r.path.replace(/[\\/]+$/,``)}${S}`:r.path,p={...s.location,directory:f},g={pendingWorktreeRequestId:null,bootstrapPendingDirectory:null,worktreeMetadata:{name:r.name,path:f,worktreeRoot:r.path,projectDirectory:e.path,relativePath:S.replace(/^\//,``)||void 0,branch:r.branch,label:r.branch||r.name,source:`sdk`,worktreeSource:`created-for-session`,headState:r.branch?`branch`:`unborn`,worktreeStatus:i?.status===`pending`?`pending`:`ready`,createdFromBranch:n.createdFromBranch||h.current||t.startRef,kind:n.kind??`standard`},bootstrapStatus:u.wait?i??{status:`ready`,error:null,updatedAt:Date.now()}:void 0};if(f!==O){let{getRemoteInputStore:e,remoteSessionDraftKey:t}=await A(async()=>{let{getRemoteInputStore:e,remoteSessionDraftKey:t}=await import(`./remote-input-store-CiwwBt7K.js`).then(e=>e.a);return{getRemoteInputStore:e,remoteSessionDraftKey:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27])),n=e(p),r=t(k,null),i=n.getState().getDraft(r),a=await n.getState().moveDraftWithAttachments(r,t(p,null),i?.revision);if(i&&!a)throw Error(`Remote draft changed while the worktree target was being finalized; the original draft was retained`);c.assertCurrent()}!n.createSession&&N()&&j&&(V.getState().updateRemoteDraft(j,g,p),j=V.getState().remoteSession),n.createSession||pe(D,f);let _;if(n.createSession)try{let t=o.resolve(p).service(),r=N()?j?.draft?.title??n.title:n.title,i=await t.createSession({title:r},f);_=i.id,c.assertCurrent();let a=await t.getConfig(f).catch(()=>void 0);c.assertCurrent();let s=e.defaultModel||a?.model,l=typeof s==`string`?s:void 0,u=l?.indexOf(`/`)??-1,h=u>0?l.slice(0,u):m(i),g=u>0?l.slice(u+1):v(i),y=a?.default_agent||i.agent,b=typeof y==`string`?y:void 0,x=Ae.getState();h&&g&&x.saveSessionModelSelection(i.id,h,g,p),b&&x.saveSessionAgentSelection(i.id,b,p),b&&h&&g&&(x.saveAgentModelForSession(i.id,b,h,g,p),x.saveAgentModelVariantForSession(i.id,b,h,g,d(i),p))}catch(t){throw await l.deleteGitWorktree(e.path,{directory:r.path,deleteLocalBranch:!0}).catch(()=>void 0),t}return c.assertCurrent(),n.createSession&&N()&&V.getState().openRemoteSession(e,p,_??null,{...j?.draft,...g}),n.createSession&&pe(D,f),{path:f,branch:r.branch,..._?{id:_}:{}}}catch(e){let t=e instanceof Error?e:Error(String(e));throw N()&&j&&V.getState().updateRemoteDraft(j,{pendingWorktreeRequestId:null,bootstrapPendingDirectory:null,bootstrapStatus:{status:`failed`,error:t.message,updatedAt:Date.now()}}),_e(D,t),e}}var dn=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``)||e,fn=e=>()=>{let t=P.getState().getActiveProject();return t?.id===e.id&&t?.hostId===e.hostId&&t?.hubId===e.hubId&&t?.path===e.path},pn=e=>({agentName:e.currentAgentName,providerId:e.currentProviderId,modelId:e.currentModelId,variant:e.currentVariant}),mn=(e,t,n)=>{let r=t.agentName?.trim()||void 0,i=t.providerId?.trim()||void 0,a=t.modelId?.trim()||void 0;!r||!i||!a||(n.saveSessionAgentSelection(e,r),n.saveSessionModelSelection(e,i,a),n.saveAgentModelForSession(e,r,i,a),n.saveAgentModelVariantForSession(e,r,i,a,t.variant))},hn=async(e,t)=>{await ke(e)&&await we(t)},gn=e=>{let t=dn(e),n=P.getState().projects;if(n.length===0)return null;let r=n.filter(e=>{if(e.hostId)return!1;let n=dn(e.path);return t===n||t.startsWith(`${n}/`)}).sort((e,t)=>dn(t.path).length-dn(e.path).length)[0];return r?{id:r.id,path:r.path}:null},_n=!1,vn=async(e,t)=>{try{let n=P.getState().projects.find(e=>e.id===t.id)??P.getState().projects.find(e=>dn(e.path)===dn(t.path)),r=R(t.path);await de.getState().activateDirectory(t.path,{source:`worktreeSessionCreator`});let i=de.getState();if(i.activeDirectoryKey!==r||i.providers.length===0||i.agents.length===0)return;i.applyDefaultModelAgentSelection({projectDefaultModel:n?.defaultModel??void 0}),mn(e,pn(de.getState()),Ae.getState())}catch{}},yn=async(e,t,n)=>{let r=U.getState(),i=de.getState();r.initializeNewYuriSession(e,i.agents),r.setSessionDirectory(e,t.path),r.setWorktreeMetadata(e,t),await vn(e,n),o.getState().setDirectory(t.path,{showOverlay:!1})},bn=e=>e.trim().replace(/^remotes\//,``).replace(/[^A-Za-z0-9._/-]+/g,`-`).replace(/\/+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``)||`worktree`,xn=async e=>{if(_n)return null;let t=P.getState().getActiveProject();if(t?.hostId){_n=!0;let n=fn(t);try{let r=e?.existingBranch?.trim().replace(/^remotes\//,``),i=r?bn(r):ln();return(await un(t,{mode:r?`existing`:`new`,worktreeName:i,...r?{existingBranch:r}:{branchName:i}},{...e,isSelected:n})).path}catch(e){return K.error(`Failed to create worktree`,{description:e instanceof Error?e.message:String(e)}),null}finally{_n=!1}}let n=e?.projectDirectory?.trim()||t?.path;if(!n)return K.error(`No active project`,{description:`Please select a project first.`}),null;let r=gn(n)??(t?.path?{id:t.id,path:t.path}:null);if(!r)return K.error(`No active project`,{description:`Please select a project first.`}),null;let i=!1;try{i=await rt(r.path)}catch{}if(!i)return K.error(`Not a Git repository`,{description:`Worktrees can only be created in Git repositories.`}),null;_n=!0;try{let t=ye(),n=e?.existingBranch?.trim().replace(/^remotes\//,``)||``,i=n?bn(n):ln(),a=n?`existing`:`new`,s=U.getState();s.newSessionDraft?.open?s.overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:s.newSessionDraft.directoryOverride??r.path,pendingWorktreeRequestId:t,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}):s.openNewSessionDraft({selectedProjectId:r.id,directoryOverride:r.path,pendingWorktreeRequestId:t,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt});let c=await nt(r.path,{mode:a,...a===`new`?{branchName:i,worktreeName:i}:{existingBranch:n,worktreeName:i}}).catch(()=>null);c?.path&&(U.getState().overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:c.path,pendingWorktreeRequestId:t,bootstrapPendingDirectory:c.path,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}),o.getState().setDirectory(c.path,{showOverlay:!1}));let l=await je(r),u=await _t(r,{preferredName:i,mode:a,worktreeName:i,setupCommands:l,returnAfterDirectoryCreated:!0,...a===`new`?{branchName:i}:{existingBranch:n}});return pe(t,u.path),U.getState().overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:u.path,pendingWorktreeRequestId:null,bootstrapPendingDirectory:u.path,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}),o.getState().setDirectory(u.path,{showOverlay:!1}),u.path}catch(e){let t=e instanceof Error?e.message:`Failed to create worktree`,n=U.getState().newSessionDraft.pendingWorktreeRequestId;return n&&(_e(n,e instanceof Error?e:Error(t)),U.getState().resolvePendingDraftWorktreeTarget(n,null)),U.getState().setDraftBootstrapPendingDirectory(null),K.error(`Failed to create worktree`,{description:t}),null}finally{_n=!1}};async function Sn(){return xn()}async function Cn(e){let t=e.branch?.trim();return t?xn({existingBranch:t,projectDirectory:e.projectDirectory,initialPrompt:e.initialPrompt,title:e.title}):null}async function wn(e,t,n,r){if(_n)return null;_n=!0;try{let i=P.getState().getActiveProject();if(i?.hostId){let e=fn(i);try{if(!t.trim())throw Error(`Branch name is required`);let a=await un(i,{mode:`new`,branchName:t.trim(),worktreeName:r?.worktreeName||t.trim(),startRef:n?.trim()||`HEAD`,setUpstream:r?.setUpstream,upstreamRemote:r?.upstreamRemote,upstreamBranch:r?.upstreamBranch,ensureRemoteName:r?.ensureRemoteName,ensureRemoteUrl:r?.ensureRemoteUrl},{createSession:!0,isSelected:e,kind:r?.kind,createdFromBranch:r?.createdFromBranch});if(!a.id)throw Error(`Could not create a remote session for the worktree`);return{id:a.id,branch:a.branch,path:a.path}}catch(e){return K.error(`Failed to create worktree`,{description:e instanceof Error?e.message:String(e)}),null}}let a=n?.trim()||`HEAD`,o=t?.trim();if(!o)throw Error(`Branch name is required`);let s=r?.kind??`standard`,c=gn(e);if(!c)throw Error(`Project is not registered in Yuri`);let l=!1;try{l=await rt(c.path)}catch{}if(!l)return K.error(`Not a Git repository`,{description:`Worktrees can only be created in Git repositories.`}),null;let u=await je(c),d=await mt(c.path);try{let e=await _t(c,{preferredName:o,mode:`new`,branchName:o,worktreeName:r?.worktreeName||o,startRef:a,setUpstream:r?.setUpstream,upstreamRemote:r?.upstreamRemote,upstreamBranch:r?.upstreamBranch,ensureRemoteName:r?.ensureRemoteName,ensureRemoteUrl:r?.ensureRemoteUrl,setupCommands:u,returnAfterDirectoryCreated:r?.returnAfterDirectoryCreated}),t={...e,createdFromBranch:r?.createdFromBranch||d||a,kind:s};await hn(c,e.worktreeRoot??e.path);let n=await U.getState().createSession(void 0,e.path);if(!n)throw await pt(c,e,{deleteLocalBranch:!0}).catch(()=>void 0),Error(`Could not create a session for the worktree.`);return await yn(n.id,t,c),{id:n.id,branch:e.branch||o,path:e.path}}catch(e){let t=e instanceof Error?e.message:`Failed to create worktree session`;return K.error(`Failed to create worktree`,{description:t}),null}}finally{_n=!1}}function Tn(e){let t=(0,Z.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,style:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===i?a=t[5]:(a={color:`var(--surface-elevated-foreground)`,...i},t[4]=i,t[5]=a);let o;t[6]===n?o=t[7]:(o=G(`flex h-full w-full flex-col overflow-hidden rounded-xl`,n),t[6]=n,t[7]=o);let s;return t[8]!==r||t[9]!==a||t[10]!==o?(s=(0,Q.jsx)(Ct,{"data-slot":`command`,style:a,className:o,...r}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}var En=X.forwardRef((e,t)=>{let n=(0,Z.c)(16),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,variant:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=(a===void 0?`default`:a)===`mobileGlass`?`yuri-mobile-glass-control rounded-full`:`bg-[var(--surface-elevated)] ring-1 ring-inset ring-border/60 transition duration-200 ease-out hover:[&:not(:focus-within)]:bg-[var(--surface-subtle)] hover:[&:not(:focus-within)]:ring-transparent focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]`,s;n[4]===o?s=n[5]:(s=G(`flex h-8 items-center gap-2 rounded-lg px-3`,o),n[4]=o,n[5]=s);let c;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(Y,{name:`search`,className:`size-4 shrink-0 opacity-50`}),n[6]=c):c=n[6];let l;n[7]===r?l=n[8]:(l=G(`placeholder:text-muted-foreground flex h-8 w-full bg-transparent typography-meta outline-none focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50`,r),n[7]=r,n[8]=l);let u;n[9]!==i||n[10]!==t||n[11]!==l?(u=(0,Q.jsx)(Ct.Input,{ref:t,"data-slot":`command-input`,className:l,...i}),n[9]=i,n[10]=t,n[11]=l,n[12]=u):u=n[12];let d;return n[13]!==s||n[14]!==u?(d=(0,Q.jsx)(`div`,{"data-slot":`command-input-wrapper`,className:`p-1.5 pb-1`,children:(0,Q.jsxs)(`div`,{"data-slot":`command-input-field`,className:s,children:[c,u]})}),n[13]=s,n[14]=u,n[15]=d):d=n[15],d});En.displayName=`CommandInput`;function Dn(e){let t=(0,Z.c)(14),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,scrollbarClassName:o,disableHorizontal:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=G(`scroll-py-1 overflow-x-hidden h-full min-h-0`,r),t[6]=r,t[7]=s);let c=o??`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`,l=i??!0,u;return t[8]!==n||t[9]!==a||t[10]!==s||t[11]!==c||t[12]!==l?(u=(0,Q.jsx)(Ve,{as:Ct.List,"data-slot":`command-list`,outerClassName:`max-h-[min(600px,calc(100vh-10rem))] overflow-x-hidden p-0 w-full h-full min-h-0`,className:s,scrollbarClassName:c,disableHorizontal:l,...a,children:n}),t[8]=n,t[9]=a,t[10]=s,t[11]=c,t[12]=l,t[13]=u):u=t[13],u}function On(e){let t=(0,Z.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(Ct.Empty,{"data-slot":`command-empty`,className:`py-6 text-center typography-ui-label`,...n}),t[2]=n,t[3]=r),r}function kn(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=G(`text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:typography-meta [&_[cmdk-group-heading]]:font-medium`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Ct.Group,{"data-slot":`command-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function An(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=G(`bg-border -mx-1 h-px`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Ct.Separator,{"data-slot":`command-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function jn(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=G(`data-[selected=true]:bg-interactive-selection data-[selected=true]:text-interactive-selection-foreground data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 typography-meta outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Ct.Item,{"data-slot":`command-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Mn(e){let t=(0,Z.c)(27),{branches:n,search:r,local:i,currentBranch:a,branchInfo:o,onCheckout:s}=e,{t:c}=ze(),l;if(t[0]!==n||t[1]!==r){let e=r.trim();l=e?M(n,e,Pn).map(Nn):n,t[0]=n,t[1]=r,t[2]=l}else l=t[2];let u=l,d=i?`gitView.branch.localBranches`:`gitView.branch.remoteBranches`,f;t[3]!==c||t[4]!==d?(f=c(d),t[3]=c,t[4]=d,t[5]=f):f=t[5];let p;if(t[6]!==o||t[7]!==a||t[8]!==u||t[9]!==i||t[10]!==s||t[11]!==c){let e;t[13]!==o||t[14]!==a||t[15]!==i||t[16]!==s||t[17]!==c?(e=e=>(0,Q.jsxs)(jn,{onSelect:()=>s(e),children:[i?(0,Q.jsxs)(`span`,{className:`flex flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e}),(o?.[e]?.ahead||o?.[e]?.behind)&&(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[o[e].ahead||0,` ahead ·`,` `,o[e].behind||0,` behind`]})]}):(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e}),i&&a===e&&(0,Q.jsx)(`span`,{className:`typography-micro text-primary`,children:c(`gitView.branch.currentBadge`)})]},`${i?`local`:`remote`}-${e}`),t[13]=o,t[14]=a,t[15]=i,t[16]=s,t[17]=c,t[18]=e):e=t[18],p=u.map(e),t[6]=o,t[7]=a,t[8]=u,t[9]=i,t[10]=s,t[11]=c,t[12]=p}else p=t[12];let m;t[19]!==u.length||t[20]!==i||t[21]!==c?(m=u.length===0&&(0,Q.jsx)(jn,{disabled:!0,className:`justify-center`,children:(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:c(i?`gitView.branch.noLocalBranches`:`gitView.branch.noRemoteBranches`)})}),t[19]=u.length,t[20]=i,t[21]=c,t[22]=m):m=t[22];let h;return t[23]!==f||t[24]!==p||t[25]!==m?(h=(0,Q.jsxs)(kn,{heading:f,children:[p,m]}),t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}function Nn(e){return e.item}function Pn(e){return e}function Fn(e){let t=(0,Z.c)(9),{options:n,selectedDirectory:r,onSelect:i}=e,{t:a}=ze(),o;if(t[0]!==i||t[1]!==n||t[2]!==r||t[3]!==a){let e;t[5]!==i||t[6]!==r||t[7]!==a?(e=e=>(0,Q.jsxs)(jn,{onSelect:()=>i(e.value),children:[(0,Q.jsxs)(`span`,{className:`truncate typography-ui-label text-foreground`,children:[e.pending?`⏳ `:``,e.label]}),r===e.value?(0,Q.jsx)(`span`,{className:`typography-micro text-primary`,children:a(`gitView.branch.currentBadge`)}):null]},`worktree-${e.value}`),t[5]=i,t[6]=r,t[7]=a,t[8]=e):e=t[8],o=n.map(e),t[0]=i,t[1]=n,t[2]=r,t[3]=a,t[4]=o}else o=t[4];return o}var In=e=>e.trim().replace(/\s+/g,`-`).replace(/[^A-Za-z0-9._/-]/g,`-`).replace(/-+/g,`-`).replace(/\/{2,}/g,`/`).replace(/\/-+/g,`/`).replace(/-+\//g,`/`).replace(/^[-/]+/,``).replace(/[-/]+$/,``),Ln=({currentBranch:e,localBranches:t,remoteBranches:n,branchInfo:r,onCheckout:i,onCreate:a,remotes:o=[],disabled:s=!1,iconOnly:c=!1,trigger:l,triggerLabel:u,contentAlign:d,hideTooltip:f=!1,projectRootOption:p=null,worktreeOptions:m=[],selectedDirectory:h=null,onSelectDirectory:g,onCreateWorktree:_,worktreesLabel:v,worktreeNewLabel:y,projectRootLabel:b,onOpenChange:x,open:S,presentation:C=`dropdown`})=>{let{t:w}=ze(),[T,ee]=X.useState(!1),[E,D]=X.useState(``),[O,k]=X.useState(!1),[te,A]=X.useState(!1),[j,N]=X.useState(``),[P,F]=X.useState(!1),ne=X.useRef(null),I=X.useId(),L=S??T,R=e=>{S===void 0&&ee(e),x?.(e)},re=X.useCallback(e=>{e.stopPropagation()},[]),ie=o.length>1,ae=!!(g||_),oe=X.useMemo(()=>In(j),[j]),z=X.useMemo(()=>{let e=E.trim();return e?M(m,e,e=>e.label).map(e=>e.item):m},[E,m]),se=X.useMemo(()=>{if(!p)return!1;let e=E.trim();return!e||M([p],e,e=>[e.label,b??``]).length>0},[b,p,E]),B=t=>{if(t===e){R(!1);return}i(t),R(!1),D(``)},V=e=>{g?.(e),R(!1),D(``)},ce=()=>{k(!0),setTimeout(()=>ne.current?.focus(),50)},le=async()=>{if(!(!oe||P)){if(ie){A(!0);return}F(!0);try{await a(oe,o[0]),N(``),k(!1),R(!1)}finally{F(!1)}}},ue=async e=>{if(!(!oe||P)){F(!0);try{await a(oe,e),N(``),k(!1),A(!1),R(!1)}finally{F(!1)}}},de=()=>{A(!1)},fe=()=>{N(``),k(!1),A(!1)};X.useEffect(()=>{L||(D(``),k(!1),A(!1),N(``))},[L]);let pe=u||e||w(`gitView.branch.detachedHead`),me=d??(c?`end`:`start`),he=v??w(`chat.chatInput.worktrees`),U=y??w(`chat.chatInput.worktreeNew`),ge=b??w(`chat.chatInput.projectRoot`),_e=c?(0,Q.jsx)(`button`,{type:`button`,className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,disabled:s,"aria-label":pe,children:(0,Q.jsx)(Y,{name:`git-branch`,className:`size-3.5`})}):(0,Q.jsxs)(H,{variant:`ghost`,size:`xs`,className:`h-6 min-w-0 max-w-full justify-start gap-1 px-0 hover:bg-transparent`,disabled:s,"aria-label":pe,children:[(0,Q.jsx)(Y,{name:`git-branch`,className:`size-3.5 text-primary`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate typography-ui-label font-semibold text-left text-foreground`,children:pe}),(0,Q.jsx)(Y,{name:`arrow-down-s`,className:`size-3 shrink-0 text-muted-foreground`})]}),ve=(0,Q.jsx)(Ze,{asChild:!0,disabled:s,children:l??_e}),ye=(0,Q.jsxs)(Tn,{className:`h-full min-h-0`,children:[(0,Q.jsx)(`div`,{"data-mobile-sheet-no-dismiss":C===`mobile-sheet`?``:void 0,children:(0,Q.jsx)(En,{placeholder:w(`gitView.branch.searchPlaceholder`),value:E,onValueChange:D,onKeyDown:re})}),(0,Q.jsxs)(Dn,{scrollbarClassName:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`,disableHorizontal:!0,children:[(0,Q.jsx)(On,{children:w(`gitView.branch.empty`)}),(0,Q.jsx)(kn,{children:te?(0,Q.jsxs)(`div`,{className:`px-2 py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:de,disabled:P,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:(0,Q.jsx)(Y,{name:`arrow-left`,className:`size-4`})}),(0,Q.jsxs)(`span`,{className:`typography-meta text-muted-foreground`,children:[w(`gitView.branch.pushToPrefix`),` `,(0,Q.jsx)(`span`,{className:`text-foreground font-medium`,children:oe}),` `,w(`gitView.branch.pushToSuffix`)]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>ue(e),disabled:P,className:`flex flex-col items-start gap-0.5 px-2 py-1.5 rounded-md text-left hover:bg-accent disabled:opacity-50`,children:[(0,Q.jsxs)(`span`,{className:`typography-ui-label text-foreground`,children:[P?(0,Q.jsx)(Y,{name:`loader-4`,className:`inline size-3 mr-1.5 animate-spin`}):null,e.name]}),(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground truncate max-w-full`,children:e.pushUrl})]},e.name))})]}):O?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 rounded-lg`,children:[(0,Q.jsx)(`input`,{ref:ne,placeholder:w(`gitView.branch.newBranchPlaceholder`),value:j,onChange:e=>N(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:e=>{re(e),e.key===`Enter`?(e.preventDefault(),le()):e.key===`Escape`&&(e.preventDefault(),fe())},className:`flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground`}),(0,Q.jsx)(`button`,{type:`button`,onClick:le,disabled:!oe||P,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:P?(0,Q.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(Y,{name:`add`,className:`size-4`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:fe,disabled:P,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:(0,Q.jsx)(Y,{name:`close`,className:`size-4`})})]}):(0,Q.jsxs)(jn,{onSelect:ce,children:[(0,Q.jsx)(Y,{name:`add`,className:`size-4`}),(0,Q.jsx)(`span`,{children:w(`gitView.branch.create`)})]})}),(0,Q.jsx)(An,{}),(0,Q.jsx)(Mn,{branches:t,search:E,local:!0,currentBranch:e,branchInfo:r,onCheckout:B}),(0,Q.jsx)(An,{}),(0,Q.jsx)(Mn,{branches:n,search:E,onCheckout:B}),ae?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(An,{}),(0,Q.jsxs)(kn,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground typography-meta`,children:he}),_?(0,Q.jsx)(`button`,{type:`button`,className:`cursor-pointer text-muted-foreground typography-meta hover:text-foreground`,onPointerDown:e=>{e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation(),R(!1),_()},children:U}):null]}),p&&se?(0,Q.jsxs)(jn,{onSelect:()=>V(p.value),children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:ge}),(0,Q.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:p.label})]}),h===p.value?(0,Q.jsx)(`span`,{className:`typography-micro text-primary`,children:w(`gitView.branch.currentBadge`)}):null]}):null,(0,Q.jsx)(Fn,{options:z,selectedDirectory:h,onSelect:V})]})]}):null]})]});if(C===`mobile-sheet`){let e=X.cloneElement(l??_e,{onClick:()=>R(!0),"data-popup-open":L?``:void 0});return(0,Q.jsxs)(Q.Fragment,{children:[e,(0,Q.jsx)(He,{id:`mobile-draft-branch-picker-sheet-${I}`,open:L,onOpenChange:R,ariaLabel:w(`gitView.branch.selectBranch`),closeAriaLabel:w(`mobile.surface.closeAria`),resizeAriaLabel:w(`mobile.sessions.sheet.resizeAria`),children:ye})]})}return(0,Q.jsxs)($e,{open:L,onOpenChange:R,children:[f||l?ve:(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(Je,{asChild:!0,children:ve}),(0,Q.jsx)(Ye,{sideOffset:8,children:c?pe:w(`gitView.branch.currentBranchTooltip`)})]}),(0,Q.jsx)(Qe,{align:me,className:`w-72 p-0 max-h-[60vh] flex flex-col`,children:ye})]})};function Rn(e){let{localBranches:t,remoteBranches:n,query:r}=e,i=r.trim();if(!i)return{matching:[],otherLocal:t,otherRemote:n};let a=M(t,i,e=>e),o=M(n,i,e=>e),s=new Set(a.map(e=>e.item)),c=new Set(o.map(e=>e.item));return{matching:[...a.map(e=>({label:e.item,value:e.item,source:`local`,score:e.score})),...o.map(e=>({label:e.item,value:`remotes/${e.item}`,source:`remote`,score:e.score}))].sort((e,t)=>e.score===t.score?e.source===t.source?e.label.length===t.label.length?e.label.localeCompare(t.label,void 0,{sensitivity:`accent`}):e.label.length-t.label.length:e.source===`local`?-1:1:e.score-t.score).map(({label:e,value:t,source:n})=>({label:e,value:t,source:n})),otherLocal:t.filter(e=>!s.has(e)),otherRemote:n.filter(e=>!c.has(e))}}function zn(e){let t=E(e),n=(e,n={})=>t.json(`/api/github/${e}`,{query:n}),r=e=>e?{owner:e.owner,repo:e.repo}:{};return{authStatus:()=>n(`auth/status`),issuesList:(e,t)=>n(`issues/list`,{directory:e,page:t?.page,query:t?.query}),prsList:(e,t)=>n(`pulls/list`,{directory:e,page:t?.page,query:t?.query}),issueGet:(e,t,i)=>n(`issues/get`,{directory:e,number:t,...r(i?.sourceRepo)}),issueComments:(e,t,i)=>n(`issues/comments`,{directory:e,number:t,...r(i?.sourceRepo)}),prContext:(e,t,i)=>n(`pulls/context`,{directory:e,number:t,...r(i?.sourceRepo),diff:i?.includeDiff?`1`:void 0,checkDetails:i?.includeCheckDetails?`1`:void 0})}}var Bn=e=>({queryKey:[...e.queryScope,`worktree-dialog`,`github-auth`],queryFn:({signal:t})=>E(e).json(`/api/github/auth/status`,{signal:t}),staleTime:3e4,gcTime:1/0});function Vn(e,t){let n=(0,Z.c)(12),r=D(),i=e?void 0:r.github,a;n[0]!==e||n[1]!==i?(a=e?zn(e):i,n[0]=e,n[1]=i,n[2]=a):a=n[2];let o=a,s;n[3]!==e||n[4]!==r?(s=e?Bn(e):dt(r.github),n[3]=e,n[4]=r,n[5]=s):s=n[5];let c;n[6]!==t||n[7]!==s?(c={...s,enabled:t},n[6]=t,n[7]=s,n[8]=c):c=n[8];let l=w(c,O),u;return n[9]!==l||n[10]!==o?(u={github:o,auth:l},n[9]=l,n[10]=o,n[11]=u):u=n[11],u}async function Hn(e,t,n={}){let r=await E(e).json(`/api/magic-prompts`);return(typeof r.overrides?.[t]==`string`?r.overrides[t]:it(t)).replace(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g,(e,t)=>Object.prototype.hasOwnProperty.call(n,t)?n[t]??``:``)}async function Un(e,t,n,r,i,a){let o=zn(t),s=i.issue,l=i.pr;if(!s&&!l)return;let u=s?`issue`:`pr`,d=s?.number??l.number,f=await Hn(t,`github.${u}.review.visible`,{[`${u}_number`]:String(d)}),p=await Hn(t,`github.${u}.review.instructions`),m;if(s){let e=await o.issueGet(t.location.directory,d,{sourceRepo:s.sourceRepo}),n=await o.issueComments(t.location.directory,d,{sourceRepo:s.sourceRepo});if(e.connected===!1||!e.issue||n.connected===!1)throw Error(a);m=`GitHub issue context (JSON)\n${JSON.stringify({repo:e.repo??null,issue:e.issue,comments:n.comments??[]},null,2)}`}else{let e=await o.prContext(t.location.directory,d,{sourceRepo:l.sourceRepo,includeDiff:i.includeDiff,includeCheckDetails:!1});if(e.connected===!1||!e.pr)throw Error(a);m=`GitHub pull request context (JSON)\n${JSON.stringify(e,null,2)}`}t.sdk();let h=e.resolve({...t.location,directory:n});await Me(e,h).state.send({sessionID:r,messageID:c(`msg`),text:[f,p,m].join(`
|
|
3
|
-
|
|
4
|
-
`)})}function Wn(e){let t=(0,Z.c)(41),{project:n,open:r,onClose:i,children:a}=e,o=ee(),s=n?.hostId&&o&&o.entry.location.hubId===n.hubId&&o.entry.location.hostId===n.hostId&&o.entry.location.directory===n.path,c=Le(!!(r&&n?.hostId&&!s)),{t:l}=ze();if(!n?.hostId){let e;return t[0]===a?e=t[1]:(e=(0,Q.jsx)(T.Provider,{value:null,children:a}),t[0]=a,t[1]=e),e}if(s)return a;if(!r)return null;if(!c.registry||c.registry.hubId!==n.hubId){let e;t[2]===i?e=t[3]:(e=e=>{e||i()},t[2]=i,t[3]=e);let n;t[4]===l?n=t[5]:(n=l(`session.newWorktree.title`),t[4]=l,t[5]=n);let r;t[6]===n?r=t[7]:(r=(0,Q.jsx)(Ue,{children:(0,Q.jsx)(Ke,{children:n})}),t[6]=n,t[7]=r);let a=c.isPending?`status`:`alert`,o;t[8]!==c.error?.message||t[9]!==c.isPending||t[10]!==l?(o=c.isPending?l(`remoteProjects.running`):c.error?.message||l(`remoteProjects.host-unavailable`),t[8]=c.error?.message,t[9]=c.isPending,t[10]=l,t[11]=o):o=t[11];let s;t[12]!==a||t[13]!==o?(s=(0,Q.jsx)(`p`,{role:a,children:o}),t[12]=a,t[13]=o,t[14]=s):s=t[14];let u;t[15]===l?u=t[16]:(u=l(`session.newWorktree.actions.cancel`),t[15]=l,t[16]=u);let d;t[17]!==i||t[18]!==u?(d=(0,Q.jsx)(H,{onClick:i,children:u}),t[17]=i,t[18]=u,t[19]=d):d=t[19];let f;t[20]!==c.isPending||t[21]!==l?(f=c.isPending?null:(0,Q.jsx)(H,{onClick:Gn,children:l(`remoteProjects.retry`)}),t[20]=c.isPending,t[21]=l,t[22]=f):f=t[22];let p;t[23]!==d||t[24]!==f?(p=(0,Q.jsxs)(We,{children:[d,f]}),t[23]=d,t[24]=f,t[25]=p):p=t[25];let m;t[26]!==p||t[27]!==r||t[28]!==s?(m=(0,Q.jsxs)(Ge,{children:[r,s,p]}),t[26]=p,t[27]=r,t[28]=s,t[29]=m):m=t[29];let h;return t[30]!==e||t[31]!==m?(h=(0,Q.jsx)(qe,{open:!0,onOpenChange:e,children:m}),t[30]=e,t[31]=m,t[32]=h):h=t[32],h}let u;t[33]!==n.hostId||t[34]!==n.hubId||t[35]!==n.path?(u={hubId:n.hubId,hostId:n.hostId,directory:n.path},t[33]=n.hostId,t[34]=n.hubId,t[35]=n.path,t[36]=u):u=t[36];let d;return t[37]!==a||t[38]!==c.registry||t[39]!==u?(d=(0,Q.jsx)(k,{registry:c.registry,location:u,children:a}),t[37]=a,t[38]=c.registry,t[39]=u,t[40]=d):d=t[40],d}function Gn(){Re().catch(Kn)}function Kn(){}var qn=(e,t,n)=>{let r=n??t;return r?e.find(e=>e.id===r)??null:null};function Jn(e,t){return`${e}\0${t}`}function Yn(e){let t=(0,Z.c)(12),n;t[0]===e.projectId?n=t[1]:(n=t=>qn(t.projects,t.activeProjectId,e.projectId),t[0]=e.projectId,t[1]=n);let r=P(n),i;t[2]===e?i=t[3]:(i=()=>e.onOpenChange(!1),t[2]=e,t[3]=i);let a=r?.id,o;t[4]!==e||t[5]!==a?(o=(0,Q.jsx)(Xn,{...e},a),t[4]=e,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==e.open||t[9]!==i||t[10]!==o?(s=(0,Q.jsx)(Wn,{project:r,open:e.open,onClose:i,children:o}),t[7]=r,t[8]=e.open,t[9]=i,t[10]=o,t[11]=s):s=t[11],s}function Xn({open:e,onOpenChange:t,onSelect:n,projectId:r}){let{t:i}=ze(),a=j(e=>e.isMobile),o=ee(),s=o?.entry.location.hostId?o.entry:void 0,{git:c}=et(),{github:l,auth:u}=Vn(s,e),d=u.data??null,f=u.isFetched,p=j(e=>e.setSettingsDialogOpen),m=j(e=>e.setSettingsPage),h=P(e=>qn(e.projects,e.activeProjectId,r)),g=h?.id??null,_=h?.path??null,v=X.useMemo(()=>_&&g?{id:g,path:_,hostId:h?.hostId,hubId:h?.hubId}:null,[g,_,h?.hostId,h?.hubId]),[y,b]=X.useState(`issues`),[x,S]=X.useState(``),[C,w]=X.useState([]),[T,E]=X.useState([]),[D,O]=X.useState(!1),[k,A]=X.useState(!1),[M,N]=X.useState(null),[F,ne]=X.useState(null),[I,L]=X.useState(null),[R,re]=X.useState(!1),[ie,ae]=X.useState(new Map),[oe,z]=X.useState(1),[se,B]=X.useState(!1),V=X.useRef(0),ce=ct(x,350),le=te(async e=>{if(!(!_||!l)&&!(f&&d?.connected===!1)){O(!0),N(null),z(1),B(!1);try{if(y===`issues`&&l.issuesList){let t=await l.issuesList(_,{page:1,query:e});t.connected===!1?(N(i(`session.githubIntegration.error.notConnected`)),w([])):(w(t.issues??[]),z(t.page??1),B(!!t.hasMore))}else if(y===`prs`&&l.prsList){let t=await l.prsList(_,{page:1,query:e});t.connected===!1?(N(i(`session.githubIntegration.error.notConnected`)),E([])):(E(t.prs??[]),z(t.page??1),B(!!t.hasMore))}}catch(e){N(e instanceof Error?e.message:i(`session.githubIntegration.error.loadDataFailed`))}finally{O(!1)}}});X.useEffect(()=>{if(!e||!_||f&&d?.connected===!1||!l)return;if(!ce.trim()){le();return}let t=new AbortController;O(!0),N(null),z(1),B(!1);let n=y===`issues`&&l.issuesList?l.issuesList(_,{page:1,query:ce.trim()}):y===`prs`&&l.prsList?l.prsList(_,{page:1,query:ce.trim()}):null;if(!n){O(!1);return}return n.then(e=>{t.signal.aborted||(`issues`in e?e.connected===!1?(N(i(`session.githubIntegration.error.notConnected`)),w([])):(w(e.issues??[]),z(e.page??1),B(!!e.hasMore)):`prs`in e&&(e.connected===!1?(N(i(`session.githubIntegration.error.notConnected`)),E([])):(E(e.prs??[]),z(e.page??1),B(!!e.hasMore))))}).catch(e=>{t.signal.aborted||N(e instanceof Error?e.message:i(`session.githubIntegration.error.loadDataFailed`))}).finally(()=>{t.signal.aborted||O(!1)}),()=>t.abort()},[e,_,l,f,d,y,ce,le,i]);let ue=te(async()=>{if(!(!_||!l)&&!(D||k)&&se){A(!0);try{let e=oe+1;if(y===`issues`&&l.issuesList){let t=ce.trim()?await l.issuesList(_,{page:e,query:ce.trim()}):await l.issuesList(_,{page:e});t.connected!==!1&&(w(e=>[...e,...t.issues??[]]),z(t.page??e),B(!!t.hasMore))}else if(y===`prs`&&l.prsList){let t=ce.trim()?await l.prsList(_,{page:e,query:ce.trim()}):await l.prsList(_,{page:e});t.connected!==!1&&(E(e=>[...e,...t.prs??[]]),z(t.page??e),B(!!t.hasMore))}}catch{}finally{A(!1)}}});X.useEffect(()=>{if(!e){b(`issues`),S(``),w([]),E([]),ne(null),L(null),re(!1),N(null),ae(new Map),z(1),B(!1);return}le()},[e,le]),X.useEffect(()=>{V.current+=1,ae(new Map)},[_,v]);let de=te(async e=>{if(!v||!e)return;let t=Jn(v.path,e);if(ie.has(t))return;let n=V.current;try{let r={mode:`new`,branchName:e,worktreeName:e},a=s?await c.validateGitWorktree(v.path,r):await ft(v,r);if(n!==V.current)return;let o=a.errors.find(e=>e.code===`branch_in_use`);ae(e=>new Map(e).set(t,{isValid:!o,error:o?i(o.code===`branch_exists`?`session.githubIntegration.validation.branchAlreadyExists`:`session.githubIntegration.validation.branchAlreadyCheckedOut`):null}))}catch{if(n!==V.current)return;ae(e=>new Map(e).set(t,{isValid:!1,error:i(`session.githubIntegration.validation.failed`)}))}});X.useEffect(()=>{!e||y!==`prs`||T.forEach(e=>{e.head&&de(e.head)})},[e,y,T,_,v,de]);let fe=f&&d?.connected===!0,pe=()=>{if(s){K.info(i(`remoteProjects.configurationReadOnly`));return}m(`github`),p(!0)},me=e=>{ne(e),L(null)},he=e=>{L(e),ne(null)},U=()=>{F?n({type:`issue`,item:F}):I&&n({type:`pr`,item:I,includeDiff:R}),t(!1)},ge=()=>{ne(null),L(null),re(!1)},_e=F||(I?.head&&_?ie.get(Jn(_,I.head))?.isValid!==!1:!1),ve=e=>!e.head||(_?ie.get(Jn(_,e.head)):void 0)?.isValid===!1,ye=(0,Q.jsxs)(Q.Fragment,{children:[s&&u.error?(0,Q.jsxs)(`div`,{role:`alert`,className:`typography-small text-destructive`,children:[u.error.message,(0,Q.jsx)(H,{variant:`ghost`,size:`xs`,onClick:()=>{u.refetch()},children:i(`remoteProjects.retry`)})]}):null,fe?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`yuri-picker-search relative mt-2`,children:[(0,Q.jsx)(Y,{name:`search`,className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(st,{value:x,onChange:e=>S(e.target.value),placeholder:i(y===`issues`?`session.githubIntegration.search.issuesPlaceholder`:`session.githubIntegration.search.prsPlaceholder`),className:`h-8 pl-9`})]}),(0,Q.jsx)(`div`,{className:`yuri-picker-list mt-2 h-[300px] overflow-hidden`,children:(0,Q.jsxs)(`div`,{className:`h-full overflow-y-auto`,children:[D&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Q.jsx)(Y,{name:`loader-4`,className:`h-5 w-5 animate-spin text-muted-foreground`})}),M&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-md bg-destructive/10 text-destructive`,children:[(0,Q.jsx)(Y,{name:`error-warning`,className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`typography-small`,children:M})]})}),!D&&!M&&y===`issues`&&(0,Q.jsxs)(`div`,{className:`space-y-0.5 min-h-full`,children:[C.length>0?C.map(e=>(0,Q.jsx)(`button`,{onClick:()=>me(e),className:G(`yuri-picker-row w-full text-left px-2 py-1.5 rounded transition-colors`,F?.number===e.number?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0 typography-micro`,children:[`#`,e.number]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`yuri-picker-label typography-small line-clamp-2`,children:e.title}),e.sourceRepo?.source===`upstream`?(0,Q.jsxs)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info mt-0.5 inline-block`,children:[e.sourceRepo.owner,`/`,e.sourceRepo.repo]}):null]})]})},`${e.sourceRepo?.owner??``}-${e.sourceRepo?.repo??``}-${e.number}`)):(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground`,children:i(`session.githubIntegration.empty.noIssuesFound`)}),se&&!k&&(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>void ue(),className:`h-7 text-xs`,children:i(`session.githubIntegration.actions.loadMore`)})}),k&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-2`,children:(0,Q.jsx)(Y,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`})})]}),!D&&!M&&y===`prs`&&(0,Q.jsxs)(`div`,{className:`space-y-0.5 min-h-full`,children:[T.length>0?T.map(e=>{let t=ve(e),n=e.head&&_?ie.get(Jn(_,e.head)):void 0;return(0,Q.jsx)(`button`,{onClick:()=>!t&&he(e),disabled:t,className:G(`yuri-picker-row w-full text-left px-2 py-1.5 rounded transition-colors`,I?.number===e.number?`bg-interactive-selection text-interactive-selection-foreground`:t?`opacity-50 cursor-not-allowed`:`hover:bg-interactive-hover`),children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0 typography-micro`,children:[`#`,e.number]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`yuri-picker-label typography-small line-clamp-1`,children:e.title}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[e.head,` → `,e.base]}),e.sourceRepo?.source===`upstream`?(0,Q.jsxs)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info`,children:[e.sourceRepo.owner,`/`,e.sourceRepo.repo]}):null,t&&n?.error&&(0,Q.jsx)(`span`,{className:`typography-micro text-destructive`,children:n.error})]})]})]})},`${e.sourceRepo?.owner??``}-${e.sourceRepo?.repo??``}-${e.number}`)}):(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground`,children:i(`session.githubIntegration.empty.noPullRequestsFound`)}),se&&!k&&(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>void ue(),className:`h-7 text-xs`,children:i(`session.githubIntegration.actions.loadMore`)})}),k&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-2`,children:(0,Q.jsx)(Y,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`})})]})]})})]}):(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center p-8 gap-4`,children:[(0,Q.jsx)(Y,{name:`github`,className:`h-12 w-12 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`text-center`,children:[(0,Q.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:i(`session.githubIntegration.connect.title`)}),(0,Q.jsx)(`p`,{className:`typography-small text-muted-foreground mt-1`,children:i(`session.githubIntegration.connect.description`)})]}),(0,Q.jsx)(H,{onClick:pe,size:`sm`,children:i(`session.githubIntegration.connect.action`)})]})]}),be=(0,Q.jsxs)(`div`,{className:G(`w-full`,a?`flex flex-col gap-2`:`flex flex-row items-center`),children:[(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-4`,a?`w-full justify-center order-1`:`flex-1`),children:[!a&&(F||I)&&(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),(0,Q.jsx)(`span`,{className:`typography-small truncate max-w-[150px]`,children:F?i(`session.githubIntegration.selected.issueNumber`,{number:F.number}):i(`session.githubIntegration.selected.prNumber`,{number:I?.number??``})}),(0,Q.jsx)(`button`,{onClick:ge,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]}),y===`prs`&&I&&(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer h-8`,children:[(0,Q.jsx)(lt,{checked:R,onChange:e=>re(e),ariaLabel:i(`session.githubIntegration.includeDiffAria`)}),(0,Q.jsx)(`span`,{className:`typography-small text-foreground`,children:i(`session.githubIntegration.includeDiff`)})]})]}),(0,Q.jsxs)(`div`,{className:G(`flex gap-2`,a?`w-full order-2`:`justify-end`),children:[(0,Q.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>t(!1),className:G(a&&`flex-1`),children:i(`session.githubIntegration.actions.cancel`)}),(0,Q.jsx)(H,{size:`sm`,onClick:U,disabled:!_e,className:G(a&&`flex-1`),children:i(`session.githubIntegration.actions.select`)})]})]});return(0,Q.jsx)(Q.Fragment,{children:a?(0,Q.jsx)(ut,{open:e,title:i(`session.githubIntegration.title`),onClose:()=>t(!1),footer:fe?be:void 0,renderHeader:e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 py-2 border-b border-border/40`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:i(`session.githubIntegration.title`)}),e]}),(0,Q.jsx)(`div`,{className:`w-full`,children:(0,Q.jsx)(wt,{items:[{id:`issues`,label:i(`session.githubIntegration.tabs.issues`),icon:(0,Q.jsx)(Y,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`prs`,label:i(`session.githubIntegration.tabs.pullRequests`),icon:(0,Q.jsx)(Y,{name:`git-pull-request`,className:`h-3.5 w-3.5`})}],activeId:y,onSelect:e=>{b(e),S(``)},variant:`active-pill`,layoutMode:`fit`})}),(F||I)&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1 rounded-md bg-muted/50 border border-border/50`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),(0,Q.jsx)(`span`,{className:`typography-small truncate flex-1`,children:F?i(`session.githubIntegration.selected.issueNumber`,{number:F.number}):i(`session.githubIntegration.selected.prNumber`,{number:I?.number??``})}),(0,Q.jsx)(`button`,{onClick:ge,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]})]}),children:ye}):(0,Q.jsx)(qe,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Ge,{presentation:`picker`,children:[(0,Q.jsx)(Ue,{className:`yuri-picker-header`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-3`,children:[(0,Q.jsx)(Ke,{className:`yuri-picker-title`,children:i(`session.githubIntegration.title`)}),(0,Q.jsx)(`div`,{className:`w-[220px]`,children:(0,Q.jsx)(wt,{items:[{id:`issues`,label:i(`session.githubIntegration.tabs.issues`),icon:(0,Q.jsx)(Y,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`prs`,label:i(`session.githubIntegration.tabs.pullRequests`),icon:(0,Q.jsx)(Y,{name:`git-pull-request`,className:`h-3.5 w-3.5`})}],activeId:y,onSelect:e=>{b(e),S(``)},variant:`active-pill`,layoutMode:`fit`})})]})}),ye,(0,Q.jsx)(We,{className:`yuri-picker-footer`,children:be})]})})})}var Zn=e=>e.trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/\s+/g,`-`).replace(/^\/+|\/+$/g,``),$=e=>e.trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/\s+/g,`-`).replace(/^\/+|\/+$/g,``).split(`/`).join(`-`).replace(/[^A-Za-z0-9._-]+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``).slice(0,80),Qn=e=>String(e||``).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``)||`pr-head`,$n=(e,t,n)=>{let r=Zn(e.head||``);if(!r)throw Error(`PR head branch is missing`);if(t.includes(r))return{existingBranch:r,setUpstream:void 0,upstreamRemote:void 0,upstreamBranch:void 0,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:r};let i=n.find(e=>{let t=e.indexOf(`/`);return t<=0||t>=e.length-1?!1:e.slice(t+1)===r});if(i){let e=i.indexOf(`/`),t=i.slice(0,e);return{existingBranch:`remotes/${i}`,setUpstream:!0,upstreamRemote:t,upstreamBranch:r,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${t}/${r}`}}let a=String(e.headLabel||``).split(`:`)[0]?.trim(),o=`pr-${Qn(e.headRepo?.owner||a||`pr-head`)}`,s=e.headRepo?.sshUrl||e.headRepo?.cloneUrl||``;if(!s)throw Error(`PR head repository URL is unavailable`);return{existingBranch:`remotes/${o}/${r}`,setUpstream:!0,upstreamRemote:o,upstreamBranch:r,ensureRemoteName:o,ensureRemoteUrl:s,sourceLabel:`${o}/${r}`}},er=e=>{let t={repo:e.repo??null,issue:e.issue,comments:e.comments};return`GitHub issue context (JSON)\n${JSON.stringify(t,null,2)}`},tr=e=>`GitHub pull request context (JSON)\n${JSON.stringify(e,null,2)}`;function nr(e){let t=(0,Z.c)(12),n;t[0]===e.projectId?n=t[1]:(n=t=>qn(t.projects,t.activeProjectId,e.projectId),t[0]=e.projectId,t[1]=n);let r=P(n),i;t[2]===e?i=t[3]:(i=()=>e.onOpenChange(!1),t[2]=e,t[3]=i);let a=r?.id,o;t[4]!==e||t[5]!==a?(o=(0,Q.jsx)(rr,{...e},a),t[4]=e,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==e.open||t[9]!==i||t[10]!==o?(s=(0,Q.jsx)(Wn,{project:r,open:e.open,onClose:i,children:o}),t[7]=r,t[8]=e.open,t[9]=i,t[10]=o,t[11]=s):s=t[11],s}function rr({open:e,onOpenChange:t,onWorktreeCreated:n,projectId:r}){let{t:i}=ze(),{git:a}=et(),o=ee(),s=o?.entry.location.hostId?o.entry:void 0,{github:c,auth:l}=Vn(s,e),u=j(e=>e.isMobile),d=X.useId(),f=l.data??null,p=l.isFetched,m=P(e=>qn(e.projects,e.activeProjectId,r)),h=m?.path??null,g=X.useMemo(()=>h&&m?{id:m.id,path:h,hostId:m.hostId,hubId:m.hubId}:null,[m,h]),[_,v]=X.useState(`new-branch`),[y,b]=X.useState({branchName:``,worktreeName:``,isSyncingWorktreeName:!0,sourceBranch:``,linkedIssue:null,linkedPr:null,includePrDiff:!1}),[x,S]=X.useState({selectedBranch:``,worktreeName:``}),C=ot(h),T=at(e=>h?e.directories.get(h)?.isLoadingBranches??!1:!1),E=at(e=>e.fetchBranches),D=X.useMemo(()=>C?.all?C.all.filter(e=>!e.startsWith(`remotes/`)).sort():[],[C]),k=X.useMemo(()=>C?.all?C.all.filter(e=>e.startsWith(`remotes/`)).map(e=>e.replace(/^remotes\//,``)).sort():[],[C]),te=U(e=>e.availableWorktreesByProject),A=w({queryKey:[...s?.queryScope??[`local`],`worktree-dialog`,`worktrees`],enabled:!!(s&&e&&h),queryFn:()=>a.listGitWorktrees(h),staleTime:3e4,gcTime:1/0},O),M=X.useMemo(()=>{if(!h)return new Set;let e=s?A.data??[]:te.get(h)??[];return new Set(e.map(e=>e.name))},[te,h,s,A.data]),N=X.useCallback((e=10)=>{for(let t=0;t<e;t++){let e=cn();if(!M.has(e))return e}return`${cn()}-${Date.now().toString(36).slice(-4)}`},[M]),[F,I]=X.useState(!1),[L,R]=X.useState(!1),[re,ie]=X.useState(!1),[ae,oe]=X.useState(!1),[z,se]=X.useState(!1),[B,ce]=X.useState(``),[le,ue]=X.useState(``),pe=X.useRef(null),me=X.useRef(null),ge=X.useRef(null),_e=X.useRef(null),ve=X.useCallback(e=>{e.stopPropagation()},[]),ye=X.useCallback(e=>{let t=e;for(;t&&t!==document.body;){let{overflowY:e}=window.getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null},[]),be=X.useCallback(e=>{e&&(e.scrollTop=0)},[]),xe=X.useCallback(e=>{let t=e.current?.querySelector(`[data-slot="command-list"]`)??null;be(t)},[be]),Se=X.useCallback(e=>{let t=ye(e.current);be(t)},[ye,be]),Ce=X.useMemo(()=>Rn({localBranches:D,remoteBranches:k,query:B}),[D,k,B]),W=X.useMemo(()=>Rn({localBranches:D,remoteBranches:k,query:le}),[D,k,le]),Te=B.trim().length>0,Ee=le.trim().length>0,De=Ce.matching.length>0,Oe=W.matching.length>0,Me=!!(h&&a),Ne=X.useCallback(()=>{!h||!a||E(h,a)},[h,a,E]);X.useEffect(()=>{!e||!h||!a||C?.all||E(h,a)},[e,h,a,C?.all,E]),X.useEffect(()=>{!L&&!ae&&ce(``)},[L,ae]),X.useEffect(()=>{!re&&!z&&ue(``)},[re,z]),X.useEffect(()=>{L&&xe(pe),ae&&Se(ge)},[L,ae,B,xe,Se]),X.useEffect(()=>{re&&xe(me),z&&Se(_e)},[re,z,le,xe,Se]);let[q,J]=X.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[Pe,Fe]=X.useState(!1),[Ie,Le]=X.useState(null),Re=X.useCallback(()=>{let e=de.getState(),t=e.getVisibleAgents();if(e.settingsDefaultAgent){let n=t.find(t=>t.name===e.settingsDefaultAgent);if(n)return n.name}return t.find(e=>e.name===`build`)?.name||t[0]?.name},[]),Be=X.useCallback(()=>{let e=de.getState(),t=e.settingsDefaultModel??(e.currentModelId?void 0:e.opencodeDefaultModel);if(!t)return null;let n=ne(t);if(!n)return null;let{providerId:r,modelId:i}=n;return{providerID:r,modelID:i}},[]),Je=X.useCallback((e,t)=>{let n=de.getState(),r=ne(n.settingsDefaultModel??n.opencodeDefaultModel),i=r?.providerId===e&&r.modelId===t?r.variant??n.settingsDefaultVariant:void 0,a=n.currentProviderId===e&&n.currentModelId===t?n.currentVariant:void 0;return i??a},[]),Ye=X.useCallback(async e=>{if(!h||!c)return;let t=de.getState(),n=Ae.getState().lastUsedProvider,r=Be(),a=r?.providerID||t.currentProviderId||n?.providerID,o=r?.modelID||t.currentModelId||n?.modelID,s=Re()||t.currentAgentName||void 0;if(!a||!o){K.error(i(`session.newWorktree.error.noModelSelected`));return}let l=Je(a,o);if(e.issue){if(!c.issueGet||!c.issueComments)return;let t=await c.issueGet(h,e.issue.number,{sourceRepo:e.issue.sourceRepo??null});if(t.connected===!1||!t.repo||!t.issue)throw Error(`Failed to load issue context`);let n=await c.issueComments(h,e.issue.number,{sourceRepo:e.issue.sourceRepo??null});if(n.connected===!1)throw Error(`Failed to load issue comments`);let r=await tt(`github.issue.review.visible`,{issue_number:String(e.issue.number)}),u=await tt(`github.issue.review.instructions`),d=er({repo:t.repo,issue:t.issue,comments:n.comments??[]});await U.getState().sendMessage(r,a,o,s,void 0,void 0,[{text:u,synthetic:!0},{text:d,synthetic:!0}],l,void 0,{sessionId:e.sessionId}),K.success(i(`session.newWorktree.toast.sessionFromIssue`));return}if(e.pr){if(!c.prContext)return;let t=await c.prContext(h,e.pr.number,{sourceRepo:e.pr.sourceRepo??null,includeDiff:e.includeDiff,includeCheckDetails:!1});if(t.connected===!1||!t.repo||!t.pr)throw Error(`Failed to load PR context`);let n=await tt(`github.pr.review.visible`,{pr_number:String(e.pr.number)}),r=await tt(`github.pr.review.instructions`),u=tr(t);await U.getState().sendMessage(n,a,o,s,void 0,void 0,[{text:r,synthetic:!0},{text:u,synthetic:!0}],l,void 0,{sessionId:e.sessionId}),K.success(i(`session.newWorktree.toast.sessionFromPr`))}},[c,h,Re,Be,Je,i]),Xe=_===`new-branch`?y:x;X.useEffect(()=>{if(!e||!C?.all||!h||y.sourceBranch)return;let t=y.sourceBranch,n=!1;return(async()=>{try{let e=s?(await a.getGitStatus(h)).current:await mt(h).catch(()=>null);if(n)return;let r=localStorage.getItem(xt),{sourceBranch:i,shouldClearSavedSourceBranch:o}=vt({branches:C.all,savedSourceBranch:r,rootBranch:e});if(o&&localStorage.removeItem(xt),n||t)return;i&&b(e=>({...e,sourceBranch:i}))}catch{}})(),()=>{n=!0}},[e,C?.all,h,y.sourceBranch,s,a]),X.useLayoutEffect(()=>{if(!e)return;v(`new-branch`),S({selectedBranch:``,worktreeName:``}),R(!1),ie(!1),oe(!1),se(!1),ce(``),ue(``),J({isValidating:!1,branchError:null,worktreeError:null,touched:!1});let t=N();b({branchName:t,worktreeName:t,isSyncingWorktreeName:!0,sourceBranch:``,linkedIssue:null,linkedPr:null,includePrDiff:!1})},[e,N]),X.useEffect(()=>{if(_!==`new-branch`||!y.isSyncingWorktreeName)return;let e=$(Zn(y.branchName));b(t=>({...t,worktreeName:e}))},[_,y.branchName,y.isSyncingWorktreeName]);let nt=X.useCallback(async()=>{if(!g||!q.touched||Pe)return;Ie&&Ie.abort();let e=new AbortController;Le(e),J(e=>({...e,isValidating:!0}));try{let t=_===`new-branch`?y.branchName:x.selectedBranch,n=Xe.worktreeName,r=Zn(t),o=$(n),c=null,l=null;if(r||(c=i(`session.newWorktree.error.branchNameRequired`)),o||(l=i(`session.newWorktree.error.worktreeDirectoryRequired`)),r&&o){let t=_===`new-branch`?y.linkedPr:null,n=t?$n(t,D,k):null,i={mode:_===`existing-branch`||n?`existing`:`new`,branchName:r,worktreeName:o,existingBranch:n?.existingBranch??(_===`existing-branch`?r:void 0),...n?.ensureRemoteName?{ensureRemoteName:n.ensureRemoteName}:{},...n?.ensureRemoteUrl?{ensureRemoteUrl:n.ensureRemoteUrl}:{}},u=s?await a.validateGitWorktree(h,i):await ft(g,i);if(e.signal.aborted)return;u.ok||u.errors.forEach(e=>{if(e.code===`worktree_exists`){l??=e.message;return}e.code.startsWith(`branch_`)&&(c??=e.message)})}e.signal.aborted||J(e=>({...e,isValidating:!1,branchError:c,worktreeError:l}))}catch{e.signal.aborted||J(e=>({...e,isValidating:!1}))}},[s,a,h,g,_,y.branchName,y.linkedPr,x.selectedBranch,Xe.worktreeName,D,k,q.touched,Ie,Pe,i]),rt=_===`new-branch`?y.branchName:x.selectedBranch;X.useEffect(()=>{if(!e||!g||!q.touched||Pe)return;let t=setTimeout(()=>{nt()},300);return()=>clearTimeout(t)},[Xe.worktreeName,rt,e,g,nt,q.touched,Pe]);let it=async()=>{if(!g||!h){K.error(i(`session.newWorktree.error.noActiveProject`));return}J(e=>({...e,touched:!0}));let e=_===`new-branch`?y.branchName:x.selectedBranch,r=Xe.worktreeName,a=Zn(e),c=$(r);if(!a){K.error(i(`session.newWorktree.error.branchNameRequired`));return}if(!c){K.error(i(`session.newWorktree.error.worktreeDirectoryRequired`));return}Ie&&(Ie.abort(),Le(null)),J(e=>({...e,isValidating:!1,branchError:null,worktreeError:null})),Fe(!0);try{let e=_===`new-branch`?y.linkedPr:null,r=_===`new-branch`?y.linkedIssue:null,l=_===`new-branch`?y.linkedPr:null,u=_===`new-branch`&&y.includePrDiff,d=!!(r||l);if(s&&o&&m?.hostId){let l=m;P.getState().setActiveProjectIdOnly(l.id);let f=e?$n(e,D,k):null,p=r?`#${r.number} ${r.title}`.trim():e?`#${e.number} ${e.title}`.trim():void 0,h=await un(l,{mode:f||_===`existing-branch`?`existing`:`new`,worktreeName:c,branchName:_===`new-branch`?a:void 0,existingBranch:f?.existingBranch??(_===`existing-branch`?a:void 0),..._===`new-branch`&&!f&&y.sourceBranch?{startRef:y.sourceBranch}:{},...f?{setUpstream:f.setUpstream,upstreamRemote:f.upstreamRemote,upstreamBranch:f.upstreamBranch,...f.ensureRemoteName?{ensureRemoteName:f.ensureRemoteName}:{},...f.ensureRemoteUrl?{ensureRemoteUrl:f.ensureRemoteUrl}:{}}:{}},{title:p,createSession:d,kind:e?`pr`:`standard`,createdFromBranch:f?.sourceLabel??y.sourceBranch,isSelected:()=>P.getState().activeProjectId===l.id});s.sdk();let g=V.getState().remoteSession;g?.projectId===l.id&&g.location.hubId===s.location.hubId&&g.location.hostId===s.location.hostId&&g.location.directory===h.path&&g.sessionId===(h.id??null)&&n?.(h.path,{...h.id?{sessionId:h.id}:{},remote:!0}),t(!1),K.success(i(`session.newWorktree.toast.worktreeCreated`)),h.id&&d&&Un(o.registry,s,h.path,h.id,{issue:r,pr:e,includeDiff:u},i(`session.newWorktree.error.sendGitHubContextFailed`)).catch(e=>{K.error(i(`session.newWorktree.error.sendGitHubContextFailed`),{description:e instanceof Error?e.message:String(e)})});return}let[f,p]=await Promise.all([je(g),gt(h)]),v=y.sourceBranch,b=``,S=(()=>{if(e){let t=$n(e,D,k);return b=t.sourceLabel,{preferredName:a||c,mode:`existing`,branchName:a,worktreeName:c,existingBranch:t.existingBranch,setupCommands:f,setUpstream:t.setUpstream,upstreamRemote:t.upstreamRemote,upstreamBranch:t.upstreamBranch,returnAfterDirectoryCreated:!0,...t.ensureRemoteName?{ensureRemoteName:t.ensureRemoteName}:{},...t.ensureRemoteUrl?{ensureRemoteUrl:t.ensureRemoteUrl}:{}}}return b=_===`new-branch`?v:``,{preferredName:a||c,mode:_===`existing-branch`?`existing`:`new`,branchName:_===`existing-branch`?void 0:a,worktreeName:c,existingBranch:_===`existing-branch`?a:void 0,setupCommands:f,returnAfterDirectoryCreated:!0,...v&&_===`new-branch`?{startRef:v}:{}}})(),C=await yt(h,S,{resolvedRootTrackingRemote:p}),w=await ht(g,C),T=null;if(d){await ke(g)&&await we(w.worktreeRoot??w.path);let e=r?`#${r.number} ${r.title}`.trim():l?`#${l.number} ${l.title}`.trim():i(`session.newWorktree.newSessionTitle`),a=await fe(e,w.path,null);if(!a?.id)throw Error(`Failed to create session`);T=a.id,n?.(w.path,{sessionId:T}),t(!1),Fe(!1),he(a.id,e).catch(()=>void 0);try{U.getState().initializeNewYuriSession(a.id,de.getState().agents)}catch{}}else t(!1),Fe(!1);let ee=bt({mode:_,sourceBranch:y.sourceBranch,linkedPr:!!y.linkedPr,selectedBranch:x.selectedBranch});ee&&localStorage.setItem(xt,ee),K.success(i(`session.newWorktree.toast.worktreeCreated`),{description:i(`session.newWorktree.toast.worktreeCreatedDescription`,{target:`${w.branch||w.name}${b?` ${i(`session.newWorktree.fromSource`,{source:b})}`:``}`})}),T?Ye({sessionId:T,directory:w.path,issue:r,pr:l,includeDiff:u}).catch(e=>{let t=e instanceof Error?e.message:i(`session.newWorktree.error.sendGitHubContextFailed`);K.error(i(`session.newWorktree.error.sendGitHubContextFailed`),{description:t})}):n?.(w.path)}catch(e){let t=e instanceof Error?e.message:i(`session.newWorktree.error.createWorktreeFailed`);K.error(i(`session.newWorktree.error.createWorktreeFailed`),{description:t})}finally{Fe(!1)}},ct=e=>{v(e),J(e=>({...e,touched:!1,branchError:null,worktreeError:null}))},lt=e=>{if(!e){b(e=>({...e,linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:``}));return}if(e.type===`issue`){let t=e.item,n=`issue-${t.number}-${cn()}`;b(e=>({...e,linkedIssue:t,linkedPr:null,includePrDiff:!1,branchName:n,worktreeName:$(n),isSyncingWorktreeName:!0}))}else if(e.type===`pr`){let t=e.item;b(n=>({...n,linkedPr:t,linkedIssue:null,includePrDiff:e.includeDiff??!1,branchName:t.head,worktreeName:$(t.head),isSyncingWorktreeName:!0}))}},dt=p&&f?.connected===!0,pt=(_===`existing-branch`?!!x.selectedBranch&&!!x.worktreeName&&!q.branchError&&!q.worktreeError:!!Zn(y.branchName)&&!!y.worktreeName&&!q.branchError&&!q.worktreeError)&&!Pe,_t=()=>{b(e=>({...e,linkedIssue:null,linkedPr:null,branchName:``,includePrDiff:!1,isSyncingWorktreeName:!0}))},St=s&&(A.error||l.error)?(0,Q.jsxs)(`div`,{role:`alert`,className:`typography-micro text-destructive`,children:[(A.error||l.error)?.message,(0,Q.jsx)(H,{size:`xs`,variant:`ghost`,onClick:()=>{A.refetch(),l.refetch()},children:i(`remoteProjects.retry`)})]}):null,Ct=(0,Q.jsxs)(`div`,{className:G(`flex gap-2`,u?`flex-col w-full`:`flex-row items-center`),children:[St,(0,Q.jsx)(`div`,{className:G(`flex items-center gap-1.5 text-destructive`,u?`w-full justify-center order-first`:`mr-auto`),children:q.touched&&(q.branchError||q.worktreeError)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{name:`error-warning`,className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:q.branchError||q.worktreeError})]})}),(0,Q.jsxs)(`div`,{className:G(`flex gap-2`,u&&`w-full`),children:[(0,Q.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:Pe,className:G(u&&`flex-1`),children:i(`session.newWorktree.actions.cancel`)}),(0,Q.jsxs)(H,{size:`sm`,onClick:it,disabled:!pt||Pe,className:G(`gap-1.5`,u&&`flex-1`),children:[Pe&&(0,Q.jsx)(Y,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}),i(Pe?`session.newWorktree.actions.creating`:`session.newWorktree.actions.createWorktree`)]})]})]});return(0,Q.jsxs)(Q.Fragment,{children:[u?(0,Q.jsx)(He,{id:`new-worktree-sheet-${d}`,open:e,onOpenChange:t,title:(0,Q.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:i(`session.newWorktree.title`)}),ariaLabel:i(`session.newWorktree.title`),closeAriaLabel:i(`mobile.surface.closeAria`),resizeAriaLabel:i(`mobile.sessions.sheet.resizeAria`),children:(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsxs)(Ve,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:`min-h-0 flex-1`,className:`overscroll-contain px-4 pb-4 pt-2`,children:[(0,Q.jsx)(`div`,{className:`w-full mb-4`,children:(0,Q.jsx)(wt,{items:[{id:`new-branch`,label:i(`session.newWorktree.mode.newBranch`),icon:(0,Q.jsx)(Y,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`existing-branch`,label:i(`session.newWorktree.mode.existingBranch`),icon:(0,Q.jsx)(Y,{name:`git-repository`,className:`h-3.5 w-3.5`})}],activeId:_,onSelect:e=>ct(e),variant:`active-pill`,layoutMode:`fit`,className:`w-full`})}),(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[_===`existing-branch`?(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.selectBranch`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,onClick:()=>oe(!0),className:`flex-1 justify-between h-9`,children:[(0,Q.jsx)(`span`,{className:x.selectedBranch?`text-foreground`:`text-muted-foreground`,children:x.selectedBranch||i(`session.newWorktree.chooseBranch`)}),(0,Q.jsx)(Y,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`})]}),(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,className:`h-8 w-8 px-0 shrink-0`,onClick:Ne,disabled:!Me||T,title:i(`session.newWorktree.fetchBranches`),children:T?(0,Q.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(Y,{name:`refresh`,className:`size-4`})})]}),(0,Q.jsx)(ut,{open:ae,title:i(`session.newWorktree.selectBranch`),onClose:()=>oe(!1),children:(0,Q.jsxs)(`div`,{className:`space-y-4`,ref:ge,children:[(0,Q.jsx)(st,{value:B,onChange:e=>ce(e.target.value),placeholder:i(`session.newWorktree.searchBranches`),className:`h-8`}),T?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):D.length===0&&k.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[Te&&De&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(`session.newWorktree.matchingBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ce.matching.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:e.value,worktreeName:$(e.label)})),J(e=>({...e,touched:!0})),oe(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,x.selectedBranch===e.value?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))})]}),Te&&!De&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),Ce.otherLocal.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Te?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ce.otherLocal.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:e,worktreeName:$(e)})),J(e=>({...e,touched:!0})),oe(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,x.selectedBranch===e?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},e))})]}),Ce.otherRemote.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Te?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ce.otherRemote.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:`remotes/${e}`,worktreeName:$(e)})),J(e=>({...e,touched:!0})),oe(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,x.selectedBranch===`remotes/${e}`?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remotes/${e}`))})]})]})]})})]}):(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col items-start gap-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.branchName`)}),_===`new-branch`&&dt&&(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,onClick:()=>I(!0),className:`gap-1.5 h-7`,children:[(0,Q.jsx)(Y,{name:`github`,className:`size-4 text-status-success`}),y.linkedIssue||y.linkedPr?i(`session.newWorktree.actions.change`):i(`session.newWorktree.actions.startFromGitHubIssuePr`)]})]}),(0,Q.jsx)(st,{value:y.branchName,onChange:e=>{b(t=>({...t,branchName:e.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.branchNamePlaceholder`),disabled:!!y.linkedPr,className:G(`h-8`,q.touched&&q.branchError&&`border-destructive`,y.linkedPr&&`bg-muted text-muted-foreground`)}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.usingPrBranch`,{branch:y.linkedPr.head})})]}),y.linkedIssue&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.fromIssue`,{number:y.linkedIssue.number,title:y.linkedIssue.title})})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground font-semibold`,children:i(`session.newWorktree.worktreeDirectory`)}),_!==`existing-branch`&&(0,Q.jsxs)(`button`,{onClick:()=>{let e=$(_===`new-branch`?y.branchName:``);b(t=>({...t,worktreeName:e,isSyncingWorktreeName:!0}))},disabled:!y.branchName||y.worktreeName===$(y.branchName),className:G(`flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded`,y.worktreeName===$(y.branchName)||!y.branchName?`text-muted-foreground/40 cursor-not-allowed`:`text-muted-foreground hover:text-foreground hover:bg-muted`),title:i(`session.newWorktree.resetToMatchBranchName`),children:[(0,Q.jsx)(Y,{name:`refresh`,className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:i(`session.newWorktree.actions.reset`)})]})]}),(0,Q.jsx)(st,{value:Xe.worktreeName,onChange:e=>{_===`new-branch`?b(t=>({...t,worktreeName:e.target.value,isSyncingWorktreeName:!1})):S(t=>({...t,worktreeName:e.target.value}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.worktreeDirectoryPlaceholder`),className:G(`h-8`,q.touched&&q.worktreeError&&`border-destructive`)})]}),_===`new-branch`&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.sourceBranch`)}),(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,onClick:()=>se(!0),className:`w-full justify-between h-9`,children:[(0,Q.jsx)(`span`,{className:y.sourceBranch?`text-foreground`:`text-muted-foreground`,children:y.sourceBranch||i(`session.newWorktree.selectSourceBranchPlaceholder`)}),(0,Q.jsx)(Y,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`})]}),y.sourceBranch&&(0,Q.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i(`session.newWorktree.newBranchFromSource`,{source:y.sourceBranch})}),(0,Q.jsx)(ut,{open:z,title:i(`session.newWorktree.selectSourceBranch`),onClose:()=>se(!1),children:(0,Q.jsxs)(`div`,{className:`space-y-4`,ref:_e,children:[(0,Q.jsx)(st,{value:le,onChange:e=>ue(e.target.value),placeholder:i(`session.newWorktree.searchBranches`),className:`h-8`}),T?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):D.length===0&&k.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[Ee&&Oe&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(`session.newWorktree.matchingBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:W.matching.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:e.value})),se(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,y.sourceBranch===e.value?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))})]}),Ee&&!Oe&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),W.otherLocal.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Ee?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:W.otherLocal.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:e})),se(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,y.sourceBranch===e?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},e))})]}),W.otherRemote.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Ee?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:W.otherRemote.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:`remotes/${e}`})),se(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,y.sourceBranch===`remotes/${e}`?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remotes/${e}`))})]})]})]})})]}),(y.linkedIssue||y.linkedPr)&&_===`new-branch`&&(0,Q.jsxs)(`div`,{className:`mt-2 px-2 py-1.5 rounded bg-muted/30`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Y,{name:`github`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),y.linkedIssue&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.issueNumber`,{number:y.linkedIssue.number})}),y.linkedPr&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.prNumber`,{number:y.linkedPr.number})}),(0,Q.jsx)(`span`,{className:`typography-micro text-foreground truncate flex-1`,children:y.linkedIssue?.title||y.linkedPr?.title}),(0,Q.jsx)(`a`,{href:y.linkedIssue?.url||y.linkedPr?.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground hover:text-foreground shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(Y,{name:`external-link`,className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{onClick:_t,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 pl-5`,children:[(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[y.linkedPr.head,` → `,y.linkedPr.base]}),y.includePrDiff&&(0,Q.jsx)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success`,children:i(`session.newWorktree.includeDiffBadge`)})]})]})]})]}),(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-3 pt-2`,children:Ct})]})}):(0,Q.jsx)(qe,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Ge,{className:`max-w-lg max-h-[80vh] flex flex-col`,children:[(0,Q.jsx)(Ue,{className:`flex flex-row items-center justify-between`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(Ke,{className:`flex items-center gap-2 shrink-0`,children:[(0,Q.jsx)(Y,{name:`git-branch`,className:`h-5 w-5`}),i(`session.newWorktree.title`)]}),(0,Q.jsx)(`div`,{className:`w-[280px] shrink-0`,children:(0,Q.jsx)(wt,{items:[{id:`new-branch`,label:i(`session.newWorktree.mode.newBranch`),icon:(0,Q.jsx)(Y,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`existing-branch`,label:i(`session.newWorktree.mode.existingBranch`),icon:(0,Q.jsx)(Y,{name:`git-repository`,className:`h-3.5 w-3.5`})}],activeId:_,onSelect:e=>ct(e),variant:`active-pill`,layoutMode:`fit`,className:`w-full`})})]})}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto mt-2 space-y-6`,children:[_===`existing-branch`?(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.selectBranch`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)($e,{open:L,onOpenChange:R,children:[(0,Q.jsx)(Ze,{asChild:!0,children:(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,className:`h-9 min-w-[220px] max-w-full justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:G(`truncate`,x.selectedBranch?`text-foreground`:`text-muted-foreground`),children:x.selectedBranch||i(`session.newWorktree.chooseBranch`)}),(0,Q.jsx)(Y,{name:`arrow-down-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,Q.jsx)(Qe,{align:`start`,sideOffset:6,portalToBody:!0,className:`w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden`,ref:pe,children:(0,Q.jsxs)(Tn,{shouldFilter:!1,children:[(0,Q.jsx)(En,{placeholder:i(`session.newWorktree.searchBranches`),value:B,onValueChange:ce,onKeyDown:ve}),(0,Q.jsx)(Dn,{disableHorizontal:!0,children:T?(0,Q.jsx)(`div`,{className:`px-2 py-4 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):D.length===0&&k.length===0?(0,Q.jsx)(On,{children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(Q.Fragment,{children:[Te&&De&&(0,Q.jsx)(kn,{heading:i(`session.newWorktree.matchingBranches`),children:Ce.matching.map(e=>(0,Q.jsx)(jn,{value:e.value,onSelect:()=>{S(t=>({...t,selectedBranch:e.value,worktreeName:$(e.label)})),J(e=>({...e,touched:!0})),R(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))}),Te&&!De&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),Ce.otherLocal.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[Te&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Te?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`),children:Ce.otherLocal.map(e=>(0,Q.jsx)(jn,{value:e,onSelect:()=>{S(t=>({...t,selectedBranch:e,worktreeName:$(e)})),J(e=>({...e,touched:!0})),R(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`local-${e}`))})]}),Ce.otherRemote.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(Ce.otherLocal.length>0||Te)&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Te?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`),children:Ce.otherRemote.map(e=>(0,Q.jsx)(jn,{value:`remotes/${e}`,onSelect:()=>{S(t=>({...t,selectedBranch:`remotes/${e}`,worktreeName:$(e)})),J(e=>({...e,touched:!0})),R(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remote-${e}`))})]})]})})]})})]}),(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,className:`h-8 w-8 px-0 shrink-0`,onClick:Ne,disabled:!Me||T,title:i(`session.newWorktree.fetchBranches`),children:T?(0,Q.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(Y,{name:`refresh`,className:`size-4`})})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.branchName`)}),_===`new-branch`&&dt&&(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,onClick:()=>I(!0),className:`gap-1.5 h-7`,children:[(0,Q.jsx)(Y,{name:`github`,className:`size-4 text-status-success`}),y.linkedIssue||y.linkedPr?i(`session.newWorktree.actions.change`):i(`session.newWorktree.actions.startFromGitHubIssuePr`)]})]}),(0,Q.jsx)(st,{value:y.branchName,onChange:e=>{b(t=>({...t,branchName:e.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.branchNamePlaceholder`),disabled:!!y.linkedPr,className:G(`h-8`,q.touched&&q.branchError&&`border-destructive`,y.linkedPr&&`bg-muted text-muted-foreground`)}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.usingPrBranch`,{branch:y.linkedPr.head})})]}),y.linkedIssue&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.fromIssue`,{number:y.linkedIssue.number,title:y.linkedIssue.title})})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground font-semibold`,children:i(`session.newWorktree.worktreeDirectory`)}),_!==`existing-branch`&&(0,Q.jsxs)(`button`,{onClick:()=>{let e=$(_===`new-branch`?y.branchName:``);b(t=>({...t,worktreeName:e,isSyncingWorktreeName:!0}))},disabled:!y.branchName||y.worktreeName===$(y.branchName),className:G(`flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded`,y.worktreeName===$(y.branchName)||!y.branchName?`text-muted-foreground/40 cursor-not-allowed`:`text-muted-foreground hover:text-foreground hover:bg-muted`),title:i(`session.newWorktree.resetToMatchBranchName`),children:[(0,Q.jsx)(Y,{name:`refresh`,className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:i(`session.newWorktree.actions.reset`)})]})]}),(0,Q.jsx)(st,{value:Xe.worktreeName,onChange:e=>{_===`new-branch`?b(t=>({...t,worktreeName:e.target.value,isSyncingWorktreeName:!1})):S(t=>({...t,worktreeName:e.target.value}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.worktreeDirectoryPlaceholder`),className:G(`h-8`,q.touched&&q.worktreeError&&`border-destructive`)})]}),_===`new-branch`&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.sourceBranch`)}),(0,Q.jsxs)($e,{open:re,onOpenChange:ie,children:[(0,Q.jsx)(Ze,{asChild:!0,children:(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,className:`h-9 min-w-[220px] max-w-full justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:G(`truncate`,y.sourceBranch?`text-foreground`:`text-muted-foreground`),children:y.sourceBranch||i(`session.newWorktree.selectSourceBranchPlaceholder`)}),(0,Q.jsx)(Y,{name:`arrow-down-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,Q.jsx)(Qe,{align:`start`,portalToBody:!0,className:`w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden`,ref:me,children:(0,Q.jsxs)(Tn,{shouldFilter:!1,children:[(0,Q.jsx)(En,{placeholder:i(`session.newWorktree.searchBranches`),value:le,onValueChange:ue,onKeyDown:ve}),(0,Q.jsx)(Dn,{disableHorizontal:!0,children:T?(0,Q.jsx)(`div`,{className:`px-2 py-4 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):D.length===0&&k.length===0?(0,Q.jsx)(On,{children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(Q.Fragment,{children:[Ee&&Oe&&(0,Q.jsx)(kn,{heading:i(`session.newWorktree.matchingBranches`),children:W.matching.map(e=>(0,Q.jsx)(jn,{value:e.value,onSelect:()=>{b(t=>({...t,sourceBranch:e.value})),ie(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))}),Ee&&!Oe&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),W.otherLocal.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[Ee&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Ee?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`),children:W.otherLocal.map(e=>(0,Q.jsx)(jn,{value:e,onSelect:()=>{b(t=>({...t,sourceBranch:e})),ie(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`local-${e}`))})]}),W.otherRemote.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(W.otherLocal.length>0||Ee)&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Ee?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`),children:W.otherRemote.map(e=>(0,Q.jsx)(jn,{value:`remotes/${e}`,onSelect:()=>{b(t=>({...t,sourceBranch:`remotes/${e}`})),ie(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remote-${e}`))})]})]})})]})})]}),y.sourceBranch&&(0,Q.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i(`session.newWorktree.newBranchFromSource`,{source:y.sourceBranch})})]}),(y.linkedIssue||y.linkedPr)&&_===`new-branch`&&(0,Q.jsxs)(`div`,{className:`mt-2 px-2 py-1.5 rounded bg-muted/30`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Y,{name:`github`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),y.linkedIssue&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.issueNumber`,{number:y.linkedIssue.number})}),y.linkedPr&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.prNumber`,{number:y.linkedPr.number})}),(0,Q.jsx)(`span`,{className:`typography-micro text-foreground truncate flex-1`,children:y.linkedIssue?.title||y.linkedPr?.title}),(0,Q.jsx)(`a`,{href:y.linkedIssue?.url||y.linkedPr?.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground hover:text-foreground shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(Y,{name:`external-link`,className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{onClick:_t,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 pl-5`,children:[(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[y.linkedPr.head,` → `,y.linkedPr.base]}),y.includePrDiff&&(0,Q.jsx)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success`,children:i(`session.newWorktree.includeDiffBadge`)})]})]})]}),(0,Q.jsxs)(We,{className:`mt-1 flex items-center justify-between`,children:[St,(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5 text-destructive`,children:q.touched&&(q.branchError||q.worktreeError)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{name:`error-warning`,className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:q.branchError||q.worktreeError})]})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:Pe,children:i(`session.newWorktree.actions.cancel`)}),(0,Q.jsxs)(H,{size:`sm`,onClick:it,disabled:!pt||Pe,className:`gap-1.5`,children:[Pe&&(0,Q.jsx)(Y,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}),i(Pe?`session.newWorktree.actions.creating`:`session.newWorktree.actions.createWorktree`)]})]})]})]})}),(0,Q.jsx)(Yn,{projectId:m?.id,open:F,onOpenChange:I,onSelect:lt})]})}var ir=null,ar=new Set,or=()=>{for(let e of ar)e()},sr=e=>e===`chat`||e===`assistant`,cr=()=>ir,lr=e=>{ir!==e&&(ir=e,or())},ur=e=>{ir&&(e&&ir.surfaceID!==e||(ir=null,or()))},dr=(e,t)=>{if(e.transportIdentity!==t.transportIdentity||e.runtimeGeneration!==t.runtimeGeneration)throw Error(`chat-input-delivery-runtime-stale`)},fr=e=>{let t=e.options?.delivery===`steer`?`steer`:e.options?.delivery===`queue`?`queue`:void 0,n={...t?{delivery:t}:{},...e.options?.commitStagedMessageEdit===void 0?{}:{commitStagedMessageEdit:e.options.commitStagedMessageEdit},...e.options?.messageID?{messageID:e.options.messageID}:{},...e.options?.ticket?{ticket:e.options.ticket}:{}},r=e.options?.sessionId??e.sessionID??void 0;if(!r)return n;let i=e.options?.directoryHint===void 0?e.directory||null:e.options.directoryHint;return{...n,sessionId:r,directoryHint:i}},pr=(e,t,n={})=>({operation:t,surfaceID:e.surfaceID,transportIdentity:e.transportIdentity,runtimeGeneration:e.runtimeGeneration,sessionID:e.sessionID,directory:e.directory??``,draftKey:e.draftKey,deliveryTarget:e.deliveryTarget,...n}),mr=e=>{if(!e.active||!e.draftKey||!e.directory)return null;let t=e.activity?.phase??`idle`,n=e.activity?.canAbort??(t===`busy`||t===`retry`);return{send:async t=>{let n=pr(e,`send`,t);return await e.selection.flush(),e.kind===`secondary`&&await e.shortcuts.submit(),e.backend.send(n)},sendQueued:async(t,n={})=>{let{manual:r,...i}=n,a=pr(e,`send`,i),o=Qt(e);if(await e.selection.flush(),!o)throw Error(`chat-input-queue-scope-incomplete`);return e.backend.sendQueued({...a,queueItemID:t,manual:r,queueScope:o})},create:async()=>{let t=pr(e,`create`);return await e.selection.flush(),e.backend.create(t)},compact:async t=>{let n=pr(e,`compact`,t);return await e.selection.flush(),e.backend.compact(n)},abort:async()=>{let t=pr(e,`abort`);return await e.selection.flush(),e.backend.abort(t)},queueScope:Qt(e),canAbort:n,canQueue:t===`busy`||t===`retry`,allowsCommand:t=>Gt(e,{name:t,source:`yuri`}),shortcut:async(t,n=1)=>{if(e.kind===`secondary`){t===`cycle`?await e.shortcuts.cycle(n):t===`new`?await e.shortcuts.new():t===`abort`?await e.shortcuts.abort():await e.shortcuts.submit();return}if(t===`abort`){let t=pr(e,`abort`);await e.selection.flush(),await e.backend.abort(t);return}if(t===`new`){let t=pr(e,`create`);await e.selection.flush(),await e.backend.create(t);return}t!==`submit`&&await e.shortcuts?.cycle(n)},resources:e.resources??null}},hr=e=>e.type===`tool`&&e.metadata?.providerExecuted===!0,gr=e=>{if(e.type!==`tool`)return!1;let t=e.state;return t?.status===`error`&&t.metadata?.interrupted===!0},_r=e=>e.type!==`tool`||hr(e)?!1:!gr(e),vr=e=>{let t=0;for(let n of e)_r(n)&&(t+=1);return t},yr=(e,t)=>e===`stop`&&vr(t)===0,br=e=>{if(e.type!==`text`||e.synthetic===!0)return!1;let t=e.text;return typeof t==`string`&&Tt(t)},xr=e=>{if(vr(e)!==0)return-1;for(let t=e.length-1;t>=0;--t){let n=e[t];if(br(n))return t;if(n.type===`tool`||n.type===`reasoning`||n.type===`file`||n.type===`agent`||n.type===`subtask`)break}return-1},Sr=(e,t,n)=>{if(n||!yr(e,t))return!1;for(let e of t)if(br(e))return!0;return!1},Cr=e=>e===`streaming`||e===`cooldown`,wr=e=>e.parts.some(br),Tr=e=>Cr(e.streamPhase)?wr(e):!1,Er=e=>{let t=e;return typeof t.text==`string`?t.text:typeof t.content==`string`?t.content:``},Dr=e=>{let t=e?.type;return t===`compaction`?!g(e):t===`text`&&Er(e).trim()===`/compact`},Or=e=>e?e.some(e=>Dr(e)):!1,kr=e=>Or(e.parts),Ar=e=>e?Or(e.sourceParts)||Or(e.parts):!1,jr=e=>{if(!kr(e))return e;let t=!1,n=e.parts.map(e=>e?.type!==`compaction`||g(e)?e:(t=!0,{type:`text`,text:`/compact`})),r=e.info.clientRole!==`user`;return!t&&!r?e:{...e,info:r?{...e.info,clientRole:`user`}:e.info,parts:t?n:e.parts}},Mr=e=>{let t=Et(e.parts);return t.length===e.parts.length?e:{...e,parts:t}},Nr=new WeakMap,Pr=e=>{let t=Nr.get(e);if(t)return t;let n=jr(Mr(e)),r=n.parts,i=Ce(r),a=i===r?n:{...n,parts:i,sourceParts:r};return Nr.set(e,a),a},Fr={activity:`idle`,hasWorkingContext:!1,hasActiveTools:!1,isWorking:!1,isStreaming:!1,isCooldown:!1,lifecyclePhase:null,statusText:null,isGenericStatus:!0,isWaitingForPermission:!1,canAbort:!1,compactionDeadline:null,activePartType:void 0,activeToolName:void 0,wasAborted:!1,abortActive:!1,lastCompletionId:null,isComplete:!1,isTurnSettled:!1,retryInfo:null,turnStartedAt:void 0},Ir=[],Lr=`\0`,Rr=new Set([`edit`,`write`,`apply_patch`]),zr={read:`chat.assistantStatus.readingFile`,write:`chat.assistantStatus.writingFile`,edit:`chat.assistantStatus.editingFile`,apply_patch:`chat.assistantStatus.applyingPatch`,bash:`chat.assistantStatus.runningCommand`,grep:`chat.assistantStatus.searchingContent`,glob:`chat.assistantStatus.findingFiles`,list:`chat.assistantStatus.listingDirectory`,task:`chat.assistantStatus.delegatingTask`,webfetch:`chat.assistantStatus.fetchingUrl`,websearch:`chat.assistantStatus.searchingWeb`,codesearch:`chat.assistantStatus.webCodeSearch`,todowrite:`chat.assistantStatus.updatingTodos`,todoread:`chat.assistantStatus.readingTodos`,skill:`chat.assistantStatus.learningSkill`,question:`chat.assistantStatus.askingQuestion`,execute:`chat.assistantStatus.executing`,session_rename:`chat.assistantStatus.renamingSession`,session_move:`chat.assistantStatus.movingSession`,browser:`chat.assistantStatus.usingBrowser`},Br=[`chat.assistantStatus.working`,`chat.assistantStatus.processing`,`chat.assistantStatus.preparing`,`chat.assistantStatus.warmingUp`,`chat.assistantStatus.gearsTurning`,`chat.assistantStatus.computing`,`chat.assistantStatus.calculating`,`chat.assistantStatus.analyzing`,`chat.assistantStatus.wheelsSpinning`,`chat.assistantStatus.calibrating`,`chat.assistantStatus.synthesizing`,`chat.assistantStatus.connectingDots`,`chat.assistantStatus.inspectingLogic`,`chat.assistantStatus.weighingOptions`],Vr=(e,t)=>{let n=zr[Be(e)];return n?t(n):t(`chat.assistantStatus.usingTool`,{tool:e})},Hr=e=>{let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)},Ur=(e,t)=>t(Br[Hr(e)%Br.length]??`chat.assistantStatus.working`),Wr=(e,t,n)=>{let r,i;if(!N(e))for(let t=e.length-1;t>=0;--t){let n=e[t];if(n)switch(n.type){case`reasoning`:{let e=n.time??Xr(n);(!e||e.end===void 0)&&!r&&(r=`reasoning`);break}case`tool`:{let e=n.state?.status;if((e===`running`||e===`pending`)&&!r){let e=Be(Zr(n));Rr.has(e)?(r=`editing`,i=e):(r=`tool`,i=e)}break}case`text`:{let e=Yr(n)??``;if(typeof e==`string`&&e.trim().length>0){let e=Xr(n);(!e||e.end===void 0)&&!r&&(r=`text`)}break}}}let a=r===void 0,o=r===`editing`?n(`chat.assistantStatus.editingFile`):r===`tool`&&i?Vr(i,n):r===`reasoning`?n(`chat.assistantStatus.thinking`):r===`text`?n(`chat.assistantStatus.composing`):Ur(t,n);return{activePartType:r,activeToolName:i,statusText:o,isGenericStatus:a}},Gr=e=>[e.activePartType??``,e.activeToolName??``,e.statusText,e.isGenericStatus?`1`:`0`].join(Lr),Kr=e=>{let[t,n,r=`working`,i]=e.split(Lr);return{activePartType:t===`text`||t===`tool`||t===`reasoning`||t===`editing`?t:void 0,activeToolName:n||void 0,statusText:r,isGenericStatus:i===`1`}},qr=e=>e.type===`reasoning`,Jr=e=>e.type===`text`,Yr=e=>{if(Jr(e))return e.text;let t=e;if(typeof t.text==`string`)return t.text;if(typeof t.content==`string`)return t.content;if(typeof t.value==`string`)return t.value},Xr=e=>(Jr(e)||qr(e),e.time),Zr=e=>{if(e.tool)return e.tool;let t=e;return typeof t.name==`string`?t.name:`tool`};function Qr(e,t){let{t:n}=ze(),r=U(e=>e.currentSessionId),i=U(e=>e.currentSessionDirectory),a=e??r,o=t??i,s=ue(e=>!!(a&&e.session_execution_recovery[a]),o??void 0),c=X.useMemo(()=>e=>a?e.pendingSendMessageIDs.get(a)??null:null,[a]),l=U(c),u=Ne(a??``,o??void 0),d=X.useMemo(()=>{for(let e=u.length-1;e>=0;e--){let t=u[e];if(t.role===`assistant`)return{id:t.id,index:e,finish:t.finish,error:t.error,isCompaction:t.clientRole===`compaction`,startedAt:Number.isFinite(t.time.created)?t.time.created:void 0}}return{id:null,index:-1,finish:void 0,error:void 0,isCompaction:!1,startedAt:void 0}},[u]),f=d.id,p=X.useMemo(()=>{for(let e=u.length-1;e>=0;e--){let t=u[e];if(t.role===`user`&&!b(t))return{id:t.id,index:e,turnStartedAt:Number.isFinite(t.time.created)?t.time.created:void 0}}return{id:null,index:-1,turnStartedAt:void 0}},[u]),m=p.id,h=ge(f??``,o??void 0,a??void 0),g=ge(m??``,o??void 0,a??void 0),_=!!m&&Or(g),v=d.isCompaction&&d.index>p.index?h.find(e=>e.type===`compaction`):void 0,y=v?.reason===`manual`?d.startedAt:p.turnStartedAt,x=!!(f&&d.index>p.index&&(v?v.status===`failed`||v.reason===`manual`&&v.status===`completed`:Sr(d.finish,h,d.error))),S=X.useMemo(()=>{let e=`${a??``}:${f??``}`;return Gr(Wr(f&&!d.error&&d.index>p.index?h:Ir,e,n))},[a,f,d.error,d.index,p.index,h,n]),C=Oe(a??``,o??void 0),w=Te(a??``,o??void 0),T=X.useMemo(()=>e=>a?e.sessionAbortFlags?.get(a)??null:null,[a]),ee=U(T),{phase:E,isWorking:D}=nn(a,o??void 0),O=!!(d.error&&d.index>p.index),k=be(a??``,o??void 0),te=k?.type===`retry`?k.attempt:void 0,A=k?.type===`retry`?k.next:void 0,j=X.useMemo(()=>Kr(S),[S]),M=X.useMemo(()=>{let e=!!(ee&&!ee.acknowledged);return{wasAborted:e,abortActive:e}},[ee]),N=X.useMemo(()=>{if(s)return{...Fr,isRecovering:!0,canAbort:D};if(O&&E!==`retry`)return{...Fr,isTurnSettled:!0,canAbort:D};if(M.wasAborted)return{...Fr,wasAborted:!0,abortActive:M.abortActive,activity:`idle`,hasWorkingContext:!1,isWorking:!1,isStreaming:!1,isCooldown:!1,statusText:null,canAbort:!1,retryInfo:null};if(x)return{...Fr,isComplete:v?.status!==`failed`,isTurnSettled:!0,turnStartedAt:y};let e=D,t=E===`busy`,r=E===`retry`,i=e&&(_||v?.status===`running`),a=`idle`;e&&(a=!i&&(j.activePartType===`tool`||j.activePartType===`editing`)?`tooling`:`streaming`);let o=r?{attempt:te,next:A,message:k?.type===`retry`?k.message:void 0}:null;return{activity:a,hasWorkingContext:e,hasActiveTools:!i&&(j.activePartType===`tool`||j.activePartType===`editing`),isWorking:e,isStreaming:t,isCooldown:!1,lifecyclePhase:t?`streaming`:null,statusText:e?i?n(`chat.assistantStatus.compacting`):j.statusText:null,isGenericStatus:!e||!i&&j.isGenericStatus,isWaitingForPermission:!1,canAbort:e,compactionDeadline:null,activePartType:e&&!i?j.activePartType:void 0,activeToolName:e&&!i?j.activeToolName:void 0,wasAborted:!1,abortActive:!1,lastCompletionId:null,isComplete:!1,isTurnSettled:!1,retryInfo:o,turnStartedAt:y}},[s,O,E,D,x,_,v?.status,y,j,M,te,A,k,n]);return{forming:X.useMemo(()=>({isActive:!s&&!O&&D&&j.activePartType===`text`,characterCount:0}),[s,O,D,j.activePartType]),working:X.useMemo(()=>{if(s||N.wasAborted||N.abortActive)return N;if(l)return{...N,activity:`streaming`,hasWorkingContext:!0,isWorking:!0,isStreaming:!0,isCooldown:!1,lifecyclePhase:`streaming`,statusText:n(`chat.assistantStatus.sendingMessage`),isGenericStatus:!1,isWaitingForPermission:!1,canAbort:!0,activePartType:void 0,activeToolName:void 0,isComplete:!1,isTurnSettled:!1,retryInfo:null};let e=C.length>0,t=w.length>0;return!e&&!t?N:t?{...N,statusText:null,isWorking:!1,hasWorkingContext:!1,hasActiveTools:!1,canAbort:!1,activePartType:void 0,activeToolName:void 0,retryInfo:null}:{...N,statusText:n(`chat.assistantStatus.waitingForPermission`),isWaitingForPermission:!0,canAbort:!1,retryInfo:null}},[s,N,l,C,w,n])}}var $r=`--yuri-mobile-header-collapse`,ei=e=>e.closest(`.mobile-chat-screen`)?.querySelector(`:scope > [data-yuri-collapsible-header="true"]`)??null,ti=e=>{e.style.removeProperty($r),delete e.dataset.yuriHeaderCollapsePhase,delete e.dataset.yuriHeaderCollapseRest},ni=(e,t,n)=>{let r=String(t.progress),i=t.phase,a=t.rest===`compact`?`collapsed`:`expanded`;return n?.phase!==i&&(e.dataset.yuriHeaderCollapsePhase=i,i===`snapping`&&n&&n.phase!==`snapping`&&e.offsetWidth),n?.progress!==r&&e.style.setProperty($r,r),n?.rest!==a&&(e.dataset.yuriHeaderCollapseRest=a),{progress:r,phase:i,rest:a}},ri=e=>{let t=e.startsWith(`#`)?e.slice(1):e;if(!t)return null;let n=t.match(/^turn-(.+)$/);if(n?.[1])return{kind:`turn`,id:n[1]};let r=t.match(/^message-(.+)$/);return r?.[1]?{kind:`message`,id:r[1]}:null},ii=(e,t,n)=>{if(n===0||e.length===0)return{kind:`noop`};let r=t?e.indexOf(t):e.length-1,i=(r>=0?r:e.length-1)+n;if(i>=e.length)return{kind:`resume`};let a=e[Math.max(0,i)];return a?{kind:`turn`,turnId:a}:{kind:`noop`}},ai=e=>{if(typeof window>`u`)return;let t=e?`#${e}`:``,n=`${window.location.pathname}${window.location.search}${t}`;window.history.replaceState(window.history.state,``,n),e&&window.dispatchEvent(new HashChangeEvent(`hashchange`))},oi=e=>{e&&ai(`message-${e}`)},si=e=>{let t=(0,Z.c)(29),{sessionId:n,turnIds:r,activeTurnId:i,scrollToTurn:a,scrollToMessage:o,resumeToBottom:s}=e,c=X.useRef(r),l=X.useRef(i),u,d;t[0]===r?(u=t[1],d=t[2]):(u=()=>{c.current=r},d=[r],t[0]=r,t[1]=u,t[2]=d),X.useEffect(u,d);let f,p;t[3]===i?(f=t[4],p=t[5]):(f=()=>{l.current=i},p=[i],t[3]=i,t[4]=f,t[5]=p),X.useEffect(f,p);let m;t[6]===a?m=t[7]:(m=async(e,t)=>e?(t?.updateHash!==!1&&ai(`turn-${e}`),a(e,{behavior:t?.behavior})):!1,t[6]=a,t[7]=m);let h=m,g;t[8]===o?g=t[9]:(g=async(e,t)=>e?(t?.updateHash!==!1&&ai(`message-${e}`),o(e,{behavior:t?.behavior})):!1,t[8]=o,t[9]=g);let _=g,v;t[10]!==s||t[11]!==h?(v=async(e,t)=>{let n=c.current,r=ii(n,l.current,e);if(r.kind===`noop`)return e===0;if(r.kind===`resume`){if(t?.resumePastEnd===!1){let e=n[n.length-1];return e?h(e,{behavior:`auto`}):!1}return ai(null),s(),!0}return h(r.turnId,{behavior:`auto`})},t[10]=s,t[11]=h,t[12]=v):v=t[12];let y=v,b;t[13]===s?b=t[14]:(b=()=>{ai(null),s()},t[13]=s,t[14]=b);let x=b,S;t[15]!==_||t[16]!==h||t[17]!==n?(S=()=>{if(!n||typeof window>`u`)return;let e=()=>{let e=ri(window.location.hash);if(e){if(e.kind===`turn`){h(e.id,{behavior:`auto`,updateHash:!1});return}_(e.id,{behavior:`auto`,updateHash:!1})}};return e(),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`hashchange`,e)}},t[15]=_,t[16]=h,t[17]=n,t[18]=S):S=t[18];let C;t[19]!==_||t[20]!==h||t[21]!==n||t[22]!==r.length?(C=[n,_,h,r.length],t[19]=_,t[20]=h,t[21]=n,t[22]=r.length,t[23]=C):C=t[23],X.useEffect(S,C);let w;return t[24]!==x||t[25]!==y||t[26]!==_||t[27]!==h?(w={scrollToTurnId:h,scrollToMessageId:_,scrollByTurnOffset:y,resumeToLatest:x},t[24]=x,t[25]=y,t[26]=_,t[27]=h,t[28]=w):w=t[28],w},ci=[0,200,400],li=e=>{let t=(0,Z.c)(5),{className:n}=e,r;t[0]===n?r=t[1]:(r=G(`inline-flex`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=ci.map(ui),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,Q.jsxs)(Q.Fragment,{children:[`\xA0`,(0,Q.jsx)(`span`,{className:r,"aria-hidden":`true`,children:i})]}),t[3]=r,t[4]=a),a};function ui(e){return(0,Q.jsx)(`span`,{className:`animate-busy-pulse`,style:{animationDelay:`${e}ms`},children:`.`},e)}export{En as A,Xt as B,sr as C,Tn as D,Ln as E,wn as F,Ut as G,Vt as H,cn as I,qt as J,Yt as K,rn as L,Dn as M,Cn as N,On as O,Sn as P,Ot as Q,an as R,cr as S,nr as T,$t as U,Gt as V,Zt as W,Bt as X,Jt as Y,Dt as Z,Tr as _,ti as a,fr as b,Qr as c,wr as d,vr as f,br as g,yr as h,$r as i,jn as j,kn as k,Pr as l,Sr as m,oi as n,ni as o,xr as p,Ht as q,si as r,ei as s,li as t,Ar as u,dr as v,lr as w,ur as x,mr as y,nn as z};
|