pisper 0.6.43 → 0.6.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/package.json +6 -6
  2. package/web/.vite/manifest.json +690 -690
  3. package/web/assets/{AppDialog-Cv4YvRrF.js → AppDialog-BmhtqPq6.js} +1 -1
  4. package/web/assets/{AppOverlays-Du54VkDZ.js → AppOverlays-cyz0mMc9.js} +1 -1
  5. package/web/assets/{AssetsPage-TiFEC32s.js → AssetsPage-a_DNQXQF.js} +1 -1
  6. package/web/assets/{AttachmentTray-BI4I9xoX.js → AttachmentTray-Fx0RVdj2.js} +1 -1
  7. package/web/assets/{BoardPage-BBa6v_6k.js → BoardPage-CQF_701M.js} +3 -3
  8. package/web/assets/{ChannelsPage-BsQCgczL.js → ChannelsPage-C4sSuXef.js} +1 -1
  9. package/web/assets/{ChatAppearancePage-By82YAjZ.js → ChatAppearancePage-BA77E4RG.js} +1 -1
  10. package/web/assets/{ChatHistoryPage-a6EHRkRQ.js → ChatHistoryPage-Bo932avi.js} +1 -1
  11. package/web/assets/{ChatMessage-CrCe2TLj.js → ChatMessage-DyRMVDmJ.js} +3 -3
  12. package/web/assets/{ChatPage-BixfWP4y.js → ChatPage-Bh2srQ5Q.js} +3 -3
  13. package/web/assets/{ConfigPage-CcwhlyGO.js → ConfigPage-CRMPpPxz.js} +3 -3
  14. package/web/assets/{DesktopWindowControls-D3YeNjmV.js → DesktopWindowControls-QTt7BkHB.js} +1 -1
  15. package/web/assets/{FeaturePage-DyRo_I02.js → FeaturePage-DEjUrI25.js} +1 -1
  16. package/web/assets/{FileAttachmentPreview-LLowX6R-.js → FileAttachmentPreview-CU3DVCec.js} +1 -1
  17. package/web/assets/{FloatingWidgets-CgXdrX0y.js → FloatingWidgets-DsEUT3hG.js} +1 -1
  18. package/web/assets/{FocusRuntimeControls-LaHQWOPc.js → FocusRuntimeControls-CoxLbl8K.js} +1 -1
  19. package/web/assets/{GitDiffViewer-D6X8UoVx.js → GitDiffViewer-BFdi1mxr.js} +1 -1
  20. package/web/assets/{ManageProjectsDialog-D4HGh_Lh.js → ManageProjectsDialog-BpsBTKv5.js} +1 -1
  21. package/web/assets/{MarkdownMessage-COsYrsCd.js → MarkdownMessage-B9Bb9VQU.js} +1 -1
  22. package/web/assets/{McpPage-Bfqrm6Ua.js → McpPage-D1onf9RA.js} +1 -1
  23. package/web/assets/MemoryEvolution-D4d8ELda.js +1 -0
  24. package/web/assets/MemoryPage-BxeQ1cdR.js +2 -0
  25. package/web/assets/{MobileNavigation-Ci_zzYIj.js → MobileNavigation-DQcTpoYc.js} +1 -1
  26. package/web/assets/{MorePage-0bECKmUj.js → MorePage-DqfRiueD.js} +1 -1
  27. package/web/assets/{NewFolderDialog-Ctuw8Xt9.js → NewFolderDialog-dNstknkT.js} +1 -1
  28. package/web/assets/{PageHeader-DDHU5m0R.js → PageHeader-Bn_vZ-th.js} +1 -1
  29. package/web/assets/{PhoneDrawer-DZMbkdza.js → PhoneDrawer-BnWXS2P1.js} +1 -1
  30. package/web/assets/{PhoneMenuButton-BtAGHyzX.js → PhoneMenuButton-Coocnsrf.js} +1 -1
  31. package/web/assets/{PhoneTopBar-Cx1lw-iS.js → PhoneTopBar-DUJ9aeM3.js} +1 -1
  32. package/web/assets/{PluginsPage-iBWJo-Ux.js → PluginsPage-Z7Fx-eAU.js} +1 -1
  33. package/web/assets/{SafeModePrompt-CEOQ01Bl.js → SafeModePrompt-DaxOzv7_.js} +1 -1
  34. package/web/assets/{SchedulesPage-Dw3CQw8g.js → SchedulesPage-ZGP3g3Vt.js} +1 -1
  35. package/web/assets/{SessionBrowserPane-DzZvN-iz.js → SessionBrowserPane-DeOqkbLQ.js} +2 -2
  36. package/web/assets/{SessionContextPanel-D2MIRUxU.js → SessionContextPanel-Co419auw.js} +2 -2
  37. package/web/assets/{SessionHome-BTl_EcTv.js → SessionHome-3GRisRUv.js} +1 -1
  38. package/web/assets/{SessionInspector-BY9P2WuS.js → SessionInspector-KjdRXk-P.js} +1 -1
  39. package/web/assets/{SessionShell-DzIXzmYM.js → SessionShell-DrMljmEy.js} +1 -1
  40. package/web/assets/{SettingsSidebar-DxFdOSKE.js → SettingsSidebar-Bfgryx3X.js} +1 -1
  41. package/web/assets/{ShortcutHelpDialog-BhD8_tZa.js → ShortcutHelpDialog-BEv4kDZo.js} +1 -1
  42. package/web/assets/{ShortcutKeys-CAiqwRJW.js → ShortcutKeys-CFnZogMX.js} +1 -1
  43. package/web/assets/{SidebarUpdateStatus-StFlsvF7.js → SidebarUpdateStatus-BaQLz9Ha.js} +1 -1
  44. package/web/assets/{SkillsPage-9ff7FB_P.js → SkillsPage-DiBdvo55.js} +1 -1
  45. package/web/assets/{TaskProcessesPane-Cjti3REL.js → TaskProcessesPane-CgzN0Oqf.js} +1 -1
  46. package/web/assets/{TaskTerminalView-Bj9xJWSN.js → TaskTerminalView-E0ZkafSN.js} +1 -1
  47. package/web/assets/{TerminalPanel-BsVTDd6P.js → TerminalPanel-KwRTV-hb.js} +1 -1
  48. package/web/assets/{WebDesktopPet-B1QzBZFt.js → WebDesktopPet-CGpI6-UL.js} +1 -1
  49. package/web/assets/{WorkflowsPage-BW0PAk_6.js → WorkflowsPage-BCfAr_BN.js} +1 -1
  50. package/web/assets/{WorkspacePicker-Di59Kt67.js → WorkspacePicker-DyL_8DP0.js} +1 -1
  51. package/web/assets/{api-DMqZSAib.js → api-D1flkoh7.js} +1 -1
  52. package/web/assets/{app-update-B3x5F3G0.js → app-update-DWy3AK8N.js} +1 -1
  53. package/web/assets/{approval-confirm-2JlrhCJj.js → approval-confirm-CDGLUuxy.js} +1 -1
  54. package/web/assets/{assets-api-BYWPazKD.js → assets-api-BGMZsyC4.js} +1 -1
  55. package/web/assets/{board-projects-wULJ4QMT.js → board-projects-DjGBcX8k.js} +1 -1
  56. package/web/assets/{bots-store-BFSwqKxI.js → bots-store-Ck_jncK7.js} +1 -1
  57. package/web/assets/{chat-api-CbddSAiB.js → chat-api-BqA8nXly.js} +1 -1
  58. package/web/assets/{client-store-CQELNb0e.js → client-store-e4OXhDNK.js} +1 -1
  59. package/web/assets/{command-BLb6loUF.js → command-LVPgEdXI.js} +1 -1
  60. package/web/assets/{config-search-CEVepeo_.js → config-search-a0xjM1yz.js} +1 -1
  61. package/web/assets/{desktop-hosts-D5V4ltEO.js → desktop-hosts-DsTa6yr4.js} +2 -2
  62. package/web/assets/{dialog-nax_z9Og.js → dialog-DldLiTwf.js} +1 -1
  63. package/web/assets/{event-stream-CuxX_nc8.js → event-stream-DRv0u06j.js} +1 -1
  64. package/web/assets/{events-BgoXNekW.js → events-C8OUQmIW.js} +1 -1
  65. package/web/assets/{folder-paths-BxUl5vo9.js → folder-paths-CfRbR0Ik.js} +1 -1
  66. package/web/assets/{hosts-yZPjlvMS.js → hosts-DbXwJrWt.js} +1 -1
  67. package/web/assets/{http-D4AhfBV1.js → http-B-XVZUum.js} +1 -1
  68. package/web/assets/{http-response-BHt8SJKV.js → http-response-DEs9jkgT.js} +1 -1
  69. package/web/assets/i18n-DyMZgkZI.js +1 -0
  70. package/web/assets/{index-Dw3Kz26s.js → index-CiyAfWLi.js} +2 -2
  71. package/web/assets/{machine-messages-Dy3k2jL6.js → machine-messages-CKHf8pyL.js} +1 -1
  72. package/web/assets/{machines-api-C8KK5tCO.js → machines-api-BeimiMiu.js} +1 -1
  73. package/web/assets/{memory-api-apQzknw7.js → memory-api-Cu3MEsQE.js} +1 -1
  74. package/web/assets/{mount-app-CI5QAfkX.js → mount-app-ISo-f47e.js} +2 -2
  75. package/web/assets/{permission-rules-api-Ci2nr5hD.js → permission-rules-api-bHINce43.js} +1 -1
  76. package/web/assets/{pick-system-directory-BeHwgRu7.js → pick-system-directory-D1GGkOTf.js} +1 -1
  77. package/web/assets/{placements-Bca0DPqX.js → placements-9_rV4h0k.js} +2 -2
  78. package/web/assets/{popover-2hW0lH2e.js → popover-DGWRnOht.js} +1 -1
  79. package/web/assets/{public-BWzxxlQu.js → public-B7wKOz_X.js} +2 -2
  80. package/web/assets/{public-bMk6lfoD.js → public-DRF_OfnY.js} +1 -1
  81. package/web/assets/{public-CUh5RfpQ.js → public-Dr8_scp5.js} +2 -2
  82. package/web/assets/{public-components-COcMq_cr.js → public-components-by-7di2-.js} +1 -1
  83. package/web/assets/public-diff-pNrf0LGG.js +1 -0
  84. package/web/assets/public-events-DmLE1dVC.js +1 -0
  85. package/web/assets/{public-flags-2sXN0jOy.js → public-flags-DHN44K2T.js} +1 -1
  86. package/web/assets/{public-folder-dialog-BrY1IUjD.js → public-folder-dialog-Gkbm4LRI.js} +1 -1
  87. package/web/assets/{public-greeting-F27_o7CG.js → public-greeting-Bdpk4piS.js} +1 -1
  88. package/web/assets/{public-CvQSuCpU.js → public-lAWjPSYc.js} +1 -1
  89. package/web/assets/{public-session-BXcmWF--.js → public-session-CtusCiv8.js} +1 -1
  90. package/web/assets/{public-sidebar-rxvfp6cZ.js → public-sidebar-DmWVSBL3.js} +1 -1
  91. package/web/assets/{runtime-capabilities-store-BA14peh5.js → runtime-capabilities-store-MtXRlSIi.js} +1 -1
  92. package/web/assets/{safe-mode-instance-CpApZsNO.js → safe-mode-instance-CpOBP8Nz.js} +1 -1
  93. package/web/assets/safe-mode-sentinel-BGslsjrl.js +1 -0
  94. package/web/assets/{session-change-summary-api-zrzUcWPa.js → session-change-summary-api-CAkw4_-l.js} +1 -1
  95. package/web/assets/{session-home-cMbldWP4.js → session-home-CJcIlNWK.js} +1 -1
  96. package/web/assets/{session-inspector-store-CVt788oh.js → session-inspector-store-C3BluNoW.js} +1 -1
  97. package/web/assets/{session-questions-CFzjCrxi.js → session-questions-BPKyVhzp.js} +1 -1
  98. package/web/assets/{session-scope-DSz16bMk.js → session-scope-ddZfvpZE.js} +1 -1
  99. package/web/assets/{session-tree-actions-DejUCyUM.js → session-tree-actions-_YCQsWye.js} +1 -1
  100. package/web/assets/{session-tree-summary-Bjg79Vc5.js → session-tree-summary-BLsTrwUq.js} +1 -1
  101. package/web/assets/{session-web-preview-BUv0rBHy.js → session-web-preview-DZOVkeBU.js} +1 -1
  102. package/web/assets/{shortcuts-lvsdkhJa.js → shortcuts-C6ddcUau.js} +1 -1
  103. package/web/assets/{side-chat-context-D9g8NFwu.js → side-chat-context-C7vwSBGo.js} +4 -4
  104. package/web/assets/{sidebar-CtLMqJCy.js → sidebar-B7HP3-3A.js} +1 -1
  105. package/web/assets/{sidebar-store-QQPSgdSc.js → sidebar-store-Bv_D4lVD.js} +1 -1
  106. package/web/assets/{speech-session-C_7w5AfS.js → speech-session-DI3T3jpW.js} +1 -1
  107. package/web/assets/{startup-queries-CbAKsBHA.js → startup-queries-B2k6wlnS.js} +1 -1
  108. package/web/assets/{use-i18n-47vsdOU3.js → use-i18n-CsOCclo6.js} +1 -1
  109. package/web/assets/{use-open-bot-CHjqcvJF.js → use-open-bot-BPSaOfrG.js} +1 -1
  110. package/web/assets/{use-studio-actions-CMpatayc.js → use-studio-actions-Cvz4jiDa.js} +1 -1
  111. package/web/assets/{useCatalogProjects-t9qTve0q.js → useCatalogProjects-D3mDdYej.js} +1 -1
  112. package/web/assets/{useMachines-deaqc_F-.js → useMachines-BwvKcPVd.js} +1 -1
  113. package/web/assets/useNativeBrowser-CF8AHTRL.js +1 -0
  114. package/web/assets/{useNewProjectPicker-D5M2WzCG.js → useNewProjectPicker-DfE1or_O.js} +2 -2
  115. package/web/assets/{useNow-D1gmERNF.js → useNow-CuwOIh4H.js} +1 -1
  116. package/web/assets/{usePhoneShell-Bn3ZlBYr.js → usePhoneShell-e-CScTJH.js} +1 -1
  117. package/web/assets/{useSessionRowActions-C59wvHhe.js → useSessionRowActions-DUufel_k.js} +1 -1
  118. package/web/assets/{useSidebarModel-B9j6QP07.js → useSidebarModel-CShQi_Fw.js} +1 -1
  119. package/web/assets/{workspace-folders-VL22twQS.js → workspace-folders-Dq7V_wOF.js} +1 -1
  120. package/web/assets/{workspace-order-store-Cz2oC0mc.js → workspace-order-store-PI98x5sR.js} +1 -1
  121. package/web/index.html +1 -1
  122. package/web/assets/MemoryEvolution-B3gyPy3a.js +0 -1
  123. package/web/assets/MemoryPage-CpBDpgyx.js +0 -2
  124. package/web/assets/i18n-CHUj56MI.js +0 -1
  125. package/web/assets/public-diff-7U99QOFO.js +0 -1
  126. package/web/assets/public-events-DaY2zYrz.js +0 -1
  127. package/web/assets/safe-mode-sentinel-b5M49bjO.js +0 -1
  128. package/web/assets/useNativeBrowser-C0j3zafh.js +0 -1
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{u as t}from"./vendor-router-CSN_DGvx.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{t as i}from"./use-i18n-47vsdOU3.js";import{t as a}from"./api-DMqZSAib.js";import{t as o}from"./bell-BjONAtgH.js";import{t as s}from"./bot-B3TaBp_T.js";import{t as c}from"./calendar-clock-VIxTaqqy.js";import{t as l}from"./circle-check-iEdCm3Pw.js";import{t as u}from"./WorkspacePicker-Di59Kt67.js";import{t as d}from"./folder-open-FIShC5Qk.js";import{t as f}from"./message-circle-D-XrK6Ft.js";import{t as p}from"./play-DNDjDNGn.js";import{t as m}from"./plus-fQbSqB1n.js";import{t as h}from"./send-Cj-W03w_.js";import{t as g}from"./trash-2-CNrPOoPR.js";import{t as _}from"./triangle-alert-CE1q54ci.js";import{t as v}from"./more-pages-D_PnxLN0.js";import{t as y}from"./switch-D_G8wFhs.js";import{t as b}from"./utils-C8uzG5AZ.js";import{n as x,t as S}from"./button-CCcCN8tE.js";import{s as C}from"./shortcuts-lvsdkhJa.js";import{a as w}from"./format-DMJQzoZ7.js";import{t as T}from"./StatusGlyph-1KgitlUg.js";import{a as E,i as D,l as O,s as ee,t as k}from"./dialog-nax_z9Og.js";import{t as A}from"./input-CPw-zkYh.js";import{t as j}from"./textarea-DmATpOqT.js";import{t as M}from"./pick-system-directory-BeHwgRu7.js";import{n as N,t as P}from"./PageState-Cz6vFMXv.js";import{a as te,i as ne,n as re,o as ie,r as ae,s as oe,t as se}from"./FeaturePage-DyRo_I02.js";import{n as F}from"./field-DoLEb0np.js";import{t as I}from"./AppSelect-B15Hpk2W.js";import{i as L,s as R}from"./app-primitives-BskZ4ZJj.js";var z=e(n(),1),B=r(),V={browser:{name:`通知`,Icon:o},feishu:{name:`飞书`,Icon:s},weixin:{name:`微信`,Icon:f},qq:{name:`QQ`,Icon:f},telegram:{name:`Telegram`,Icon:h}},H={once:`一次`,interval:`每隔一段时间`,daily:`每天`,weekly:`每周`,monthly:`每月`},U={minutes:`分钟`,hours:`小时`,days:`天`},W=[...new Set([`Asia/Hong_Kong`,`UTC`,...typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[]])],G=[`full-access`],K=`mt-4 border-t border-stroke-soft pt-1`,q=`form-grid grid gap-x-3 sm:grid-cols-3`,J=`schedule-interval-input grid grid-cols-[minmax(0,1fr)_minmax(84px,auto)] gap-1.5`,Y=`inline-grid h-8 grid-cols-2 rounded-md border border-stroke bg-chrome p-[3px] max-[650px]:h-auto max-[650px]:w-full pointer-coarse:h-auto`,ce=`inline-flex min-w-0 items-center justify-center rounded-sm border border-transparent px-3 text-sm text-content-secondary transition-colors duration-(--d-fast) hover:text-content aria-pressed:border-key-border aria-pressed:bg-key aria-pressed:font-medium aria-pressed:text-content aria-pressed:shadow-key max-[650px]:h-11 pointer-coarse:h-11`;function le({status:e}){return(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`mt-px grid size-[18px] flex-none place-items-center`,children:(0,B.jsx)(T,{status:e===`running`?`run`:e===`completed`?`done`:`failed`,className:`size-3.5`})})}function ue(e){return e(`schedules:schedulesPage.fullAccessHelp`)}function de(e,t){return t(e===`once`?`schedules:schedulesPage.once`:e===`daily`?`schedules:schedulesPage.daily`:e===`weekly`?`schedules:schedulesPage.weekly`:e===`monthly`?`schedules:schedulesPage.monthly`:`schedules:schedulesPage.atIntervals`)}function fe(e,t){return t(e===`hours`?`schedules:schedulesPage.hours`:e===`days`?`schedules:schedulesPage.days`:`schedules:schedulesPage.minutes`)}function pe(e,t){return t(e===`feishu`?`schedules:schedulesPage.feishu`:e===`weixin`?`schedules:schedulesPage.weChat`:e===`qq`?`schedules:schedulesPage.qq`:e===`telegram`?`schedules:schedulesPage.telegram`:`schedules:schedulesPage.browserNotification`)}function X({value:e,onChange:t}){let{t:n}=i();return(0,B.jsxs)(F,{variant:`control`,children:[n(`schedules:schedulesPage.executionMode`),(0,B.jsx)(I,{value:e,onChange:e=>t(e.target.value),children:G.map(e=>(0,B.jsx)(`option`,{value:e,children:n(`schedules:schedulesPage.fullAccess`)},e))}),(0,B.jsx)(`small`,{children:ue(n)})]})}function Z(e){return Object.fromEntries((e?.inputs||[]).map(e=>[e.name,e.defaultValue??``]))}function Q(e,t,n,r,i){if(e===`prompt`)return!!t.trim();let a=i.find(e=>e.id===n);return a?a.inputs.every(e=>{let t=Object.hasOwn(r,e.name)?r[e.name]:e.defaultValue;return!e.required||t!=null&&t!==``}):!1}function $({targetType:e,prompt:t,workflowId:n,workflowInputs:r,workflows:a,onChange:o}){let{t:s}=i(),c=a.find(e=>e.id===n);return(0,B.jsxs)(`div`,{className:`grid`,children:[(0,B.jsxs)(F,{variant:`control`,children:[s(`schedules:schedulesPage.executionTarget`),(0,B.jsxs)(I,{value:e,onChange:e=>{let t=e.target.value,i=a[0];o(t===`workflow`?{targetType:t,workflowId:n||i?.id||``,workflowInputs:n?r:Z(i)}:{targetType:t})},children:[(0,B.jsx)(`option`,{value:`prompt`,children:`Prompt`}),(0,B.jsx)(`option`,{value:`workflow`,children:s(`schedules:schedulesPage.workflow`)})]})]}),e===`prompt`?(0,B.jsxs)(F,{variant:`control`,children:[`Prompt`,(0,B.jsx)(j,{value:t,onChange:e=>o({prompt:e.target.value}),placeholder:s(`schedules:schedulesPage.describeTheWorkTheAgentShouldCompleteEachTime`)})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(F,{variant:`control`,children:[s(`schedules:schedulesPage.workflow`),(0,B.jsxs)(I,{value:n,onChange:e=>{let t=a.find(t=>t.id===e.target.value);o({workflowId:e.target.value,workflowInputs:Z(t)})},children:[(0,B.jsx)(`option`,{value:``,children:s(`schedules:schedulesPage.selectPublishedWorkflow`)}),a.map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.name,` · v`,e.revision]},e.id))]}),(0,B.jsx)(`small`,{children:c?.description||(a.length?s(`schedules:schedulesPage.workflowUsesItsOwnRuntimeSettings`):s(`schedules:schedulesPage.noPublishedWorkflows`))})]}),c?.inputs.length?(0,B.jsxs)(`div`,{className:`grid`,children:[(0,B.jsxs)(`div`,{className:`schedule-workflow-inputs-heading mt-3 flex items-baseline justify-between gap-3 max-[650px]:flex-col max-[650px]:items-start max-[650px]:gap-0.5 [&_small]:text-xs [&_small]:text-content-muted [&_strong]:text-xs [&_strong]:font-medium [&_strong]:text-content-secondary`,children:[(0,B.jsx)(`strong`,{children:s(`schedules:schedulesPage.workflowInputs`)}),(0,B.jsx)(`small`,{children:s(`schedules:schedulesPage.workflowInputsHelp`)})]}),(0,B.jsx)(`div`,{className:`schedule-workflow-inputs grid gap-x-3 sm:grid-cols-2 [&_input[type=checkbox]]:size-4 [&_input[type=checkbox]]:justify-self-end [&_input[type=checkbox]]:accent-star`,children:c.inputs.map(e=>(0,B.jsxs)(F,{variant:`control`,className:e.type===`boolean`?`grid grid-cols-[minmax(0,1fr)_auto] items-center`:void 0,children:[e.label,e.required?` *`:``,e.type===`boolean`?(0,B.jsx)(y,{checked:!!r[e.name],onCheckedChange:t=>o({workflowInputs:{...r,[e.name]:t}})}):(0,B.jsx)(A,{type:e.type===`number`?`number`:`text`,required:e.required,value:String(r[e.name]??``),onChange:t=>o({workflowInputs:{...r,[e.name]:t.target.value}})}),e.description&&(0,B.jsx)(`small`,{children:e.description})]},e.id))})]}):null]})]})}function me({value:e,onChange:t}){let{t:n}=i(),[r,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(!1),c=async()=>{a(``);try{let r=await M(e,n(`common:workspacePicker.selectWorkspaceForSchedule`));r.status===`picked`?t(r.path):r.status===`unavailable`&&s(!0)}catch(e){a(e instanceof Error?e.message:String(e))}};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(F,{variant:`control`,children:[n(`schedules:schedulesPage.workingDirectory`),(0,B.jsxs)(`span`,{className:`schedule-workspace-input grid grid-cols-[minmax(0,1fr)_auto] gap-1.5 [&_input]:min-w-0 [&_input]:font-mono`,children:[(0,B.jsx)(A,{value:e,onChange:e=>t(e.target.value),placeholder:n(`schedules:schedulesPage.enterTheProjectSAbsolutePath`)}),(0,B.jsxs)(S,{type:`button`,variant:`secondary`,className:`h-auto min-h-8`,onClick:()=>void c(),children:[(0,B.jsx)(d,{}),n(`schedules:schedulesPage.browseDirectories`)]})]}),(0,B.jsx)(`small`,{children:n(`schedules:schedulesPage.theScheduledAgentWillRunInThisDirectory`)})]}),r&&(0,B.jsxs)(L,{children:[(0,B.jsx)(_,{size:13}),r]}),(0,B.jsx)(u,{open:o,initialPath:e,description:n(`common:workspacePicker.selectWorkspaceForSchedule`),onOpenChange:s,onSelect:e=>t(e)})]})}function he(e){return{id:e.id,name:e.name,targetType:e.targetType||`prompt`,prompt:e.prompt,workflowId:e.workflowId||``,workflowInputs:e.workflowInputs||{},enabled:e.enabled,frequency:e.frequency,intervalValue:e.intervalValue||1,intervalUnit:e.intervalUnit||`hours`,time:e.time,date:e.date||``,timezone:e.timezone,dayOfWeek:e.dayOfWeek,dayOfMonth:e.dayOfMonth,cwd:e.cwd,executionMode:e.executionMode||`full-access`,model:e.model,notifications:e.notifications||[],notifyOn:e.notifyOn||`always`}}function ge(e,t=`zh-CN`){return!e.enabled||!e.nextRunAt?t===`en-US`?`Paused`:`已暂停`:new Intl.DateTimeFormat(t,{timeZone:e.timezone,dateStyle:`medium`,timeStyle:`short`}).format(new Date(e.nextRunAt))}function _e({notify:e,onBack:n,openNotificationSettings:r,requestConfirm:o}){let{t:s,language:l}=i(),u=t(),d=C(`focusSearch`),[f,p]=(0,z.useState)({tasks:[],runs:[],notificationTargets:{browser:{enabled:!1},feishu:{enabled:!1},weixin:{enabled:!1},qq:{enabled:!1},telegram:{enabled:!1}},workflows:[],defaultCwd:``}),[h,g]=(0,z.useState)(``),[_,y]=(0,z.useState)({}),[b,x]=(0,z.useState)(!0),[w,E]=(0,z.useState)(!1),[D,O]=(0,z.useState)(``),[ee,k]=(0,z.useState)(!1),[A,j]=(0,z.useState)(``),[M,F]=(0,z.useState)(!1),[I,L]=(0,z.useState)(``),R=(0,z.useCallback)(async()=>{try{let e=await a(`/api/schedules`);p(e),E(!0),O(``),g(t=>e.tasks.some(e=>e.id===t)?t:``),y(t=>{let n=Object.entries(t).filter(([t])=>e.tasks.some(e=>e.id===t));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})}catch(e){O(e instanceof Error?e.message:String(e))}finally{x(!1)}},[]);(0,z.useEffect)(()=>{R()},[R]),(0,z.useEffect)(()=>{let e=window.setInterval(R,f.tasks.some(e=>e.lastStatus===`running`)?2e3:1e4);return()=>window.clearInterval(e)},[f.tasks,R]);let V=f.tasks.find(e=>e.id===h),H=f.workflows||[],U=V?_[V.id]??he(V):null,W=(0,z.useMemo)(()=>f.runs.filter(e=>e.taskId===h).sort((e,t)=>new Date(t.startedAt).getTime()-new Date(e.startedAt).getTime()).slice(0,20),[f.runs,h]),G=e=>H.find(t=>t.id===e.workflowId)?.name||s(`schedules:schedulesPage.workflowUnavailable`),K=I.trim().toLocaleLowerCase(),q=K?f.tasks.filter(e=>`${e.name} ${e.targetType===`workflow`?G(e):e.targetType===`bot`?e.botMessage||``:e.prompt}`.toLocaleLowerCase().includes(K)):f.tasks,J=f.tasks.filter(e=>e.enabled).length,Y=e=>{if(!V)return;let t=he(V);y(n=>({...n,[t.id]:{...n[t.id]??t,...e}}))},ce=e=>{U&&Y({notifications:U.notifications.includes(e)?U.notifications.filter(t=>t!==e):[...U.notifications,e]})},le=async()=>{if(!(!V||!U)){k(!0),j(``);try{let t=await a(`/api/schedules/${encodeURIComponent(V.id)}`,{method:`PATCH`,body:JSON.stringify(U)});p(t.state),y(e=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t.task.id))),e(s(`schedules:schedulesPage.scheduledTaskSaved`))}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}}},ue=async()=>{if(V){k(!0),j(``);try{await a(`/api/schedules/${encodeURIComponent(V.id)}/run`,{method:`POST`,body:`{}`}),await R(),e(s(`schedules:schedulesPage.scheduledTaskStarted`))}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}}},pe=async()=>{if(V&&await o({title:s(`schedules:schedulesPage.deleteScheduledTask`),message:s(`schedules:schedulesPage.deleteScheduledTaskNameAndItsRunHistory`,{name:V.name}),confirmLabel:s(`schedules:schedulesPage.delete`)}))try{await a(`/api/schedules/${encodeURIComponent(V.id)}`,{method:`DELETE`}),await R(),e(s(`schedules:schedulesPage.scheduledTaskDeleted`))}catch(e){j(e instanceof Error?e.message:String(e))}},X=t=>{p(t.state),g(t.task.id),e(s(`schedules:schedulesPage.scheduledTaskCreated`))},Z=e=>(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col items-end gap-0.5 max-[650px]:flex-row max-[650px]:items-center max-[650px]:gap-2`,children:[e.lastStatus===`running`?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,B.jsx)(T,{status:`run`,className:`size-3.5`}),s(`schedules:schedulesPage.running`)]}):(0,B.jsx)(`span`,{className:`whitespace-nowrap`,children:e.enabled?s(`schedules:schedulesPage.nextRunTime`,{time:ge(e,l)}):e.lastStatus===`missed`?s(`schedules:schedulesPage.missed`):e.frequency===`once`&&e.lastRunAt?s(`schedules:schedulesPage.onceDone`):s(`schedules:schedulesPage.pause`)}),e.lastStatus===`failed`&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,B.jsx)(T,{status:`failed`,className:`size-3.5`}),s(`schedules:schedulesPage.lastRunFailed`)]})]}),Q=s(`navigation:navigation.schedules`);return(0,B.jsxs)(ae,{title:Q,description:s(`schedules:schedulesPage.lede`),back:n&&{label:s(`navigation:sidebar.features`),ariaLabel:s(`navigation:shell.backToFeaturesLabel`),onBack:n},toolbar:(0,B.jsx)(oe,{search:(0,B.jsx)(te,{id:v,value:I,onValueChange:L,placeholder:s(`navigation:pageHeader.searchPage`,{page:Q}),shortcut:d,clearLabel:s(`navigation:more.clearSearch`)}),actions:(0,B.jsxs)(S,{type:`button`,className:`h-9`,disabled:!w,onClick:()=>F(!0),children:[(0,B.jsx)(m,{}),s(`schedules:schedulesPage.newTask`)]})}),children:[b?(0,B.jsx)(N,{kind:`loading`,title:s(`schedules:schedulesPage.loadingScheduledTasks`)}):D&&!w?(0,B.jsx)(N,{kind:`error`,title:s(`schedules:schedulesPage.loadFailed`),description:D,action:(0,B.jsx)(S,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>{x(!0),R()},children:s(`common:pageTemplate.retry`)})}):(0,B.jsxs)(B.Fragment,{children:[(A||D)&&(0,B.jsx)(se,{children:A||D}),(0,B.jsx)(ie,{title:s(`schedules:schedulesPage.tasks`),count:f.tasks.length,meta:f.tasks.length?s(`schedules:schedulesPage.enabledCount`,{count:J}):void 0,children:q.length?(0,B.jsx)(re,{children:q.map(e=>{let t=h===e.id;return(0,B.jsx)(ne,{"data-schedule-task":e.id,className:`schedule-list-item`,icon:(0,B.jsx)(c,{}),name:e.name,description:e.targetType===`workflow`?(0,B.jsx)(`span`,{className:`font-mono`,children:G(e)}):e.targetType===`bot`?s(`schedules:schedulesPage.botTarget`,{message:e.botMessage||``}):e.prompt,meta:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{children:de(e.frequency,s)}),(0,B.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,B.jsx)(`span`,{className:`tabular-nums`,children:e.frequency===`interval`?`${e.intervalValue} ${fe(e.intervalUnit,s)}`:e.frequency===`once`?`${e.date} ${e.time}`:e.time}),(0,B.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.timezone}),e.createdBy?.kind===`agent`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,B.jsx)(`span`,{"data-schedule-created-by":`agent`,children:s(`schedules:schedulesPage.createdByAgent`)})]})]}),status:Z(e),expanded:t,onExpandedChange:t=>g(t?e.id:``),toggleLabel:s(`schedules:schedulesPage.toggleTaskDetails`,{name:e.name}),detail:t&&e.targetType===`bot`?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm text-content-secondary`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1`,children:s(`schedules:schedulesPage.botManagedThere`)}),(0,B.jsx)(S,{size:`sm`,variant:`outline`,onClick:()=>u(`/bots/${encodeURIComponent(e.botId||``)}`),children:s(`schedules:schedulesPage.openBot`)})]}):t&&U&&V?(0,B.jsx)(ve,{task:V,draft:U,runs:W,saving:ee,workflows:H,notificationTargets:f.notificationTargets,language:l,onUpdate:Y,onToggleNotification:ce,onRun:ue,onRemove:pe,onSave:le,onEditTemplates:r}):null},e.id)})}):(0,B.jsx)(P,{title:f.tasks.length?s(`schedules:schedulesPage.noMatchingTasks`):s(`schedules:schedulesPage.theTimelineIsStillUnlit`),description:f.tasks.length?void 0:s(`schedules:schedulesPage.createATaskAndLetItSetOutAutomaticallyAtTheAppointedTime`)})})]}),M&&(0,B.jsx)(ye,{notificationTargets:f.notificationTargets,workflows:H,defaultCwd:f.defaultCwd,onClose:()=>F(!1),onCreated:e=>{F(!1),X(e)}})]})}function ve({task:e,draft:t,runs:n,saving:r,workflows:a,notificationTargets:o,language:s,onUpdate:c,onToggleNotification:u,onRun:d,onRemove:f,onSave:m,onEditTemplates:h}){let{t:_}=i(),v=e.lastStatus===`running`;return(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`label`,{className:`mr-auto inline-flex min-h-8 items-center gap-2.5 text-sm text-content max-[650px]:min-h-11`,children:[(0,B.jsx)(R,{value:t.enabled,onChange:e=>c({enabled:e}),ariaLabel:_(`schedules:schedulesPage.enableTaskName`,{name:t.name})}),t.enabled?_(`schedules:schedulesPage.enabled`):_(`schedules:schedulesPage.pause`)]}),(0,B.jsxs)(S,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,disabled:r||v,onClick:d,children:[v?(0,B.jsx)(x,{}):(0,B.jsx)(p,{}),_(v?`schedules:schedulesPage.running`:`schedules:schedulesPage.runNow`)]}),(0,B.jsx)(S,{variant:`ghost`,size:`icon-sm`,className:`hover:bg-danger-soft hover:text-danger max-[650px]:size-11`,title:_(`schedules:schedulesPage.deleteTask`),"aria-label":_(`schedules:schedulesPage.deleteTask`),onClick:f,children:(0,B.jsx)(g,{})})]}),(0,B.jsx)($,{targetType:t.targetType,prompt:t.prompt,workflowId:t.workflowId,workflowInputs:t.workflowInputs,workflows:a,onChange:c}),t.targetType===`prompt`&&(0,B.jsx)(me,{value:t.cwd,onChange:e=>c({cwd:e})}),(0,B.jsx)(`div`,{className:K,children:(0,B.jsxs)(`div`,{className:q,children:[(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.frequency`),(0,B.jsx)(I,{value:t.frequency,onChange:e=>c({frequency:e.target.value}),children:Object.keys(H).map(e=>(0,B.jsx)(`option`,{value:e,children:de(e,_)},e))})]}),t.frequency===`interval`?(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.runInterval`),(0,B.jsxs)(`span`,{className:J,children:[(0,B.jsx)(A,{type:`number`,min:`1`,value:t.intervalValue,onChange:e=>c({intervalValue:Number(e.target.value)})}),(0,B.jsx)(I,{value:t.intervalUnit,onChange:e=>c({intervalUnit:e.target.value}),children:Object.keys(U).map(e=>(0,B.jsx)(`option`,{value:e,children:fe(e,_)},e))})]})]}):(0,B.jsxs)(B.Fragment,{children:[t.frequency===`once`&&(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.date`),(0,B.jsx)(A,{type:`date`,className:`tabular-nums`,value:t.date,onChange:e=>c({date:e.target.value})})]}),(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.time`),(0,B.jsx)(A,{type:`time`,className:`tabular-nums`,value:t.time,onChange:e=>c({time:e.target.value})})]})]}),(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.timeZone`),(0,B.jsx)(I,{value:t.timezone,onChange:e=>c({timezone:e.target.value}),children:W.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))})]}),t.targetType===`prompt`&&(0,B.jsx)(X,{value:t.executionMode,onChange:e=>c({executionMode:e})})]})}),(0,B.jsxs)(`div`,{className:b(`schedule-notification-section pt-3`,K),children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(`strong`,{className:`text-sm font-medium`,children:_(`schedules:schedulesPage.notificationChannels`)}),(0,B.jsx)(`button`,{type:`button`,className:`text-button text-xs font-medium text-content-secondary underline underline-offset-2 hover:text-content max-[650px]:min-h-11`,onClick:h,children:_(`schedules:schedulesPage.editTemplates`)})]}),(0,B.jsx)(`p`,{className:`mt-0.5 text-xs text-content-muted`,children:_(`schedules:schedulesPage.notificationChannelsHelp`)}),(0,B.jsx)(`div`,{className:`schedule-notification-targets mt-2.5 grid grid-cols-[repeat(auto-fill,minmax(132px,1fr))] gap-2`,children:Object.entries(V).map(([e,n])=>{let r=n.Icon,i=t.notifications.includes(e);return(0,B.jsxs)(`button`,{type:`button`,"aria-pressed":i,className:b(`grid min-h-[52px] grid-cols-[16px_minmax(0,1fr)_16px] items-center gap-2 rounded-md border px-2.5 py-2 text-left transition-colors duration-(--d-fast)`,i?`selected border-star-border bg-star-soft text-star-strong`:`border-stroke bg-panel text-content hover:bg-surface-subtle`),onClick:()=>u(e),children:[(0,B.jsx)(r,{className:`size-4`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,B.jsx)(`strong`,{className:`truncate text-sm font-medium`,children:pe(e,_)}),(0,B.jsx)(`small`,{className:`truncate text-xs text-content-muted`,children:o[e].enabled?_(`schedules:schedulesPage.configured`):_(`schedules:schedulesPage.notConfigured`)})]}),(0,B.jsx)(l,{className:b(`size-4`,i?`text-star-strong`:`text-content-faint`)})]},e)})}),(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,B.jsx)(`span`,{id:`schedule-notify-on-${e.id}`,className:`text-xs text-content-muted`,children:_(`schedules:schedulesPage.notifyWhen`)}),(0,B.jsx)(`div`,{role:`group`,"aria-labelledby":`schedule-notify-on-${e.id}`,className:b(`schedule-notification-chip`,Y),children:[`always`,`failure`].map(e=>(0,B.jsx)(`button`,{type:`button`,"aria-pressed":t.notifyOn===e,className:ce,onClick:()=>c({notifyOn:e}),children:_(e===`failure`?`schedules:schedulesPage.failuresOnly`:`schedules:schedulesPage.completionAndFailure`)},e))})]})]}),(0,B.jsxs)(`div`,{className:`form-footer mt-4 flex items-center justify-between gap-2.5 border-t border-stroke-soft pt-3 max-[650px]:flex-wrap`,children:[(0,B.jsx)(`span`,{className:`text-xs text-content-muted tabular-nums`,children:e.lastRunAt?_(`schedules:schedulesPage.lastRunTime`,{time:w(e.lastRunAt,s)}):_(`schedules:schedulesPage.nextRunTime`,{time:ge(e,s)})}),(0,B.jsxs)(S,{className:`max-[650px]:h-11 max-[650px]:w-full`,disabled:r||!Q(t.targetType,t.prompt,t.workflowId,t.workflowInputs,a),onClick:m,children:[r?(0,B.jsx)(x,{className:`text-current`}):null,_(r?`schedules:schedulesPage.saving`:`schedules:schedulesPage.saveTask`)]})]})]}),(0,B.jsxs)(`section`,{"aria-labelledby":`schedule-runs-${e.id}`,className:`min-w-0`,children:[(0,B.jsxs)(`h3`,{id:`schedule-runs-${e.id}`,className:`mb-1.5 text-[13px] font-medium text-content-muted tabular-nums`,children:[_(`schedules:schedulesPage.recentRuns`),` · `,n.length]}),n.length?(0,B.jsx)(`ul`,{className:`divide-y divide-stroke-soft overflow-hidden rounded-[var(--r-md)] border border-stroke`,children:n.map(e=>(0,B.jsxs)(`li`,{className:`schedule-run-row grid min-h-11 grid-cols-[18px_minmax(0,1fr)_auto] items-start gap-2.5 px-3 py-2.5 ${e.status}`,children:[(0,B.jsx)(le,{status:e.status}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,B.jsx)(`strong`,{className:`line-clamp-2 text-sm leading-5 font-medium text-content`,children:e.status===`running`?_(`schedules:schedulesPage.running2`):e.status===`completed`?e.summary||_(`schedules:schedulesPage.taskCompleted`):e.status===`interrupted`?_(`schedules:schedulesPage.taskInterrupted`):e.error||_(`schedules:schedulesPage.taskFailed`)}),(0,B.jsxs)(`small`,{className:`text-xs text-content-muted tabular-nums`,children:[w(e.startedAt,s),` ·`,` `,e.trigger===`manual`?_(`schedules:schedulesPage.manualRun`):_(`schedules:schedulesPage.scheduledTrigger`),e.durationMs?` · ${_(`schedules:schedulesPage.countSec`,{count:Math.round(e.durationMs/1e3)})}`:``]})]}),(0,B.jsx)(`em`,{className:`font-mono text-xs leading-5 text-content-secondary not-italic tabular-nums`,children:new Intl.DateTimeFormat(s,{hour:`2-digit`,minute:`2-digit`}).format(new Date(e.startedAt))})]},e.id))}):(0,B.jsx)(P,{compact:!0,title:_(`schedules:schedulesPage.noRunHistory`)})]})]})}function ye({notificationTargets:e,workflows:t,defaultCwd:n,onClose:r,onCreated:o}){let{t:s}=i(),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(`prompt`),[f,p]=(0,z.useState)(``),[h,g]=(0,z.useState)(``),[v,y]=(0,z.useState)({}),[b,C]=(0,z.useState)(n||``),[w,T]=(0,z.useState)(`full-access`),[j,M]=(0,z.useState)(!1),[N,P]=(0,z.useState)(``);return(0,B.jsx)(k,{open:!0,onOpenChange:e=>!e&&r(),children:(0,B.jsx)(D,{size:`compact`,children:(0,B.jsxs)(`form`,{className:`grid min-w-0`,onSubmit:async t=>{t.preventDefault(),M(!0),P(``);try{let t=Object.entries(e).filter(([,e])=>e.enabled).map(([e])=>e);o(await a(`/api/schedules`,{method:`POST`,body:JSON.stringify({name:c,targetType:u,prompt:f,workflowId:h,workflowInputs:v,cwd:b,enabled:!0,frequency:`daily`,time:`09:00`,timezone:`Asia/Hong_Kong`,executionMode:w,notifications:t,notifyOn:`always`})}))}catch(e){P(e instanceof Error?e.message:String(e))}finally{M(!1)}},children:[(0,B.jsxs)(ee,{children:[(0,B.jsx)(O,{children:s(`schedules:schedulesPage.newScheduledTask`)}),(0,B.jsx)(E,{children:s(`schedules:schedulesPage.youCanContinueSettingTheRunTimeAndNotificationChannelsAfterCreation`)})]}),(0,B.jsxs)(F,{variant:`control`,children:[s(`schedules:schedulesPage.taskName`),(0,B.jsx)(A,{value:c,onChange:e=>l(e.target.value),placeholder:s(`schedules:schedulesPage.forExampleDailyCodeReview`)})]}),(0,B.jsx)($,{targetType:u,prompt:f,workflowId:h,workflowInputs:v,workflows:t,onChange:e=>{e.targetType&&d(e.targetType),e.prompt!==void 0&&p(e.prompt),e.workflowId!==void 0&&g(e.workflowId),e.workflowInputs!==void 0&&y(e.workflowInputs)}}),u===`prompt`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(me,{value:b,onChange:C}),(0,B.jsx)(X,{value:w,onChange:T})]}),N&&(0,B.jsxs)(L,{children:[(0,B.jsx)(_,{size:13}),N]}),(0,B.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2 max-[650px]:[&>button]:h-11 max-[650px]:[&>button]:flex-1`,children:[(0,B.jsx)(S,{type:`button`,variant:`secondary`,onClick:r,children:s(`schedules:schedulesPage.cancel`)}),(0,B.jsxs)(S,{type:`submit`,disabled:j||!c.trim()||!Q(u,f,h,v,t),children:[j?(0,B.jsx)(x,{className:`text-current`}):(0,B.jsx)(m,{}),s(j?`schedules:schedulesPage.creating`:`schedules:schedulesPage.createTask`)]})]})]})})})}export{_e as SchedulesPage};
1
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{u as t}from"./vendor-router-CSN_DGvx.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{t as i}from"./use-i18n-CsOCclo6.js";import{t as a}from"./api-D1flkoh7.js";import{t as o}from"./bell-BjONAtgH.js";import{t as s}from"./bot-B3TaBp_T.js";import{t as c}from"./calendar-clock-VIxTaqqy.js";import{t as l}from"./circle-check-iEdCm3Pw.js";import{t as u}from"./WorkspacePicker-DyL_8DP0.js";import{t as d}from"./folder-open-FIShC5Qk.js";import{t as f}from"./message-circle-D-XrK6Ft.js";import{t as p}from"./play-DNDjDNGn.js";import{t as m}from"./plus-fQbSqB1n.js";import{t as h}from"./send-Cj-W03w_.js";import{t as g}from"./trash-2-CNrPOoPR.js";import{t as _}from"./triangle-alert-CE1q54ci.js";import{t as v}from"./more-pages-D_PnxLN0.js";import{t as y}from"./switch-D_G8wFhs.js";import{t as b}from"./utils-C8uzG5AZ.js";import{n as x,t as S}from"./button-CCcCN8tE.js";import{s as C}from"./shortcuts-C6ddcUau.js";import{a as w}from"./format-DMJQzoZ7.js";import{t as T}from"./StatusGlyph-1KgitlUg.js";import{a as E,i as D,l as O,s as ee,t as k}from"./dialog-DldLiTwf.js";import{t as A}from"./input-CPw-zkYh.js";import{t as j}from"./textarea-DmATpOqT.js";import{t as M}from"./pick-system-directory-D1GGkOTf.js";import{n as N,t as P}from"./PageState-Cz6vFMXv.js";import{a as te,i as ne,n as re,o as ie,r as ae,s as oe,t as se}from"./FeaturePage-DEjUrI25.js";import{n as F}from"./field-DoLEb0np.js";import{t as I}from"./AppSelect-B15Hpk2W.js";import{i as L,s as R}from"./app-primitives-BskZ4ZJj.js";var z=e(n(),1),B=r(),V={browser:{name:`通知`,Icon:o},feishu:{name:`飞书`,Icon:s},weixin:{name:`微信`,Icon:f},qq:{name:`QQ`,Icon:f},telegram:{name:`Telegram`,Icon:h}},H={once:`一次`,interval:`每隔一段时间`,daily:`每天`,weekly:`每周`,monthly:`每月`},U={minutes:`分钟`,hours:`小时`,days:`天`},W=[...new Set([`Asia/Hong_Kong`,`UTC`,...typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[]])],G=[`full-access`],K=`mt-4 border-t border-stroke-soft pt-1`,q=`form-grid grid gap-x-3 sm:grid-cols-3`,J=`schedule-interval-input grid grid-cols-[minmax(0,1fr)_minmax(84px,auto)] gap-1.5`,Y=`inline-grid h-8 grid-cols-2 rounded-md border border-stroke bg-chrome p-[3px] max-[650px]:h-auto max-[650px]:w-full pointer-coarse:h-auto`,ce=`inline-flex min-w-0 items-center justify-center rounded-sm border border-transparent px-3 text-sm text-content-secondary transition-colors duration-(--d-fast) hover:text-content aria-pressed:border-key-border aria-pressed:bg-key aria-pressed:font-medium aria-pressed:text-content aria-pressed:shadow-key max-[650px]:h-11 pointer-coarse:h-11`;function le({status:e}){return(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`mt-px grid size-[18px] flex-none place-items-center`,children:(0,B.jsx)(T,{status:e===`running`?`run`:e===`completed`?`done`:`failed`,className:`size-3.5`})})}function ue(e){return e(`schedules:schedulesPage.fullAccessHelp`)}function de(e,t){return t(e===`once`?`schedules:schedulesPage.once`:e===`daily`?`schedules:schedulesPage.daily`:e===`weekly`?`schedules:schedulesPage.weekly`:e===`monthly`?`schedules:schedulesPage.monthly`:`schedules:schedulesPage.atIntervals`)}function fe(e,t){return t(e===`hours`?`schedules:schedulesPage.hours`:e===`days`?`schedules:schedulesPage.days`:`schedules:schedulesPage.minutes`)}function pe(e,t){return t(e===`feishu`?`schedules:schedulesPage.feishu`:e===`weixin`?`schedules:schedulesPage.weChat`:e===`qq`?`schedules:schedulesPage.qq`:e===`telegram`?`schedules:schedulesPage.telegram`:`schedules:schedulesPage.browserNotification`)}function X({value:e,onChange:t}){let{t:n}=i();return(0,B.jsxs)(F,{variant:`control`,children:[n(`schedules:schedulesPage.executionMode`),(0,B.jsx)(I,{value:e,onChange:e=>t(e.target.value),children:G.map(e=>(0,B.jsx)(`option`,{value:e,children:n(`schedules:schedulesPage.fullAccess`)},e))}),(0,B.jsx)(`small`,{children:ue(n)})]})}function Z(e){return Object.fromEntries((e?.inputs||[]).map(e=>[e.name,e.defaultValue??``]))}function Q(e,t,n,r,i){if(e===`prompt`)return!!t.trim();let a=i.find(e=>e.id===n);return a?a.inputs.every(e=>{let t=Object.hasOwn(r,e.name)?r[e.name]:e.defaultValue;return!e.required||t!=null&&t!==``}):!1}function $({targetType:e,prompt:t,workflowId:n,workflowInputs:r,workflows:a,onChange:o}){let{t:s}=i(),c=a.find(e=>e.id===n);return(0,B.jsxs)(`div`,{className:`grid`,children:[(0,B.jsxs)(F,{variant:`control`,children:[s(`schedules:schedulesPage.executionTarget`),(0,B.jsxs)(I,{value:e,onChange:e=>{let t=e.target.value,i=a[0];o(t===`workflow`?{targetType:t,workflowId:n||i?.id||``,workflowInputs:n?r:Z(i)}:{targetType:t})},children:[(0,B.jsx)(`option`,{value:`prompt`,children:`Prompt`}),(0,B.jsx)(`option`,{value:`workflow`,children:s(`schedules:schedulesPage.workflow`)})]})]}),e===`prompt`?(0,B.jsxs)(F,{variant:`control`,children:[`Prompt`,(0,B.jsx)(j,{value:t,onChange:e=>o({prompt:e.target.value}),placeholder:s(`schedules:schedulesPage.describeTheWorkTheAgentShouldCompleteEachTime`)})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(F,{variant:`control`,children:[s(`schedules:schedulesPage.workflow`),(0,B.jsxs)(I,{value:n,onChange:e=>{let t=a.find(t=>t.id===e.target.value);o({workflowId:e.target.value,workflowInputs:Z(t)})},children:[(0,B.jsx)(`option`,{value:``,children:s(`schedules:schedulesPage.selectPublishedWorkflow`)}),a.map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.name,` · v`,e.revision]},e.id))]}),(0,B.jsx)(`small`,{children:c?.description||(a.length?s(`schedules:schedulesPage.workflowUsesItsOwnRuntimeSettings`):s(`schedules:schedulesPage.noPublishedWorkflows`))})]}),c?.inputs.length?(0,B.jsxs)(`div`,{className:`grid`,children:[(0,B.jsxs)(`div`,{className:`schedule-workflow-inputs-heading mt-3 flex items-baseline justify-between gap-3 max-[650px]:flex-col max-[650px]:items-start max-[650px]:gap-0.5 [&_small]:text-xs [&_small]:text-content-muted [&_strong]:text-xs [&_strong]:font-medium [&_strong]:text-content-secondary`,children:[(0,B.jsx)(`strong`,{children:s(`schedules:schedulesPage.workflowInputs`)}),(0,B.jsx)(`small`,{children:s(`schedules:schedulesPage.workflowInputsHelp`)})]}),(0,B.jsx)(`div`,{className:`schedule-workflow-inputs grid gap-x-3 sm:grid-cols-2 [&_input[type=checkbox]]:size-4 [&_input[type=checkbox]]:justify-self-end [&_input[type=checkbox]]:accent-star`,children:c.inputs.map(e=>(0,B.jsxs)(F,{variant:`control`,className:e.type===`boolean`?`grid grid-cols-[minmax(0,1fr)_auto] items-center`:void 0,children:[e.label,e.required?` *`:``,e.type===`boolean`?(0,B.jsx)(y,{checked:!!r[e.name],onCheckedChange:t=>o({workflowInputs:{...r,[e.name]:t}})}):(0,B.jsx)(A,{type:e.type===`number`?`number`:`text`,required:e.required,value:String(r[e.name]??``),onChange:t=>o({workflowInputs:{...r,[e.name]:t.target.value}})}),e.description&&(0,B.jsx)(`small`,{children:e.description})]},e.id))})]}):null]})]})}function me({value:e,onChange:t}){let{t:n}=i(),[r,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(!1),c=async()=>{a(``);try{let r=await M(e,n(`common:workspacePicker.selectWorkspaceForSchedule`));r.status===`picked`?t(r.path):r.status===`unavailable`&&s(!0)}catch(e){a(e instanceof Error?e.message:String(e))}};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(F,{variant:`control`,children:[n(`schedules:schedulesPage.workingDirectory`),(0,B.jsxs)(`span`,{className:`schedule-workspace-input grid grid-cols-[minmax(0,1fr)_auto] gap-1.5 [&_input]:min-w-0 [&_input]:font-mono`,children:[(0,B.jsx)(A,{value:e,onChange:e=>t(e.target.value),placeholder:n(`schedules:schedulesPage.enterTheProjectSAbsolutePath`)}),(0,B.jsxs)(S,{type:`button`,variant:`secondary`,className:`h-auto min-h-8`,onClick:()=>void c(),children:[(0,B.jsx)(d,{}),n(`schedules:schedulesPage.browseDirectories`)]})]}),(0,B.jsx)(`small`,{children:n(`schedules:schedulesPage.theScheduledAgentWillRunInThisDirectory`)})]}),r&&(0,B.jsxs)(L,{children:[(0,B.jsx)(_,{size:13}),r]}),(0,B.jsx)(u,{open:o,initialPath:e,description:n(`common:workspacePicker.selectWorkspaceForSchedule`),onOpenChange:s,onSelect:e=>t(e)})]})}function he(e){return{id:e.id,name:e.name,targetType:e.targetType||`prompt`,prompt:e.prompt,workflowId:e.workflowId||``,workflowInputs:e.workflowInputs||{},enabled:e.enabled,frequency:e.frequency,intervalValue:e.intervalValue||1,intervalUnit:e.intervalUnit||`hours`,time:e.time,date:e.date||``,timezone:e.timezone,dayOfWeek:e.dayOfWeek,dayOfMonth:e.dayOfMonth,cwd:e.cwd,executionMode:e.executionMode||`full-access`,model:e.model,notifications:e.notifications||[],notifyOn:e.notifyOn||`always`}}function ge(e,t=`zh-CN`){return!e.enabled||!e.nextRunAt?t===`en-US`?`Paused`:`已暂停`:new Intl.DateTimeFormat(t,{timeZone:e.timezone,dateStyle:`medium`,timeStyle:`short`}).format(new Date(e.nextRunAt))}function _e({notify:e,onBack:n,openNotificationSettings:r,requestConfirm:o}){let{t:s,language:l}=i(),u=t(),d=C(`focusSearch`),[f,p]=(0,z.useState)({tasks:[],runs:[],notificationTargets:{browser:{enabled:!1},feishu:{enabled:!1},weixin:{enabled:!1},qq:{enabled:!1},telegram:{enabled:!1}},workflows:[],defaultCwd:``}),[h,g]=(0,z.useState)(``),[_,y]=(0,z.useState)({}),[b,x]=(0,z.useState)(!0),[w,E]=(0,z.useState)(!1),[D,O]=(0,z.useState)(``),[ee,k]=(0,z.useState)(!1),[A,j]=(0,z.useState)(``),[M,F]=(0,z.useState)(!1),[I,L]=(0,z.useState)(``),R=(0,z.useCallback)(async()=>{try{let e=await a(`/api/schedules`);p(e),E(!0),O(``),g(t=>e.tasks.some(e=>e.id===t)?t:``),y(t=>{let n=Object.entries(t).filter(([t])=>e.tasks.some(e=>e.id===t));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})}catch(e){O(e instanceof Error?e.message:String(e))}finally{x(!1)}},[]);(0,z.useEffect)(()=>{R()},[R]),(0,z.useEffect)(()=>{let e=window.setInterval(R,f.tasks.some(e=>e.lastStatus===`running`)?2e3:1e4);return()=>window.clearInterval(e)},[f.tasks,R]);let V=f.tasks.find(e=>e.id===h),H=f.workflows||[],U=V?_[V.id]??he(V):null,W=(0,z.useMemo)(()=>f.runs.filter(e=>e.taskId===h).sort((e,t)=>new Date(t.startedAt).getTime()-new Date(e.startedAt).getTime()).slice(0,20),[f.runs,h]),G=e=>H.find(t=>t.id===e.workflowId)?.name||s(`schedules:schedulesPage.workflowUnavailable`),K=I.trim().toLocaleLowerCase(),q=K?f.tasks.filter(e=>`${e.name} ${e.targetType===`workflow`?G(e):e.targetType===`bot`?e.botMessage||``:e.prompt}`.toLocaleLowerCase().includes(K)):f.tasks,J=f.tasks.filter(e=>e.enabled).length,Y=e=>{if(!V)return;let t=he(V);y(n=>({...n,[t.id]:{...n[t.id]??t,...e}}))},ce=e=>{U&&Y({notifications:U.notifications.includes(e)?U.notifications.filter(t=>t!==e):[...U.notifications,e]})},le=async()=>{if(!(!V||!U)){k(!0),j(``);try{let t=await a(`/api/schedules/${encodeURIComponent(V.id)}`,{method:`PATCH`,body:JSON.stringify(U)});p(t.state),y(e=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t.task.id))),e(s(`schedules:schedulesPage.scheduledTaskSaved`))}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}}},ue=async()=>{if(V){k(!0),j(``);try{await a(`/api/schedules/${encodeURIComponent(V.id)}/run`,{method:`POST`,body:`{}`}),await R(),e(s(`schedules:schedulesPage.scheduledTaskStarted`))}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}}},pe=async()=>{if(V&&await o({title:s(`schedules:schedulesPage.deleteScheduledTask`),message:s(`schedules:schedulesPage.deleteScheduledTaskNameAndItsRunHistory`,{name:V.name}),confirmLabel:s(`schedules:schedulesPage.delete`)}))try{await a(`/api/schedules/${encodeURIComponent(V.id)}`,{method:`DELETE`}),await R(),e(s(`schedules:schedulesPage.scheduledTaskDeleted`))}catch(e){j(e instanceof Error?e.message:String(e))}},X=t=>{p(t.state),g(t.task.id),e(s(`schedules:schedulesPage.scheduledTaskCreated`))},Z=e=>(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col items-end gap-0.5 max-[650px]:flex-row max-[650px]:items-center max-[650px]:gap-2`,children:[e.lastStatus===`running`?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,B.jsx)(T,{status:`run`,className:`size-3.5`}),s(`schedules:schedulesPage.running`)]}):(0,B.jsx)(`span`,{className:`whitespace-nowrap`,children:e.enabled?s(`schedules:schedulesPage.nextRunTime`,{time:ge(e,l)}):e.lastStatus===`missed`?s(`schedules:schedulesPage.missed`):e.frequency===`once`&&e.lastRunAt?s(`schedules:schedulesPage.onceDone`):s(`schedules:schedulesPage.pause`)}),e.lastStatus===`failed`&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,B.jsx)(T,{status:`failed`,className:`size-3.5`}),s(`schedules:schedulesPage.lastRunFailed`)]})]}),Q=s(`navigation:navigation.schedules`);return(0,B.jsxs)(ae,{title:Q,description:s(`schedules:schedulesPage.lede`),back:n&&{label:s(`navigation:sidebar.features`),ariaLabel:s(`navigation:shell.backToFeaturesLabel`),onBack:n},toolbar:(0,B.jsx)(oe,{search:(0,B.jsx)(te,{id:v,value:I,onValueChange:L,placeholder:s(`navigation:pageHeader.searchPage`,{page:Q}),shortcut:d,clearLabel:s(`navigation:more.clearSearch`)}),actions:(0,B.jsxs)(S,{type:`button`,className:`h-9`,disabled:!w,onClick:()=>F(!0),children:[(0,B.jsx)(m,{}),s(`schedules:schedulesPage.newTask`)]})}),children:[b?(0,B.jsx)(N,{kind:`loading`,title:s(`schedules:schedulesPage.loadingScheduledTasks`)}):D&&!w?(0,B.jsx)(N,{kind:`error`,title:s(`schedules:schedulesPage.loadFailed`),description:D,action:(0,B.jsx)(S,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>{x(!0),R()},children:s(`common:pageTemplate.retry`)})}):(0,B.jsxs)(B.Fragment,{children:[(A||D)&&(0,B.jsx)(se,{children:A||D}),(0,B.jsx)(ie,{title:s(`schedules:schedulesPage.tasks`),count:f.tasks.length,meta:f.tasks.length?s(`schedules:schedulesPage.enabledCount`,{count:J}):void 0,children:q.length?(0,B.jsx)(re,{children:q.map(e=>{let t=h===e.id;return(0,B.jsx)(ne,{"data-schedule-task":e.id,className:`schedule-list-item`,icon:(0,B.jsx)(c,{}),name:e.name,description:e.targetType===`workflow`?(0,B.jsx)(`span`,{className:`font-mono`,children:G(e)}):e.targetType===`bot`?s(`schedules:schedulesPage.botTarget`,{message:e.botMessage||``}):e.prompt,meta:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{children:de(e.frequency,s)}),(0,B.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,B.jsx)(`span`,{className:`tabular-nums`,children:e.frequency===`interval`?`${e.intervalValue} ${fe(e.intervalUnit,s)}`:e.frequency===`once`?`${e.date} ${e.time}`:e.time}),(0,B.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.timezone}),e.createdBy?.kind===`agent`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,B.jsx)(`span`,{"data-schedule-created-by":`agent`,children:s(`schedules:schedulesPage.createdByAgent`)})]})]}),status:Z(e),expanded:t,onExpandedChange:t=>g(t?e.id:``),toggleLabel:s(`schedules:schedulesPage.toggleTaskDetails`,{name:e.name}),detail:t&&e.targetType===`bot`?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm text-content-secondary`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1`,children:s(`schedules:schedulesPage.botManagedThere`)}),(0,B.jsx)(S,{size:`sm`,variant:`outline`,onClick:()=>u(`/bots/${encodeURIComponent(e.botId||``)}`),children:s(`schedules:schedulesPage.openBot`)})]}):t&&U&&V?(0,B.jsx)(ve,{task:V,draft:U,runs:W,saving:ee,workflows:H,notificationTargets:f.notificationTargets,language:l,onUpdate:Y,onToggleNotification:ce,onRun:ue,onRemove:pe,onSave:le,onEditTemplates:r}):null},e.id)})}):(0,B.jsx)(P,{title:f.tasks.length?s(`schedules:schedulesPage.noMatchingTasks`):s(`schedules:schedulesPage.theTimelineIsStillUnlit`),description:f.tasks.length?void 0:s(`schedules:schedulesPage.createATaskAndLetItSetOutAutomaticallyAtTheAppointedTime`)})})]}),M&&(0,B.jsx)(ye,{notificationTargets:f.notificationTargets,workflows:H,defaultCwd:f.defaultCwd,onClose:()=>F(!1),onCreated:e=>{F(!1),X(e)}})]})}function ve({task:e,draft:t,runs:n,saving:r,workflows:a,notificationTargets:o,language:s,onUpdate:c,onToggleNotification:u,onRun:d,onRemove:f,onSave:m,onEditTemplates:h}){let{t:_}=i(),v=e.lastStatus===`running`;return(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`label`,{className:`mr-auto inline-flex min-h-8 items-center gap-2.5 text-sm text-content max-[650px]:min-h-11`,children:[(0,B.jsx)(R,{value:t.enabled,onChange:e=>c({enabled:e}),ariaLabel:_(`schedules:schedulesPage.enableTaskName`,{name:t.name})}),t.enabled?_(`schedules:schedulesPage.enabled`):_(`schedules:schedulesPage.pause`)]}),(0,B.jsxs)(S,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,disabled:r||v,onClick:d,children:[v?(0,B.jsx)(x,{}):(0,B.jsx)(p,{}),_(v?`schedules:schedulesPage.running`:`schedules:schedulesPage.runNow`)]}),(0,B.jsx)(S,{variant:`ghost`,size:`icon-sm`,className:`hover:bg-danger-soft hover:text-danger max-[650px]:size-11`,title:_(`schedules:schedulesPage.deleteTask`),"aria-label":_(`schedules:schedulesPage.deleteTask`),onClick:f,children:(0,B.jsx)(g,{})})]}),(0,B.jsx)($,{targetType:t.targetType,prompt:t.prompt,workflowId:t.workflowId,workflowInputs:t.workflowInputs,workflows:a,onChange:c}),t.targetType===`prompt`&&(0,B.jsx)(me,{value:t.cwd,onChange:e=>c({cwd:e})}),(0,B.jsx)(`div`,{className:K,children:(0,B.jsxs)(`div`,{className:q,children:[(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.frequency`),(0,B.jsx)(I,{value:t.frequency,onChange:e=>c({frequency:e.target.value}),children:Object.keys(H).map(e=>(0,B.jsx)(`option`,{value:e,children:de(e,_)},e))})]}),t.frequency===`interval`?(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.runInterval`),(0,B.jsxs)(`span`,{className:J,children:[(0,B.jsx)(A,{type:`number`,min:`1`,value:t.intervalValue,onChange:e=>c({intervalValue:Number(e.target.value)})}),(0,B.jsx)(I,{value:t.intervalUnit,onChange:e=>c({intervalUnit:e.target.value}),children:Object.keys(U).map(e=>(0,B.jsx)(`option`,{value:e,children:fe(e,_)},e))})]})]}):(0,B.jsxs)(B.Fragment,{children:[t.frequency===`once`&&(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.date`),(0,B.jsx)(A,{type:`date`,className:`tabular-nums`,value:t.date,onChange:e=>c({date:e.target.value})})]}),(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.time`),(0,B.jsx)(A,{type:`time`,className:`tabular-nums`,value:t.time,onChange:e=>c({time:e.target.value})})]})]}),(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.timeZone`),(0,B.jsx)(I,{value:t.timezone,onChange:e=>c({timezone:e.target.value}),children:W.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))})]}),t.targetType===`prompt`&&(0,B.jsx)(X,{value:t.executionMode,onChange:e=>c({executionMode:e})})]})}),(0,B.jsxs)(`div`,{className:b(`schedule-notification-section pt-3`,K),children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(`strong`,{className:`text-sm font-medium`,children:_(`schedules:schedulesPage.notificationChannels`)}),(0,B.jsx)(`button`,{type:`button`,className:`text-button text-xs font-medium text-content-secondary underline underline-offset-2 hover:text-content max-[650px]:min-h-11`,onClick:h,children:_(`schedules:schedulesPage.editTemplates`)})]}),(0,B.jsx)(`p`,{className:`mt-0.5 text-xs text-content-muted`,children:_(`schedules:schedulesPage.notificationChannelsHelp`)}),(0,B.jsx)(`div`,{className:`schedule-notification-targets mt-2.5 grid grid-cols-[repeat(auto-fill,minmax(132px,1fr))] gap-2`,children:Object.entries(V).map(([e,n])=>{let r=n.Icon,i=t.notifications.includes(e);return(0,B.jsxs)(`button`,{type:`button`,"aria-pressed":i,className:b(`grid min-h-[52px] grid-cols-[16px_minmax(0,1fr)_16px] items-center gap-2 rounded-md border px-2.5 py-2 text-left transition-colors duration-(--d-fast)`,i?`selected border-star-border bg-star-soft text-star-strong`:`border-stroke bg-panel text-content hover:bg-surface-subtle`),onClick:()=>u(e),children:[(0,B.jsx)(r,{className:`size-4`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,B.jsx)(`strong`,{className:`truncate text-sm font-medium`,children:pe(e,_)}),(0,B.jsx)(`small`,{className:`truncate text-xs text-content-muted`,children:o[e].enabled?_(`schedules:schedulesPage.configured`):_(`schedules:schedulesPage.notConfigured`)})]}),(0,B.jsx)(l,{className:b(`size-4`,i?`text-star-strong`:`text-content-faint`)})]},e)})}),(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,B.jsx)(`span`,{id:`schedule-notify-on-${e.id}`,className:`text-xs text-content-muted`,children:_(`schedules:schedulesPage.notifyWhen`)}),(0,B.jsx)(`div`,{role:`group`,"aria-labelledby":`schedule-notify-on-${e.id}`,className:b(`schedule-notification-chip`,Y),children:[`always`,`failure`].map(e=>(0,B.jsx)(`button`,{type:`button`,"aria-pressed":t.notifyOn===e,className:ce,onClick:()=>c({notifyOn:e}),children:_(e===`failure`?`schedules:schedulesPage.failuresOnly`:`schedules:schedulesPage.completionAndFailure`)},e))})]})]}),(0,B.jsxs)(`div`,{className:`form-footer mt-4 flex items-center justify-between gap-2.5 border-t border-stroke-soft pt-3 max-[650px]:flex-wrap`,children:[(0,B.jsx)(`span`,{className:`text-xs text-content-muted tabular-nums`,children:e.lastRunAt?_(`schedules:schedulesPage.lastRunTime`,{time:w(e.lastRunAt,s)}):_(`schedules:schedulesPage.nextRunTime`,{time:ge(e,s)})}),(0,B.jsxs)(S,{className:`max-[650px]:h-11 max-[650px]:w-full`,disabled:r||!Q(t.targetType,t.prompt,t.workflowId,t.workflowInputs,a),onClick:m,children:[r?(0,B.jsx)(x,{className:`text-current`}):null,_(r?`schedules:schedulesPage.saving`:`schedules:schedulesPage.saveTask`)]})]})]}),(0,B.jsxs)(`section`,{"aria-labelledby":`schedule-runs-${e.id}`,className:`min-w-0`,children:[(0,B.jsxs)(`h3`,{id:`schedule-runs-${e.id}`,className:`mb-1.5 text-[13px] font-medium text-content-muted tabular-nums`,children:[_(`schedules:schedulesPage.recentRuns`),` · `,n.length]}),n.length?(0,B.jsx)(`ul`,{className:`divide-y divide-stroke-soft overflow-hidden rounded-[var(--r-md)] border border-stroke`,children:n.map(e=>(0,B.jsxs)(`li`,{className:`schedule-run-row grid min-h-11 grid-cols-[18px_minmax(0,1fr)_auto] items-start gap-2.5 px-3 py-2.5 ${e.status}`,children:[(0,B.jsx)(le,{status:e.status}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,B.jsx)(`strong`,{className:`line-clamp-2 text-sm leading-5 font-medium text-content`,children:e.status===`running`?_(`schedules:schedulesPage.running2`):e.status===`completed`?e.summary||_(`schedules:schedulesPage.taskCompleted`):e.status===`interrupted`?_(`schedules:schedulesPage.taskInterrupted`):e.error||_(`schedules:schedulesPage.taskFailed`)}),(0,B.jsxs)(`small`,{className:`text-xs text-content-muted tabular-nums`,children:[w(e.startedAt,s),` ·`,` `,e.trigger===`manual`?_(`schedules:schedulesPage.manualRun`):_(`schedules:schedulesPage.scheduledTrigger`),e.durationMs?` · ${_(`schedules:schedulesPage.countSec`,{count:Math.round(e.durationMs/1e3)})}`:``]})]}),(0,B.jsx)(`em`,{className:`font-mono text-xs leading-5 text-content-secondary not-italic tabular-nums`,children:new Intl.DateTimeFormat(s,{hour:`2-digit`,minute:`2-digit`}).format(new Date(e.startedAt))})]},e.id))}):(0,B.jsx)(P,{compact:!0,title:_(`schedules:schedulesPage.noRunHistory`)})]})]})}function ye({notificationTargets:e,workflows:t,defaultCwd:n,onClose:r,onCreated:o}){let{t:s}=i(),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(`prompt`),[f,p]=(0,z.useState)(``),[h,g]=(0,z.useState)(``),[v,y]=(0,z.useState)({}),[b,C]=(0,z.useState)(n||``),[w,T]=(0,z.useState)(`full-access`),[j,M]=(0,z.useState)(!1),[N,P]=(0,z.useState)(``);return(0,B.jsx)(k,{open:!0,onOpenChange:e=>!e&&r(),children:(0,B.jsx)(D,{size:`compact`,children:(0,B.jsxs)(`form`,{className:`grid min-w-0`,onSubmit:async t=>{t.preventDefault(),M(!0),P(``);try{let t=Object.entries(e).filter(([,e])=>e.enabled).map(([e])=>e);o(await a(`/api/schedules`,{method:`POST`,body:JSON.stringify({name:c,targetType:u,prompt:f,workflowId:h,workflowInputs:v,cwd:b,enabled:!0,frequency:`daily`,time:`09:00`,timezone:`Asia/Hong_Kong`,executionMode:w,notifications:t,notifyOn:`always`})}))}catch(e){P(e instanceof Error?e.message:String(e))}finally{M(!1)}},children:[(0,B.jsxs)(ee,{children:[(0,B.jsx)(O,{children:s(`schedules:schedulesPage.newScheduledTask`)}),(0,B.jsx)(E,{children:s(`schedules:schedulesPage.youCanContinueSettingTheRunTimeAndNotificationChannelsAfterCreation`)})]}),(0,B.jsxs)(F,{variant:`control`,children:[s(`schedules:schedulesPage.taskName`),(0,B.jsx)(A,{value:c,onChange:e=>l(e.target.value),placeholder:s(`schedules:schedulesPage.forExampleDailyCodeReview`)})]}),(0,B.jsx)($,{targetType:u,prompt:f,workflowId:h,workflowInputs:v,workflows:t,onChange:e=>{e.targetType&&d(e.targetType),e.prompt!==void 0&&p(e.prompt),e.workflowId!==void 0&&g(e.workflowId),e.workflowInputs!==void 0&&y(e.workflowInputs)}}),u===`prompt`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(me,{value:b,onChange:C}),(0,B.jsx)(X,{value:w,onChange:T})]}),N&&(0,B.jsxs)(L,{children:[(0,B.jsx)(_,{size:13}),N]}),(0,B.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2 max-[650px]:[&>button]:h-11 max-[650px]:[&>button]:flex-1`,children:[(0,B.jsx)(S,{type:`button`,variant:`secondary`,onClick:r,children:s(`schedules:schedulesPage.cancel`)}),(0,B.jsxs)(S,{type:`submit`,disabled:j||!c.trim()||!Q(u,f,h,v,t),children:[j?(0,B.jsx)(x,{className:`text-current`}):(0,B.jsx)(m,{}),s(j?`schedules:schedulesPage.creating`:`schedules:schedulesPage.createTask`)]})]})]})})})}export{_e as SchedulesPage};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitDiffViewer-D6X8UoVx.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-DwNgTV1j.js","assets/use-i18n-47vsdOU3.js","assets/i18n-CHUj56MI.js","assets/vendor-router-CSN_DGvx.js","assets/index-Dw3Kz26s.js","assets/index-j6s460ui.css","assets/storage-DtvZ_lEu.js","assets/vendor-state-GkUciC5H.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/x-07u4-129.js","assets/utils-C8uzG5AZ.js","assets/vendor-ui-DvrYggeS.js","assets/button-CCcCN8tE.js","assets/dist-41X0pdUs.js","assets/events-BgoXNekW.js","assets/esm-DCV8yILT.js","assets/TaskTerminalView-Bj9xJWSN.js","assets/square-terminal-BVG6cUT1.js","assets/square-bHHVTT3G.js","assets/PageState-Cz6vFMXv.js","assets/AppSelect-B15Hpk2W.js","assets/use-mobile-C2tPBAza.js","assets/select-DyBoNnz-.js","assets/check-2vYc6QaP.js","assets/chevron-down-CxtxIjiP.js","assets/chevron-up-D_ZcXjqr.js","assets/chevrons-up-down-C2sEPdAh.js","assets/dist-BsRXXcSL.js","assets/dist-BiRPwy4W.js","assets/dist-DzGQ7sLi.js","assets/es2015-DTZdOI9P.js","assets/dist-BRjj4UeB.js","assets/dist-OB2r6Xsr.js","assets/dist-BS3ekNDj.js","assets/terminal-context-aIsIJPn8.js","assets/TaskTerminalView-BrP-ENHg.css","assets/TaskProcessesPane-Cjti3REL.js","assets/chevron-right-C3t2Rckj.js","assets/checkbox-BrEHgFV0.js","assets/FileAttachmentPreview-LLowX6R-.js","assets/api-DMqZSAib.js","assets/abort-signal-f4JsiYKX.js","assets/http-response-BHt8SJKV.js","assets/event-stream-CuxX_nc8.js","assets/http-D4AhfBV1.js","assets/download-BCfIiuaL.js","assets/file-Bllajneu.js","assets/refresh-cw-TbWxTY4K.js","assets/tabs-DsgBuvJv.js","assets/dist-BaBySQmo.js","assets/format-DMJQzoZ7.js","assets/dialog-nax_z9Og.js","assets/dist-BHkR6BLP.js","assets/MarkdownMessage-COsYrsCd.js","assets/vendor-markdown-plugins-CT5L3KA9.js","assets/vendor-shiki-runtime-DM7fm4Bl.js","assets/vendor-markdown-plugins-DEcVZfaU.css","assets/vendor-markdown-CT6Z4fh8.js","assets/copy-DHmIFc52.js","assets/route-context-DvWDul4T.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t}from"./vendor-router-CSN_DGvx.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{t as i}from"./use-i18n-47vsdOU3.js";import{o as a}from"./vendor-state-GkUciC5H.js";import{t as o}from"./useQuery-DfOU-27z.js";import{t as s}from"./createLucideIcon-Cd-3GVxJ.js";import{t as c}from"./arrow-left-B8oVrQ2S.js";import{t as l}from"./arrow-right-DqLOhpA2.js";import{t as u}from"./arrow-up-DST6-qVQ.js";import{t as d}from"./check-2vYc6QaP.js";import{t as f}from"./chevron-down-CxtxIjiP.js";import{t as p}from"./chevron-right-C3t2Rckj.js";import{t as m}from"./download-BCfIiuaL.js";import{t as h}from"./earth-Ddy13fHh.js";import{t as g}from"./external-link-CEQqPcqc.js";import{a as _}from"./GitDiffViewer-D6X8UoVx.js";import{t as v}from"./file-Bllajneu.js";import{a as y,c as b,i as ee,o as x,r as S,s as C,y as w}from"./side-chat-context-D9g8NFwu.js";import{t as T}from"./git-branch-N7LGjtzt.js";import{y as E}from"./ChatMessage-CrCe2TLj.js";import{t as D}from"./image-BY_c3FYU.js";import{t as O}from"./link-2-mgasYn21.js";import{t as k}from"./loader-circle-BOwQzHB-.js";import{t as te}from"./message-square-SKjZyY3v.js";import{t as A}from"./pause-CYWpPg1R.js";import{t as j}from"./refresh-cw-TbWxTY4K.js";import{t as M}from"./rotate-ccw-clock-CO6Bw-sF.js";import{t as ne}from"./square-bHHVTT3G.js";import{t as N}from"./trash-2-CNrPOoPR.js";import{t as re}from"./triangle-alert-CE1q54ci.js";import"./collapsible-B-fc7n0u.js";import{a as ie,c as ae,i as oe,n as se,o as ce,r as le,s as ue,t as de}from"./alert-dialog-DiUitBB0.js";import{a as fe,r as pe,t as me}from"./popover-2hW0lH2e.js";import"./tooltip-D4MFbqcG.js";import{t as P}from"./utils-C8uzG5AZ.js";import{n as F,t as I}from"./button-CCcCN8tE.js";import{c as he,r as ge}from"./shortcuts-lvsdkhJa.js";import{t as L}from"./chat-api-CbddSAiB.js";import{a as _e,i as ve,n as ye,o as be,r as xe,t as Se}from"./command-BLb6loUF.js";import{t as R}from"./input-CPw-zkYh.js";import{n as Ce}from"./session-change-summary-api-zrzUcWPa.js";import{n as we,t as z}from"./PageState-Cz6vFMXv.js";import{n as Te,t as Ee}from"./alert-DRIrgNI4.js";import{t as De}from"./AppSelect-B15Hpk2W.js";import{o as B}from"./session-tree-summary-Bjg79Vc5.js";import{a as V,i as H,o as Oe,s as ke,t as Ae}from"./session-web-preview-BUv0rBHy.js";import{i as je,n as Me,r as U,t as Ne}from"./web-preview-C7DdG9JP.js";import{n as Pe}from"./useNativeBrowser-C0j3zafh.js";var Fe=s(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ie=s(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),W=s(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Le=s(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),G=e(n(),1),K=r(),Re={completed:`completed`,in_progress:`running`,paused:`pending`,blocked:`blocked`,pending:`pending`};function ze(e){let t=new Map(e.map(e=>[String(e.id||``),e])),n=e=>e?.status===`completed`;return e.map(e=>{let r=String(e.id||``),i=(Array.isArray(e.dependsOn)?e.dependsOn:[]).map(e=>t.get(String(e))).filter(e=>!!e&&!n(e)),a=e.status!==`completed`&&(e.status===`blocked`||i.length>0);return{...e,id:r,blocked:a,blockedBy:i}})}function Be({status:e,t}){let n=t(e===`completed`?`chat:planBoard.completed`:e===`in_progress`?`chat:planBoard.inProgress`:e===`paused`?`chat:planBoard.paused`:e===`blocked`?`chat:planBoard.blocked`:`chat:planBoard.pending`);return(0,K.jsxs)(`span`,{className:`plan-board-status grid size-[18px] flex-none place-items-center rounded-xs text-content-muted [&.completed]:bg-success-soft [&.completed]:text-success [&.running]:text-accent-fg [&.blocked]:bg-danger-soft [&.blocked]:text-danger ${Re[String(e)]||`pending`}`,title:n,children:[e===`completed`?(0,K.jsx)(d,{size:12,strokeWidth:2.25}):e===`in_progress`?(0,K.jsx)(F,{className:`size-3.5`}):e===`paused`?(0,K.jsx)(A,{size:11,strokeWidth:2}):e===`blocked`?(0,K.jsx)(W,{size:11,strokeWidth:2}):(0,K.jsx)(Fe,{size:11,strokeWidth:2}),(0,K.jsx)(`span`,{className:`sr-only`,children:n})]})}function Ve({item:e,current:t,running:n,t:r}){return(0,K.jsxs)(`li`,{className:`plan-board-row flex min-w-0 flex-col gap-[2px] rounded-sm px-[6px] py-[6px] aria-[current=step]:bg-surface-subtle ${e.blocked?`blocked`:``}`,"aria-current":t?`step`:void 0,"data-pisper-plan-current":t?`true`:void 0,"data-pisper-plan-id":e.id,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[10px]`,children:[(0,K.jsx)(Be,{status:e.blocked?`blocked`:e.status===`in_progress`&&!n?`paused`:e.status,t:r}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] ${e.status===`completed`?`text-content-muted`:`text-foreground`}`,title:e.title,children:e.title}),e.assignee?(0,K.jsxs)(`span`,{className:`inline-flex max-w-[40%] flex-none items-center gap-[4px] truncate rounded-xs border border-stroke px-[6px] font-mono text-[12px] leading-[18px] text-content-secondary`,title:r(`chat:planBoard.assignedTo`,{name:e.assignee}),children:[(0,K.jsx)(w,{size:11,className:`flex-none`}),e.assignee]}):e.status!==`completed`&&(0,K.jsx)(`span`,{className:`flex-none text-[12px] text-content-muted`,children:r(`chat:planBoard.unassigned`)})]}),e.blockedBy.length>0&&(0,K.jsxs)(`div`,{className:`inline-flex min-w-0 items-center gap-[5px] pl-[28px] text-[12px] text-content-muted`,children:[(0,K.jsx)(W,{size:11,className:`flex-none`}),(0,K.jsx)(`span`,{className:`truncate`,children:r(`chat:planBoard.waitingFor`,{tasks:e.blockedBy.map(e=>e.title||e.id).join(` · `)})})]})]})}function He({plan:e,running:t,header:n,collapsible:r=!1}){let{t:a}=i(),o=(0,G.useRef)(null),[s,c]=(0,G.useState)(!0),l=e?.items||[],u=ze(l),d=u.filter(e=>e.status===`completed`).length,p=u.filter(e=>e.status===`in_progress`&&!e.blocked).length,m=u.filter(e=>e.blocked).length,h=u.find(e=>e.status===`in_progress`&&!e.blocked)?.id??u.find(e=>e.blocked)?.id??u.find(e=>e.status===`pending`)?.id??u.at(-1)?.id;if((0,G.useLayoutEffect)(()=>{if(r&&!s)return;let e=o.current,t=e?.querySelector(`[data-pisper-plan-current="true"]`);if(!e||!t)return;let n=e.getBoundingClientRect(),i=t.getBoundingClientRect();i.top<n.top?e.scrollTop-=n.top-i.top:i.bottom>n.bottom&&(e.scrollTop+=i.bottom-n.bottom)},[r,h,s,u.length]),!l.length)return null;let g=u.find(e=>e.id===h),_=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ie,{className:`flex-none text-content-muted`,size:15}),(0,K.jsx)(`strong`,{className:`tabular-nums`,children:a(`chat:planBoard.progress`,{completed:d,total:l.length})}),g?(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-content-secondary`,title:g.title,children:g.title}):null,(0,K.jsxs)(`span`,{className:`plan-board-counts inline-flex flex-none items-center gap-[8px] text-content-muted tabular-nums @max-[470px]:hidden`,children:[p>0&&(0,K.jsx)(`span`,{children:a(t?`chat:planBoard.countInProgress`:`chat:planBoard.countPaused`,{count:p})}),m>0&&(0,K.jsx)(`span`,{className:`blocked text-danger`,children:a(`chat:planBoard.countBlocked`,{count:m})})]}),n,r?(0,K.jsx)(f,{className:`plan-board-chevron flex-none text-content-muted transition-transform duration-(--d-fast) ease-precise [.plan-board-collapsible[open]_&]:rotate-180`,size:15}):null]}),v=(0,K.jsx)(`ul`,{ref:o,className:`plan-board-list [.plan-board-collapsible_>_&]:border-t [.plan-board-collapsible_>_&]:border-stroke-soft [.plan-board-collapsible_>_&]:p-[6px_8px_8px] m-0 flex list-none flex-col gap-[1px] pt-[6px]${u.length>4?` is-scrollable [.session-plan-popover_.plan-board-list&]:[block-size:min(250px,38dvh)] [.plan-board-list&]:[block-size:min(220px,34dvh)] [.plan-board-list&]:overflow-y-auto [.plan-board-list&]:[overscroll-behavior:contain] [.plan-board-list&]:pr-[4px] [.plan-board-list&]:[scrollbar-gutter:stable] [.plan-board-list&:focus-visible]:outline-2 [.plan-board-list&:focus-visible]:outline-focus [.plan-board-list&:focus-visible]:outline-offset-2`:``}`,tabIndex:u.length>4?0:void 0,children:u.map(e=>(0,K.jsx)(Ve,{running:t,item:e,current:e.id===h,t:a},e.id))});return r?(0,K.jsxs)(`details`,{className:`plan-board plan-board-collapsible m-[0_auto] flex w-[min(900px,100%)] flex-col overflow-hidden rounded-md border border-stroke bg-panel !p-0 [.session-plan-popover_&]:w-full [.session-plan-popover_&]:border-0 [.session-plan-popover_&]:bg-transparent`,open:s,onToggle:e=>c(e.currentTarget.open),children:[(0,K.jsx)(`summary`,{className:`plan-board-summary flex min-w-0 items-center gap-[8px] border-b border-stroke-soft pb-[8px] text-[13px] text-content-secondary [&_strong]:flex-none [&_strong]:font-medium [&_strong]:text-foreground [.plan-board-collapsible_>_&]:min-h-[34px] [.plan-board-collapsible_>_&]:cursor-pointer [.plan-board-collapsible_>_&]:list-none [.plan-board-collapsible_>_&]:border-0 [.plan-board-collapsible_>_&]:p-[6px_12px] max-[650px]:[.plan-board-collapsible_>_&]:min-h-11 [.plan-board-collapsible_>_&::-webkit-details-marker]:hidden [.plan-board-collapsible_>_&:hover]:bg-surface-subtle [.plan-board-collapsible_>_&:focus-visible]:outline-2 [.plan-board-collapsible_>_&:focus-visible]:-outline-offset-2 [.plan-board-collapsible_>_&:focus-visible]:outline-focus`,"aria-label":a(`chat:planBoard.toggleAriaLabel`),children:_}),v]}):(0,K.jsxs)(`section`,{className:`plan-board m-[0_auto] flex w-[min(900px,100%)] flex-col rounded-md border border-stroke bg-panel p-[10px_12px] [.session-plan-popover_&]:w-full [.session-plan-popover_&]:border-0 [.session-plan-popover_&]:bg-transparent [.session-plan-popover_&]:p-0`,"aria-label":a(`chat:planBoard.ariaLabel`),children:[(0,K.jsx)(`div`,{className:`plan-board-summary flex min-w-0 items-center gap-[8px] border-b border-stroke-soft pb-[8px] text-[13px] text-content-secondary [&_strong]:flex-none [&_strong]:font-medium [&_strong]:text-foreground [.plan-board-collapsible_>_&]:min-h-[34px] [.plan-board-collapsible_>_&]:cursor-pointer [.plan-board-collapsible_>_&]:list-none [.plan-board-collapsible_>_&]:border-0 [.plan-board-collapsible_>_&]:p-[6px_12px] max-[650px]:[.plan-board-collapsible_>_&]:min-h-11 [.plan-board-collapsible_>_&::-webkit-details-marker]:hidden [.plan-board-collapsible_>_&:hover]:bg-surface-subtle [.plan-board-collapsible_>_&:focus-visible]:outline-2 [.plan-board-collapsible_>_&:focus-visible]:-outline-offset-2 [.plan-board-collapsible_>_&:focus-visible]:outline-focus`,children:_}),v]})}var Ue=(0,G.memo)(He),We=(0,G.lazy)(()=>t(()=>import(`./GitDiffViewer-D6X8UoVx.js`).then(e=>e.n).then(e=>({default:e.InlineGitDiff})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])));function q({sessionId:e,path:t,scope:n,revision:r=0,position:a,onReading:s,mode:c,fill:l=!1}){let{t:u}=i(),d=o({queryKey:[`task-file-diff`,e,n,t,r],queryFn:({signal:r})=>n===`project`?L.getFileDiff(e,t,{signal:r}):L.getSessionFileChangeDiff(e,t,{signal:r})});return d.isPending?(0,K.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 px-3 py-2.5 text-xs text-content-muted`,children:[(0,K.jsx)(F,{className:`size-3.5`}),u(`chat:focusSession.gitLoading`)]}):d.isError?(0,K.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,K.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:d.error.message}),(0,K.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>void d.refetch(),children:u(`chat:chatMessage.filePreviewRetry`)})]}):(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(We,{position:a,onReading:s,diff:d.data.diff,truncated:d.data.diffTruncated,mode:c,fill:l})})}function Ge({sessionId:e,cwd:t,streaming:n,view:r,onViewChange:a}){let{t:s}=i(),c=o({queryKey:[`task-project-changes`,e,t,n],queryFn:({signal:t})=>L.getVcsChanges(e,{signal:t})}),l=_(r.reading?.list,e=>a({reading:{...r.reading,list:e}})),u=(0,G.useMemo)(()=>C(c.data?.diff||``,c.data?.files.map(e=>e.path)||[],c.data?.diffTruncated),[c.data]),d=r.expandedFiles.filter(e=>c.data&&!c.data.files.some(t=>t.path===e)),f=c.error?.message||c.data?.error,m=c.data?.files||[];return(0,K.jsxs)(`section`,{"aria-label":s(`chat:workbench.projectChanges`),className:`flex min-h-0 flex-1 flex-col`,children:[(0,K.jsxs)(`header`,{className:`flex min-h-10 min-w-0 shrink-0 items-center gap-2 border-b border-stroke-soft pr-1.5 pl-3`,children:[(0,K.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-xs font-medium tracking-[.02em] text-content-muted`,children:s(`chat:workbench.projectChanges`)}),c.data?.isRepo&&!f&&(0,K.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums`,children:[(0,K.jsxs)(`span`,{className:`text-success`,children:[`+`,u.added]}),` `,(0,K.jsxs)(`span`,{className:`text-danger`,children:[`−`,u.removed]})]}),(0,K.jsx)(I,{variant:`ghost`,size:`icon`,className:`max-[650px]:size-11`,"aria-label":s(`chat:focusSession.gitRefresh`),disabled:c.isFetching,onClick:()=>void c.refetch(),children:(0,K.jsx)(j,{size:15,className:c.isFetching?`animate-spin`:void 0})})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-stroke-soft px-3 py-2.5`,children:[(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:s(`chat:workbench.projectScope`)}),(0,K.jsxs)(`p`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,title:t,children:[c.data?.branch&&(0,K.jsxs)(`span`,{className:`inline-flex h-5.5 max-w-[45%] shrink-0 items-center gap-1 rounded-xs border border-stroke px-1.5 font-mono text-content-secondary`,children:[(0,K.jsx)(T,{size:12,className:`shrink-0`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`truncate`,children:c.data.branch})]}),(0,K.jsx)(`span`,{className:`min-w-0 truncate font-mono text-content-muted`,children:t})]}),(0,K.jsxs)(`div`,{className:`flex gap-1`,children:[(0,K.jsx)(I,{variant:`ghost`,size:`sm`,disabled:!m.length||!!f,onClick:()=>a({expandedFiles:m.map(e=>e.path)}),children:s(`chat:workbench.expandAll`)}),(0,K.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>a({expandedFiles:[]}),children:s(`chat:workbench.collapseAll`)})]})]}),!c.isFetching&&!f&&d.map(e=>(0,K.jsx)(`p`,{role:`status`,className:`break-all px-3 pt-2 text-xs text-content-muted`,children:s(`chat:workbench.fileNoLongerChanged`,{path:e})},e)),c.isPending?(0,K.jsx)(we,{kind:`loading`,title:s(`chat:focusSession.gitLoading`)}):f?(0,K.jsx)(`p`,{role:`alert`,className:`p-3 text-sm text-danger`,children:f}):c.data?.isRepo?m.length?(0,K.jsx)(`div`,{ref:l.ref,className:`min-h-0 flex-1 overflow-y-auto`,children:m.map(t=>{let n=r.expandedFiles.includes(t.path);return(0,K.jsxs)(`article`,{className:`border-b border-stroke-soft`,children:[(0,K.jsxs)(`button`,{"aria-expanded":n,title:t.path,className:`flex min-h-9 w-full min-w-0 items-center gap-2 pr-3 pl-2 text-left text-sm hover:bg-surface-subtle focus-visible:-outline-offset-2 max-[650px]:min-h-11 pointer-coarse:min-h-11 ${n?`bg-surface-subtle`:``}`,onClick:()=>a({expandedFiles:n?r.expandedFiles.filter(e=>e!==t.path):[...r.expandedFiles,t.path]}),children:[(0,K.jsx)(p,{size:14,className:`shrink-0 text-content-muted transition-transform duration-(--d-fast) ${n?`rotate-90`:``}`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:t.path}),(0,K.jsx)(`span`,{className:`min-w-4 shrink-0 text-center font-mono text-xs font-medium text-content-secondary`,children:t.status}),Object.hasOwn(u.files,t.path)&&(0,K.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums`,children:[(0,K.jsxs)(`span`,{className:`text-success`,children:[`+`,u.files[t.path].added]}),` `,(0,K.jsxs)(`span`,{className:`text-danger`,children:[`−`,u.files[t.path].removed]})]})]}),n&&(0,K.jsx)(`p`,{className:`break-all px-3 py-1.5 font-mono text-xs text-content-muted`,children:t.path}),n&&(0,K.jsx)(q,{sessionId:e,path:t.path,scope:`project`,position:r.reading?.[t.path],onReading:e=>a({reading:{...r.reading,[t.path]:e}}),revision:c.dataUpdatedAt})]},t.path)})}):(0,K.jsx)(z,{compact:!0,title:s(`chat:focusSession.fileChangesEmpty`)}):(0,K.jsx)(z,{compact:!0,title:s(`chat:workbench.notRepository`)})]})}function J(e){return e instanceof Error?e.message:String(e)}function Ke({sessionId:e,streaming:t,requestConfirm:n}){let{t:r}=i(),[a,o]=(0,G.useState)(0),[s,c]=(0,G.useState)(0),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(!0),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(``),[y,b]=(0,G.useState)(null),[ee,x]=(0,G.useState)(null),[S,C]=(0,G.useState)(null),w=(0,G.useRef)(!1),T=(0,G.useRef)(0),E=(0,G.useRef)(0),D=(0,G.useRef)(!0),O=(0,G.useRef)(!1),k=(0,G.useRef)(t);return(0,G.useLayoutEffect)(()=>{k.current=t},[t]),(0,G.useLayoutEffect)(()=>(w.current=!0,()=>{w.current=!1,T.current+=1,E.current+=1}),[]),(0,G.useEffect)(()=>{let t=++T.current;return E.current+=1,x(null),C(null),D.current=!0,f(!0),m(``),L.getSessionFileChanges(e).then(e=>{w.current&&t===T.current&&(u(e),c(e=>e+1))},e=>{w.current&&t===T.current&&m(J(e))}).finally(()=>{w.current&&t===T.current&&(D.current=!1,f(!1))}),()=>{T.current+=1}},[a,e,t]),{changes:l,loading:d,error:p,actionError:h,notice:_,running:y,diff:ee,setDiff:x,diffLoading:S,snapshotRevision:s,writesDisabled:d||t||!!y||!!p||!l,pendingCount:l?.summary.pending||0,reversibleCount:l?.files.filter(e=>e.canRevert&&!e.reverted).length||0,displayedError:h||p,viewDiff:async t=>{if(O.current||D.current)return;let n=++E.current;C(t),g(``);try{let i=await L.getSessionFileChangeDiff(e,t);if(!w.current||n!==E.current)return;if(!i.diff?.trim()){g(r(`chat:focusSession.fileChangesNoSnapshot`));return}x({diff:i.diff,truncated:!!i.diffTruncated})}catch(e){w.current&&n===E.current&&g(J(e))}finally{w.current&&n===E.current&&C(null)}},runAction:async t=>{if(!w.current||O.current||D.current||k.current||!l||p||!l.files.filter(e=>t.kind===`approve`?e.pending&&!e.approved&&!e.reverted:e.canRevert&&!e.reverted).some(e=>t.path===void 0||e.path===t.path))return;O.current=!0,b(t),g(``),v(``);let i=++T.current;E.current+=1,x(null),C(null);let a=!1;try{if(t.kind===`revert`&&!await n({title:t.path?r(`chat:focusSession.fileChangesRevertFile`):r(`chat:focusSession.fileChangesRevertAll`),message:t.path?r(`chat:focusSession.fileChangesRevertFileDescription`,{path:t.path}):r(`chat:focusSession.fileChangesRevertAllDescription`),confirmLabel:r(`chat:focusSession.fileChangesConfirmRevert`),tone:`danger`})||!w.current||k.current||D.current||i!==T.current)return;a=!0;let o=t.kind===`approve`?await L.approveSessionFileChanges(e,t.path):await L.revertSessionFileChanges(e,t.path);if(Ce(e),!w.current||i!==T.current)return;u(o),t.kind===`approve`?v(t.path?r(`chat:focusSession.fileChangesApproved`):r(`chat:focusSession.fileChangesApproveDone`)):o.reverted?t.path===void 0&&o.files.some(e=>e.pending)?v(r(`chat:focusSession.fileChangesRevertPartial`,{count:o.reverted})):v(r(`chat:focusSession.fileChangesRevertDone`)):v(r(`chat:focusSession.fileChangesRevertUnavailable`))}catch(e){w.current&&i===T.current&&g(J(e))}finally{O.current=!1,w.current&&(b(null),a&&(D.current=!0,f(!0),o(e=>e+1)))}},refresh:()=>{D.current=!0,f(!0),g(``),o(e=>e+1)}}}var qe=(0,G.lazy)(()=>t(()=>import(`./TaskTerminalView-Bj9xJWSN.js`).then(e=>({default:e.TaskTerminalView})),__vite__mapDeps([18,1,2,3,4,5,6,7,8,9,19,10,20,14,13,15,12,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]))),Je=(0,G.lazy)(()=>t(()=>import(`./TaskProcessesPane-Cjti3REL.js`).then(e=>({default:e.TaskProcessesPane})),__vite__mapDeps([38,1,2,3,4,5,6,7,8,9,39,10,19,20,40,25,15,29,34,12,13,14,21,22,23,24,26,27,28,30,31,32,33,35,36]))),Ye=(0,G.lazy)(()=>t(()=>import(`./FileAttachmentPreview-LLowX6R-.js`).then(e=>e.n).then(e=>({default:e.FileAttachmentPreview})),__vite__mapDeps([41,1,2,3,4,5,6,7,8,9,42,43,44,45,46,47,10,48,49,11,50,13,29,15,31,51,12,14,52,53,54,32,55,56,57,58,59,25,60,61])));function Xe({sources:e,view:t,onViewChange:n}){let{t:r}=i(),a=_(t.reading?.list,e=>n({reading:{...t.reading,list:e}})),o=(0,G.useContext)(b),[s,c]=(0,G.useState)(``),l=(0,G.useRef)(null),u=e.find(e=>e.id===s),d=e.filter(e=>(!t.filter||e.kind===t.filter)&&e.name.toLocaleLowerCase().includes(t.query.toLocaleLowerCase()));return(0,K.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":r(`chat:workbench.sources`),children:[(0,K.jsxs)(`header`,{className:`flex min-h-10 min-w-0 shrink-0 items-center gap-2 border-b border-stroke-soft pr-1.5 pl-3`,children:[(0,K.jsxs)(`h2`,{className:`min-w-0 flex-1 truncate text-xs font-medium tracking-[.02em] text-content-muted`,children:[r(`chat:workbench.sources`),(0,K.jsx)(`span`,{className:`ml-1.5 tabular-nums`,children:e.length})]}),(0,K.jsx)(`span`,{className:`shrink-0 text-xs text-content-muted`,children:r(`chat:workbench.addSource`)}),(0,K.jsx)(`div`,{ref:o?.setSourceActionHost,className:`grid min-h-7 min-w-7 place-items-center`})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-stroke-soft px-3 py-2.5`,children:[(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:r(`chat:workbench.sourcesScope`)}),(0,K.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,K.jsx)(R,{className:`min-w-0 flex-1`,"aria-label":r(`chat:workbench.searchSources`),placeholder:r(`chat:workbench.searchSources`),value:t.query,onChange:e=>n({query:e.target.value})}),(0,K.jsxs)(De,{"aria-label":r(`chat:workbench.sourceType`),className:`w-auto max-w-[45%] shrink-0`,value:t.filter,onChange:e=>n({filter:e.target.value}),children:[(0,K.jsx)(`option`,{value:``,children:r(`chat:workbench.allTypes`)}),(0,K.jsx)(`option`,{value:`image`,children:r(`chat:workbench.images`)}),(0,K.jsx)(`option`,{value:`text`,children:r(`chat:workbench.text`)}),(0,K.jsx)(`option`,{value:`file`,children:r(`chat:workbench.files`)})]})]})]}),(0,K.jsxs)(`div`,{ref:a.ref,className:`min-h-0 flex-1 overflow-y-auto`,children:[!d.length&&(0,K.jsx)(z,{compact:!0,title:e.length?r(`chat:workbench.noMatches`):r(`chat:workbench.noSources`)}),d.map(e=>{let i=t.selectedSourceId===e.id,a=e.kind===`image`?D:e.method===`path`?O:v;return(0,K.jsxs)(`article`,{className:`border-b border-stroke-soft`,children:[(0,K.jsxs)(`button`,{className:`flex min-h-9 w-full min-w-0 items-center gap-2 px-2 text-left hover:bg-surface-subtle focus-visible:-outline-offset-2 max-[650px]:min-h-11 pointer-coarse:min-h-11 ${i?`bg-surface-subtle`:``}`,"aria-expanded":i,onClick:()=>n({selectedSourceId:i?``:e.id}),children:[(0,K.jsx)(p,{size:14,className:`shrink-0 text-content-muted transition-transform duration-(--d-fast) ${i?`rotate-90`:``}`}),(0,K.jsx)(a,{className:`size-3.5 shrink-0 text-content-muted`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e.name||r(`chat:chatMessage.fileAttachment`)})]}),i&&(0,K.jsxs)(`div`,{className:`space-y-1.5 border-t border-stroke-soft bg-code py-2.5 pr-3 pl-8 text-xs text-content-muted`,children:[(0,K.jsx)(`p`,{className:`break-all font-mono text-content-secondary`,children:e.attachment.path||e.attachment.id||r(`chat:workbench.unavailable`)}),(0,K.jsx)(`p`,{className:`font-mono`,children:e.attachment.mimeType||`application/octet-stream`}),(0,K.jsx)(`p`,{children:e.method===`asset`?r(`chat:workbench.registeredAsset`):e.method===`path`?r(`chat:workbench.pathReference`):r(`chat:workbench.invalidReference`)}),(0,K.jsx)(I,{variant:`secondary`,size:`sm`,className:`mt-1`,disabled:!e.available,onClick:t=>{l.current=t.currentTarget,c(e.id)},children:r(`chat:chatMessage.fileActionPreview`)})]})]},e.id)})]}),u&&(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(Ye,{attachment:u.attachment,onClose:()=>c(``),onRestoreFocus:()=>l.current?.focus(),onDownload:()=>{typeof u.attachment.downloadUrl==`string`&&window.open(u.attachment.downloadUrl,`_blank`,`noopener,noreferrer`)}})})]})}var Ze=`https://www.bing.com/search?q=`;function Qe(e){let t=e.split(`.`);return t.length===4&&t.every(e=>/^\d{1,3}$/.test(e)&&Number(e)<=255)}function $e(e){let t=e.split(/[/?#]/,1)[0]??``;if(!t||t.includes(`@`))return null;if(t.startsWith(`[`))return/^\[[\da-f:.]+\](?::\d{1,5})?$/i.test(t)?t:null;let n=/^([^:]+)(?::(\d{1,5}))?$/.exec(t);return n?n[1]:null}function et(e){if(/\s/.test(e))return null;let t=$e(e);if(!t)return null;let n=t.toLowerCase();if(n.startsWith(`[`)||n===`localhost`||n.endsWith(`.localhost`)||Qe(n))return`local`;let r=n.split(`.`);if(r.length<2||r.some(e=>!/^[\p{L}\p{N}-]+$/u.test(e)))return null;let i=r[r.length-1];return/^(?:\p{L}{2,}|xn--[a-z\d-]+)$/u.test(i)?`public`:null}function tt(e){return`${Ze}${encodeURIComponent(e)}`}function Y(e,t){let n=e.trim();if(!n)return null;if(/^https?:/i.test(n)||n.startsWith(`//`)){let e=U(n,t);return e?{kind:`url`,url:e}:null}let r=et(n);if(r===`local`){let e=je(`http://${n}`,t)?.href;if(e)return{kind:`url`,url:e}}else if(r===`public`){let e=U(n,t);if(e)return{kind:`url`,url:e}}return{kind:`search`,url:tt(n)}}function nt({parentId:e,active:t}){let{t:n}=i(),{entry:r,runtime:a,load:o,setDraft:s}=S(e),c=r.session?.id??``,l=(0,G.useMemo)(()=>e=>a.subscribeSessionState(c,e),[a,c]),d=(0,G.useMemo)(()=>()=>a.getSessionState(c),[a,c]),f=(0,G.useSyncExternalStore)(l,d),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(``),b=(0,G.useRef)(!1),C=(0,G.useRef)(!1),w=(0,G.useRef)(r.draft);w.current=r.draft;let T=(0,G.useRef)(null),D=he(e=>e.bindings),O=ee(f,r.session);(0,G.useEffect)(()=>{t&&o(e)},[t,o,e]);let k=async t=>{t.preventDefault();let n=w.current.trim();if(!(!n||b.current||O||r.expired)){b.current=!0,m(!0),v(``);try{let t=await o(e,!r.session);if(!t?.session)return;let i=t.session.id;if(a.getSessionState(i).streaming)return;w.current.trim()===n&&s(e,``),m(!1),await a.send(i,n),await o(e)}catch(e){v(B(e))}finally{b.current=!1,m(!1)}}},A=(0,G.useCallback)(async()=>{if(!(!c||a.getSessionState(c).streaming)){v(``);try{await a.retry(c),await o(e)}catch(e){v(B(e))}}},[o,e,a,c]),j=async()=>{if(!(!c||h)){g(!0);try{v(``),await a.abort(c)}catch(e){v(B(e))}finally{g(!1)}}},M=(0,K.jsxs)(`div`,{className:`grid h-full min-h-36 place-content-center justify-items-center gap-2 px-3 text-center text-xs text-content-muted`,children:[(0,K.jsx)(`span`,{className:`mb-1 grid size-8 place-items-center rounded-md bg-key text-content-secondary shadow-key ring-1 ring-key-border`,children:(0,K.jsx)(te,{className:`size-4`,"aria-hidden":`true`})}),(0,K.jsx)(`p`,{className:`max-w-64 leading-relaxed`,children:r.expired?n(`chat:sideChat.expired`):n(`chat:sideChat.empty`)}),r.expired&&(0,K.jsxs)(I,{variant:`secondary`,size:`sm`,className:`mt-1`,disabled:r.loading,onClick:async()=>{(await o(e,!0))?.session&&T.current?.focus()},children:[r.loading&&(0,K.jsx)(F,{className:`size-3.5 text-current`}),n(`chat:sideChat.restart`)]})]}),N=_||r.error||f.error;return(0,K.jsxs)(`section`,{"data-side-chat-parent":e,"aria-label":n(`chat:sideChat.title`),className:`flex h-full min-h-0 min-w-0 flex-1 flex-col [container-type:inline-size]`,children:[(0,K.jsx)(`p`,{className:`shrink-0 border-b border-stroke-soft px-3 py-2 text-xs leading-relaxed text-content-muted`,children:n(`chat:sideChat.retention`)}),c?(0,K.jsx)(x,{sessionId:c,messages:f.messages,transcriptLoadState:f.loaded?`ready`:f.error?`error`:`loading`,emptyState:M,messageStart:f.messageStart,hasOlder:f.hasOlder,loadingOlder:f.loadingOlder,olderError:f.olderError,activityFeed:f.activityFeed,tools:f.tools,thinkingText:f.thinkingText,currentActivity:f.currentActivity,compaction:f.compaction,streaming:O,runStartedAt:f.runStartedAt,lastActivityAt:f.lastActivityAt,runFinishedAt:f.runFinishedAt,runStopped:f.runStopped,runNotice:f.runNotice,error:f.error,cwd:r.session?.cwd,onLoadOlder:()=>a.loadOlderMessages(c),onRetryLastTurn:A}):(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:M}),(0,K.jsxs)(`form`,{className:`flex shrink-0 flex-col gap-2 border-t border-stroke-soft p-3`,onSubmit:k,children:[N&&(0,K.jsx)(E,{error:N,onRetry:r.error||!f.loaded?async()=>{await o(e)}:A}),(0,K.jsx)(y,{approvals:f.approvals,onResolve:async(e,t)=>{try{await a.approve(c,e,t)}catch{}}}),(0,K.jsxs)(`div`,{className:`flex min-w-0 items-end gap-2 rounded-[var(--composer-radius,22px)] border border-control bg-panel py-2 pr-2 pl-3 shadow-composer transition-[border-color,box-shadow] duration-(--d-fast) focus-within:border-focus focus-within:ring-3 focus-within:ring-focus-ring`,children:[(0,K.jsx)(`textarea`,{ref:T,rows:2,value:r.draft,"aria-label":n(`chat:sideChat.message`),placeholder:n(`chat:sideChat.placeholder`),className:`max-h-40 min-h-14 min-w-0 flex-1 resize-y border-0 bg-transparent px-1 py-1 text-sm leading-relaxed text-content caret-focus outline-none placeholder:text-content-muted`,onChange:t=>s(e,t.target.value),onCompositionStart:()=>{C.current=!0},onCompositionEnd:()=>{C.current=!1},onKeyDown:e=>{!C.current&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&ge(e.nativeEvent,D.sendMessage)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,K.jsx)(I,{type:O?`button`:`submit`,size:`icon`,className:`size-8 shrink-0 rounded-full max-[650px]:size-11 pointer-coarse:size-11`,"aria-label":n(O?`chat:sideChat.stop`:`chat:sideChat.send`),disabled:O?h:p||r.loading||r.expired||!r.draft.trim(),onClick:O?()=>void j():void 0,children:p||h?(0,K.jsx)(F,{className:`size-4 text-current`}):O?(0,K.jsx)(ne,{size:13,fill:`currentColor`}):(0,K.jsx)(u,{size:17})})]})]})]})}var rt=(0,G.createContext)(null),it=()=>{let e=(0,G.useContext)(rt);if(!e)throw Error(`WebPreview components must be used within a WebPreview`);return e},at=({className:e,children:t,defaultUrl:n=``,onUrlChange:r,...i})=>{let[a,o]=(0,G.useState)(n),[s,c]=(0,G.useState)(!1),l=(0,G.useCallback)(e=>{o(e),r?.(e)},[r]),u=(0,G.useMemo)(()=>({consoleOpen:s,setConsoleOpen:c,setUrl:l,url:a}),[s,l,a]);return(0,K.jsx)(rt.Provider,{value:u,children:(0,K.jsx)(`div`,{className:P(`flex size-full min-h-0 flex-col rounded-lg border bg-card`,e),...i,children:t})})},ot=({className:e,loading:t,src:n,...r})=>{let{url:i}=it();return(0,K.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden bg-background`,children:[(0,K.jsx)(`iframe`,{className:P(`block size-full border-0 bg-background`,e),loading:`lazy`,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-presentation`,src:(n??i)||void 0,title:`Preview`,...r}),t]})},X=1e6;function st(e,t,n,r,i){let a=V(t,i);if(!a)return e;let o=e.find(e=>e.url===a);return[{url:a,title:H(n)||o?.title||``,lastVisitedAt:Math.max(r,o?.lastVisitedAt??0),visits:Math.min(X,(o?.visits??0)+1)},...e.filter(e=>e.url!==a)].slice(0,500)}function ct(e,t,n,r){let i=V(t,r),a=H(n);if(!i||!a)return e;let o=e.findIndex(e=>e.url===i);return o<0||e[o].title===a?e:e.map((e,t)=>t===o?{...e,title:a}:e)}function lt(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=V(t.url);if(!n)return null;let r=typeof t.lastVisitedAt==`number`&&Number.isSafeInteger(t.lastVisitedAt)?Math.max(0,t.lastVisitedAt):0,i=typeof t.visits==`number`&&Number.isSafeInteger(t.visits)?Math.min(X,Math.max(1,t.visits)):1;return{url:n,title:H(t.title),lastVisitedAt:r,visits:i}}function ut(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!t||typeof t!=`object`||Array.isArray(t))return[];let n=t;if(n.version!==1||!Array.isArray(n.entries))return[];let r=new Map;for(let e of n.entries.slice(0,1e3)){let t=lt(e);if(!t)continue;let n=r.get(t.url);n?r.set(t.url,{url:t.url,title:(n.lastVisitedAt>=t.lastVisitedAt?n:t).title,lastVisitedAt:Math.max(n.lastVisitedAt,t.lastVisitedAt),visits:Math.min(X,n.visits+t.visits)}):r.set(t.url,t)}return[...r.values()].sort((e,t)=>t.lastVisitedAt-e.lastVisitedAt).slice(0,500)}function dt(e){let t=e.slice(0,500);if(!t.length)return null;let n=new TextEncoder,r=JSON.stringify({version:1,entries:t});for(;n.encode(r).byteLength>327680&&t.length;)t.splice(-Math.max(1,Math.ceil(t.length/10))),r=JSON.stringify({version:1,entries:t});return t.length?r:null}function ft(e,t){let n=new Date(t);n.setHours(0,0,0,0);let r=n.getTime(),i=new Date(n);i.setDate(i.getDate()-1);let a=new Date(n);a.setDate(a.getDate()-6);let o={today:[],yesterday:[],week:[],earlier:[]};for(let t of e)o[t.lastVisitedAt>=r?`today`:t.lastVisitedAt>=i.getTime()?`yesterday`:t.lastVisitedAt>=a.getTime()?`week`:`earlier`].push(t);return[`today`,`yesterday`,`week`,`earlier`].filter(e=>o[e].length).map(e=>({key:e,entries:o[e]}))}function pt(e){try{return new URL(e).host}catch{return e.slice(0,200)}}var mt=`pisper-browser-history`,ht=1e3,gt=()=>typeof window>`u`?void 0:window.location.origin,_t=ke(mt),Z=Oe(mt,ht);Z.noteStored(_t);var Q=()=>Z.schedule(()=>dt($.getState().entries)),$=a(e=>({entries:ut(_t),visit:(t,n=``)=>{let r=!1;e(e=>{let i=st(e.entries,t,n,Date.now(),gt());return r=i!==e.entries,r?{entries:i}:e}),r&&Q()},title:(t,n)=>{let r=!1;e(e=>{let i=ct(e.entries,t,n,gt());return r=i!==e.entries,r?{entries:i}:e}),r&&Q()},clear:()=>{e({entries:[]}),Q(),Z.flush()}}));function vt({onOpen:e}){let{t}=i(),n=$(e=>e.entries),[r,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(!1),c=(0,G.useRef)(null),l=t(`common:webPreview.history`),u={today:t(`common:webPreview.historyToday`),yesterday:t(`common:webPreview.historyYesterday`),week:t(`common:webPreview.historyWeek`),earlier:t(`common:webPreview.historyEarlier`)},d=r?ft(n,Date.now()):[];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(me,{open:r,onOpenChange:a,children:[(0,K.jsx)(fe,{asChild:!0,children:(0,K.jsx)(I,{ref:c,type:`button`,variant:`ghost`,size:`icon`,"aria-label":l,title:l,children:(0,K.jsx)(M,{size:14})})}),(0,K.jsx)(pe,{align:`end`,className:`w-80 gap-0 p-0`,children:n.length?(0,K.jsxs)(Se,{className:`bg-transparent`,children:[(0,K.jsx)(ve,{placeholder:t(`common:webPreview.historySearch`)}),(0,K.jsxs)(be,{className:`max-h-80`,children:[(0,K.jsx)(ye,{className:`py-0`,children:(0,K.jsx)(z,{compact:!0,title:t(`common:webPreview.historyNoMatch`)})}),d.map(t=>(0,K.jsx)(xe,{heading:u[t.key],children:t.entries.map(t=>{let n=pt(t.url);return(0,K.jsx)(_e,{value:t.url,keywords:t.title?[t.title]:void 0,title:t.url,onSelect:()=>{a(!1),e(t.url)},children:(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:t.title||n}),(0,K.jsx)(`span`,{className:`truncate text-xs text-content-muted`,children:n})]})},t.url)})},t.key))]}),(0,K.jsx)(`div`,{className:`border-t border-stroke-soft p-1`,children:(0,K.jsxs)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full justify-start text-danger`,onClick:()=>{a(!1),s(!0)},children:[(0,K.jsx)(N,{size:14}),t(`common:webPreview.clearHistory`)]})})]}):(0,K.jsx)(z,{compact:!0,icon:M,title:t(`common:webPreview.historyEmpty`)})})]}),(0,K.jsx)(de,{open:o,onOpenChange:s,children:(0,K.jsxs)(oe,{onCloseAutoFocus:e=>{e.preventDefault(),c.current?.focus()},children:[(0,K.jsxs)(ue,{children:[(0,K.jsx)(ae,{children:t(`common:webPreview.clearHistoryTitle`)}),(0,K.jsx)(ie,{children:t(`common:webPreview.clearHistoryDescription`)})]}),(0,K.jsxs)(ce,{children:[(0,K.jsx)(le,{children:t(`common:ui.cancel`)}),(0,K.jsx)(se,{variant:`destructive`,onClick:()=>$.getState().clear(),children:t(`common:webPreview.clearHistoryConfirm`)})]})]})})]})}function yt(e){let t=window.pisperDesktop;return!t||!/Windows|Macintosh/.test(navigator.userAgent)?null:t.browser?e?`failed`:null:`outdated`}function bt({sessionId:e,page:t,onChange:n,onClosed:r}){let{t:a}=i(),{draft:o,url:s}=t,[u,d]=(0,G.useState)(!1),f=(0,G.useRef)(``),p=e=>{!e||e===f.current||(f.current=e,$.getState().visit(e))},_=Pe({enabled:!!window.pisperDesktop?.browser,url:s,popupId:t.resourceId,keepAlive:t.agent,onNavigated:e=>{p(e),e!==s&&n(o===s?{url:e,draft:e}:{url:e})},onTitle:e=>{f.current&&$.getState().title(f.current,e),n({title:e})},onNewWindow:(t,n)=>Ae(e,t,n),onClosed:r}),v=yt(_.unavailable);return(0,G.useEffect)(()=>{_.active||!s||f.current===s||(f.current=s,$.getState().visit(s))},[_.active,s]),(0,K.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col gap-2 p-3`,"aria-label":a(`common:webPreview.title`),children:[(0,K.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault();let t=Y(o,window.location.href);d(!t),t&&n(t.kind===`search`?{url:t.url,draft:t.url}:{url:t.url})},children:[_.active&&(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[(0,K.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`common:webPreview.back`),title:a(`common:webPreview.back`),onClick:()=>_.act(`back`),children:(0,K.jsx)(c,{size:14})}),(0,K.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`common:webPreview.forward`),title:a(`common:webPreview.forward`),onClick:()=>_.act(`forward`),children:(0,K.jsx)(l,{size:14})}),(0,K.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`common:webPreview.reload`),title:a(`common:webPreview.reload`),"aria-busy":_.loading,onClick:()=>_.act(`reload`),children:_.loading?(0,K.jsx)(k,{size:14,className:`animate-spin`}):(0,K.jsx)(Le,{size:14})})]}),(0,K.jsx)(R,{"aria-label":a(`common:webPreview.url`),className:`flex-1 font-mono`,value:o,onChange:e=>n({draft:e.target.value}),placeholder:a(`common:webPreview.urlPlaceholder`),maxLength:2048}),(0,K.jsx)(I,{type:`submit`,variant:`secondary`,children:a(`chat:sessionContext.openUrl`)}),(0,K.jsx)(vt,{onOpen:e=>n({url:e,draft:e})})]}),u&&(0,K.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:a(`chat:sessionContext.invalidUrl`)}),_.active?(0,K.jsx)(`div`,{ref:_.slotRef,role:`group`,"aria-label":a(`common:webPreview.title`),"aria-busy":_.loading,"data-native-browser-slot":!0,className:`min-h-0 flex-1 overflow-hidden rounded-md border border-stroke bg-background`}):s?(0,K.jsx)(at,{className:`min-h-0 flex-1 overflow-hidden rounded-md border-stroke`,defaultUrl:s,children:(0,K.jsx)(ot,{src:s,title:a(`common:webPreview.title`),...Me(s)?{sandbox:Ne}:{}})},s):(0,K.jsx)(z,{icon:h,className:`min-h-0 flex-1`,title:a(`chat:sessionContext.browserEmpty`)}),s&&(0,K.jsxs)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>window.open(s,`_blank`,`noopener,noreferrer`),children:[(0,K.jsx)(g,{size:14}),a(`common:webPreview.openExternal`)]}),!_.active&&v&&s&&(0,K.jsxs)(Ee,{"data-native-browser-fallback":v,children:[(0,K.jsx)(re,{}),(0,K.jsxs)(Te,{className:`flex flex-col items-start gap-2`,children:[a(v===`outdated`?`common:webPreview.shellOutdated`:`common:webPreview.nativeFailed`),v===`outdated`&&(0,K.jsxs)(I,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void window.pisperDesktop?.openReleases(),children:[(0,K.jsx)(m,{size:14}),a(`common:webPreview.downloadDesktop`)]})]})]}),!_.active&&!(v&&s)&&(0,K.jsx)(`p`,{className:`text-xs text-content-muted`,children:a(`common:webPreview.embedNotice`)})]})}export{Je as a,Ge as c,Xe as i,q as l,nt as n,qe as o,Y as r,Ke as s,bt as t,Ue as u};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitDiffViewer-BFdi1mxr.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-DwNgTV1j.js","assets/use-i18n-CsOCclo6.js","assets/i18n-DyMZgkZI.js","assets/vendor-router-CSN_DGvx.js","assets/index-CiyAfWLi.js","assets/index-j6s460ui.css","assets/storage-DtvZ_lEu.js","assets/vendor-state-GkUciC5H.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/x-07u4-129.js","assets/utils-C8uzG5AZ.js","assets/vendor-ui-DvrYggeS.js","assets/button-CCcCN8tE.js","assets/dist-41X0pdUs.js","assets/events-C8OUQmIW.js","assets/esm-DCV8yILT.js","assets/TaskTerminalView-E0ZkafSN.js","assets/square-terminal-BVG6cUT1.js","assets/square-bHHVTT3G.js","assets/PageState-Cz6vFMXv.js","assets/AppSelect-B15Hpk2W.js","assets/use-mobile-C2tPBAza.js","assets/select-DyBoNnz-.js","assets/check-2vYc6QaP.js","assets/chevron-down-CxtxIjiP.js","assets/chevron-up-D_ZcXjqr.js","assets/chevrons-up-down-C2sEPdAh.js","assets/dist-BsRXXcSL.js","assets/dist-BiRPwy4W.js","assets/dist-DzGQ7sLi.js","assets/es2015-DTZdOI9P.js","assets/dist-BRjj4UeB.js","assets/dist-OB2r6Xsr.js","assets/dist-BS3ekNDj.js","assets/terminal-context-aIsIJPn8.js","assets/TaskTerminalView-BrP-ENHg.css","assets/TaskProcessesPane-CgzN0Oqf.js","assets/chevron-right-C3t2Rckj.js","assets/checkbox-BrEHgFV0.js","assets/FileAttachmentPreview-CU3DVCec.js","assets/api-D1flkoh7.js","assets/abort-signal-f4JsiYKX.js","assets/http-response-DEs9jkgT.js","assets/event-stream-DRv0u06j.js","assets/http-B-XVZUum.js","assets/download-BCfIiuaL.js","assets/file-Bllajneu.js","assets/refresh-cw-TbWxTY4K.js","assets/tabs-DsgBuvJv.js","assets/dist-BaBySQmo.js","assets/format-DMJQzoZ7.js","assets/dialog-DldLiTwf.js","assets/dist-BHkR6BLP.js","assets/MarkdownMessage-B9Bb9VQU.js","assets/vendor-markdown-plugins-CT5L3KA9.js","assets/vendor-shiki-runtime-DM7fm4Bl.js","assets/vendor-markdown-plugins-DEcVZfaU.css","assets/vendor-markdown-CT6Z4fh8.js","assets/copy-DHmIFc52.js","assets/route-context-DvWDul4T.js"])))=>i.map(i=>d[i]);
2
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t}from"./vendor-router-CSN_DGvx.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{t as i}from"./use-i18n-CsOCclo6.js";import{o as a}from"./vendor-state-GkUciC5H.js";import{t as o}from"./useQuery-DfOU-27z.js";import{t as s}from"./createLucideIcon-Cd-3GVxJ.js";import{t as c}from"./arrow-left-B8oVrQ2S.js";import{t as l}from"./arrow-right-DqLOhpA2.js";import{t as u}from"./arrow-up-DST6-qVQ.js";import{t as d}from"./check-2vYc6QaP.js";import{t as f}from"./chevron-down-CxtxIjiP.js";import{t as p}from"./chevron-right-C3t2Rckj.js";import{t as m}from"./download-BCfIiuaL.js";import{t as h}from"./earth-Ddy13fHh.js";import{t as g}from"./external-link-CEQqPcqc.js";import{a as _}from"./GitDiffViewer-BFdi1mxr.js";import{t as v}from"./file-Bllajneu.js";import{a as y,c as b,i as ee,o as x,r as S,s as C,y as w}from"./side-chat-context-C7vwSBGo.js";import{t as T}from"./git-branch-N7LGjtzt.js";import{y as E}from"./ChatMessage-DyRMVDmJ.js";import{t as D}from"./image-BY_c3FYU.js";import{t as O}from"./link-2-mgasYn21.js";import{t as k}from"./loader-circle-BOwQzHB-.js";import{t as te}from"./message-square-SKjZyY3v.js";import{t as A}from"./pause-CYWpPg1R.js";import{t as j}from"./refresh-cw-TbWxTY4K.js";import{t as M}from"./rotate-ccw-clock-CO6Bw-sF.js";import{t as ne}from"./square-bHHVTT3G.js";import{t as N}from"./trash-2-CNrPOoPR.js";import{t as re}from"./triangle-alert-CE1q54ci.js";import"./collapsible-B-fc7n0u.js";import{a as ie,c as ae,i as oe,n as se,o as ce,r as le,s as ue,t as de}from"./alert-dialog-DiUitBB0.js";import{a as fe,r as pe,t as me}from"./popover-DGWRnOht.js";import"./tooltip-D4MFbqcG.js";import{t as P}from"./utils-C8uzG5AZ.js";import{n as F,t as I}from"./button-CCcCN8tE.js";import{c as he,r as ge}from"./shortcuts-C6ddcUau.js";import{t as L}from"./chat-api-BqA8nXly.js";import{a as _e,i as ve,n as ye,o as be,r as xe,t as Se}from"./command-LVPgEdXI.js";import{t as R}from"./input-CPw-zkYh.js";import{n as Ce}from"./session-change-summary-api-CAkw4_-l.js";import{n as we,t as z}from"./PageState-Cz6vFMXv.js";import{n as Te,t as Ee}from"./alert-DRIrgNI4.js";import{t as De}from"./AppSelect-B15Hpk2W.js";import{o as B}from"./session-tree-summary-BLsTrwUq.js";import{a as V,i as H,o as Oe,s as ke,t as Ae}from"./session-web-preview-DZOVkeBU.js";import{i as je,n as Me,r as U,t as Ne}from"./web-preview-C7DdG9JP.js";import{n as Pe}from"./useNativeBrowser-CF8AHTRL.js";var Fe=s(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ie=s(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),W=s(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Le=s(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),G=e(n(),1),K=r(),Re={completed:`completed`,in_progress:`running`,paused:`pending`,blocked:`blocked`,pending:`pending`};function ze(e){let t=new Map(e.map(e=>[String(e.id||``),e])),n=e=>e?.status===`completed`;return e.map(e=>{let r=String(e.id||``),i=(Array.isArray(e.dependsOn)?e.dependsOn:[]).map(e=>t.get(String(e))).filter(e=>!!e&&!n(e)),a=e.status!==`completed`&&(e.status===`blocked`||i.length>0);return{...e,id:r,blocked:a,blockedBy:i}})}function Be({status:e,t}){let n=t(e===`completed`?`chat:planBoard.completed`:e===`in_progress`?`chat:planBoard.inProgress`:e===`paused`?`chat:planBoard.paused`:e===`blocked`?`chat:planBoard.blocked`:`chat:planBoard.pending`);return(0,K.jsxs)(`span`,{className:`plan-board-status grid size-[18px] flex-none place-items-center rounded-xs text-content-muted [&.completed]:bg-success-soft [&.completed]:text-success [&.running]:text-accent-fg [&.blocked]:bg-danger-soft [&.blocked]:text-danger ${Re[String(e)]||`pending`}`,title:n,children:[e===`completed`?(0,K.jsx)(d,{size:12,strokeWidth:2.25}):e===`in_progress`?(0,K.jsx)(F,{className:`size-3.5`}):e===`paused`?(0,K.jsx)(A,{size:11,strokeWidth:2}):e===`blocked`?(0,K.jsx)(W,{size:11,strokeWidth:2}):(0,K.jsx)(Fe,{size:11,strokeWidth:2}),(0,K.jsx)(`span`,{className:`sr-only`,children:n})]})}function Ve({item:e,current:t,running:n,t:r}){return(0,K.jsxs)(`li`,{className:`plan-board-row flex min-w-0 flex-col gap-[2px] rounded-sm px-[6px] py-[6px] aria-[current=step]:bg-surface-subtle ${e.blocked?`blocked`:``}`,"aria-current":t?`step`:void 0,"data-pisper-plan-current":t?`true`:void 0,"data-pisper-plan-id":e.id,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[10px]`,children:[(0,K.jsx)(Be,{status:e.blocked?`blocked`:e.status===`in_progress`&&!n?`paused`:e.status,t:r}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] ${e.status===`completed`?`text-content-muted`:`text-foreground`}`,title:e.title,children:e.title}),e.assignee?(0,K.jsxs)(`span`,{className:`inline-flex max-w-[40%] flex-none items-center gap-[4px] truncate rounded-xs border border-stroke px-[6px] font-mono text-[12px] leading-[18px] text-content-secondary`,title:r(`chat:planBoard.assignedTo`,{name:e.assignee}),children:[(0,K.jsx)(w,{size:11,className:`flex-none`}),e.assignee]}):e.status!==`completed`&&(0,K.jsx)(`span`,{className:`flex-none text-[12px] text-content-muted`,children:r(`chat:planBoard.unassigned`)})]}),e.blockedBy.length>0&&(0,K.jsxs)(`div`,{className:`inline-flex min-w-0 items-center gap-[5px] pl-[28px] text-[12px] text-content-muted`,children:[(0,K.jsx)(W,{size:11,className:`flex-none`}),(0,K.jsx)(`span`,{className:`truncate`,children:r(`chat:planBoard.waitingFor`,{tasks:e.blockedBy.map(e=>e.title||e.id).join(` · `)})})]})]})}function He({plan:e,running:t,header:n,collapsible:r=!1}){let{t:a}=i(),o=(0,G.useRef)(null),[s,c]=(0,G.useState)(!0),l=e?.items||[],u=ze(l),d=u.filter(e=>e.status===`completed`).length,p=u.filter(e=>e.status===`in_progress`&&!e.blocked).length,m=u.filter(e=>e.blocked).length,h=u.find(e=>e.status===`in_progress`&&!e.blocked)?.id??u.find(e=>e.blocked)?.id??u.find(e=>e.status===`pending`)?.id??u.at(-1)?.id;if((0,G.useLayoutEffect)(()=>{if(r&&!s)return;let e=o.current,t=e?.querySelector(`[data-pisper-plan-current="true"]`);if(!e||!t)return;let n=e.getBoundingClientRect(),i=t.getBoundingClientRect();i.top<n.top?e.scrollTop-=n.top-i.top:i.bottom>n.bottom&&(e.scrollTop+=i.bottom-n.bottom)},[r,h,s,u.length]),!l.length)return null;let g=u.find(e=>e.id===h),_=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ie,{className:`flex-none text-content-muted`,size:15}),(0,K.jsx)(`strong`,{className:`tabular-nums`,children:a(`chat:planBoard.progress`,{completed:d,total:l.length})}),g?(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-content-secondary`,title:g.title,children:g.title}):null,(0,K.jsxs)(`span`,{className:`plan-board-counts inline-flex flex-none items-center gap-[8px] text-content-muted tabular-nums @max-[470px]:hidden`,children:[p>0&&(0,K.jsx)(`span`,{children:a(t?`chat:planBoard.countInProgress`:`chat:planBoard.countPaused`,{count:p})}),m>0&&(0,K.jsx)(`span`,{className:`blocked text-danger`,children:a(`chat:planBoard.countBlocked`,{count:m})})]}),n,r?(0,K.jsx)(f,{className:`plan-board-chevron flex-none text-content-muted transition-transform duration-(--d-fast) ease-precise [.plan-board-collapsible[open]_&]:rotate-180`,size:15}):null]}),v=(0,K.jsx)(`ul`,{ref:o,className:`plan-board-list [.plan-board-collapsible_>_&]:border-t [.plan-board-collapsible_>_&]:border-stroke-soft [.plan-board-collapsible_>_&]:p-[6px_8px_8px] m-0 flex list-none flex-col gap-[1px] pt-[6px]${u.length>4?` is-scrollable [.session-plan-popover_.plan-board-list&]:[block-size:min(250px,38dvh)] [.plan-board-list&]:[block-size:min(220px,34dvh)] [.plan-board-list&]:overflow-y-auto [.plan-board-list&]:[overscroll-behavior:contain] [.plan-board-list&]:pr-[4px] [.plan-board-list&]:[scrollbar-gutter:stable] [.plan-board-list&:focus-visible]:outline-2 [.plan-board-list&:focus-visible]:outline-focus [.plan-board-list&:focus-visible]:outline-offset-2`:``}`,tabIndex:u.length>4?0:void 0,children:u.map(e=>(0,K.jsx)(Ve,{running:t,item:e,current:e.id===h,t:a},e.id))});return r?(0,K.jsxs)(`details`,{className:`plan-board plan-board-collapsible m-[0_auto] flex w-[min(900px,100%)] flex-col overflow-hidden rounded-md border border-stroke bg-panel !p-0 [.session-plan-popover_&]:w-full [.session-plan-popover_&]:border-0 [.session-plan-popover_&]:bg-transparent`,open:s,onToggle:e=>c(e.currentTarget.open),children:[(0,K.jsx)(`summary`,{className:`plan-board-summary flex min-w-0 items-center gap-[8px] border-b border-stroke-soft pb-[8px] text-[13px] text-content-secondary [&_strong]:flex-none [&_strong]:font-medium [&_strong]:text-foreground [.plan-board-collapsible_>_&]:min-h-[34px] [.plan-board-collapsible_>_&]:cursor-pointer [.plan-board-collapsible_>_&]:list-none [.plan-board-collapsible_>_&]:border-0 [.plan-board-collapsible_>_&]:p-[6px_12px] max-[650px]:[.plan-board-collapsible_>_&]:min-h-11 [.plan-board-collapsible_>_&::-webkit-details-marker]:hidden [.plan-board-collapsible_>_&:hover]:bg-surface-subtle [.plan-board-collapsible_>_&:focus-visible]:outline-2 [.plan-board-collapsible_>_&:focus-visible]:-outline-offset-2 [.plan-board-collapsible_>_&:focus-visible]:outline-focus`,"aria-label":a(`chat:planBoard.toggleAriaLabel`),children:_}),v]}):(0,K.jsxs)(`section`,{className:`plan-board m-[0_auto] flex w-[min(900px,100%)] flex-col rounded-md border border-stroke bg-panel p-[10px_12px] [.session-plan-popover_&]:w-full [.session-plan-popover_&]:border-0 [.session-plan-popover_&]:bg-transparent [.session-plan-popover_&]:p-0`,"aria-label":a(`chat:planBoard.ariaLabel`),children:[(0,K.jsx)(`div`,{className:`plan-board-summary flex min-w-0 items-center gap-[8px] border-b border-stroke-soft pb-[8px] text-[13px] text-content-secondary [&_strong]:flex-none [&_strong]:font-medium [&_strong]:text-foreground [.plan-board-collapsible_>_&]:min-h-[34px] [.plan-board-collapsible_>_&]:cursor-pointer [.plan-board-collapsible_>_&]:list-none [.plan-board-collapsible_>_&]:border-0 [.plan-board-collapsible_>_&]:p-[6px_12px] max-[650px]:[.plan-board-collapsible_>_&]:min-h-11 [.plan-board-collapsible_>_&::-webkit-details-marker]:hidden [.plan-board-collapsible_>_&:hover]:bg-surface-subtle [.plan-board-collapsible_>_&:focus-visible]:outline-2 [.plan-board-collapsible_>_&:focus-visible]:-outline-offset-2 [.plan-board-collapsible_>_&:focus-visible]:outline-focus`,children:_}),v]})}var Ue=(0,G.memo)(He),We=(0,G.lazy)(()=>t(()=>import(`./GitDiffViewer-BFdi1mxr.js`).then(e=>e.n).then(e=>({default:e.InlineGitDiff})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])));function q({sessionId:e,path:t,scope:n,revision:r=0,position:a,onReading:s,mode:c,fill:l=!1}){let{t:u}=i(),d=o({queryKey:[`task-file-diff`,e,n,t,r],queryFn:({signal:r})=>n===`project`?L.getFileDiff(e,t,{signal:r}):L.getSessionFileChangeDiff(e,t,{signal:r})});return d.isPending?(0,K.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 px-3 py-2.5 text-xs text-content-muted`,children:[(0,K.jsx)(F,{className:`size-3.5`}),u(`chat:focusSession.gitLoading`)]}):d.isError?(0,K.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,K.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:d.error.message}),(0,K.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>void d.refetch(),children:u(`chat:chatMessage.filePreviewRetry`)})]}):(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(We,{position:a,onReading:s,diff:d.data.diff,truncated:d.data.diffTruncated,mode:c,fill:l})})}function Ge({sessionId:e,cwd:t,streaming:n,view:r,onViewChange:a}){let{t:s}=i(),c=o({queryKey:[`task-project-changes`,e,t,n],queryFn:({signal:t})=>L.getVcsChanges(e,{signal:t})}),l=_(r.reading?.list,e=>a({reading:{...r.reading,list:e}})),u=(0,G.useMemo)(()=>C(c.data?.diff||``,c.data?.files.map(e=>e.path)||[],c.data?.diffTruncated),[c.data]),d=r.expandedFiles.filter(e=>c.data&&!c.data.files.some(t=>t.path===e)),f=c.error?.message||c.data?.error,m=c.data?.files||[];return(0,K.jsxs)(`section`,{"aria-label":s(`chat:workbench.projectChanges`),className:`flex min-h-0 flex-1 flex-col`,children:[(0,K.jsxs)(`header`,{className:`flex min-h-10 min-w-0 shrink-0 items-center gap-2 border-b border-stroke-soft pr-1.5 pl-3`,children:[(0,K.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-xs font-medium tracking-[.02em] text-content-muted`,children:s(`chat:workbench.projectChanges`)}),c.data?.isRepo&&!f&&(0,K.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums`,children:[(0,K.jsxs)(`span`,{className:`text-success`,children:[`+`,u.added]}),` `,(0,K.jsxs)(`span`,{className:`text-danger`,children:[`−`,u.removed]})]}),(0,K.jsx)(I,{variant:`ghost`,size:`icon`,className:`max-[650px]:size-11`,"aria-label":s(`chat:focusSession.gitRefresh`),disabled:c.isFetching,onClick:()=>void c.refetch(),children:(0,K.jsx)(j,{size:15,className:c.isFetching?`animate-spin`:void 0})})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-stroke-soft px-3 py-2.5`,children:[(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:s(`chat:workbench.projectScope`)}),(0,K.jsxs)(`p`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,title:t,children:[c.data?.branch&&(0,K.jsxs)(`span`,{className:`inline-flex h-5.5 max-w-[45%] shrink-0 items-center gap-1 rounded-xs border border-stroke px-1.5 font-mono text-content-secondary`,children:[(0,K.jsx)(T,{size:12,className:`shrink-0`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`truncate`,children:c.data.branch})]}),(0,K.jsx)(`span`,{className:`min-w-0 truncate font-mono text-content-muted`,children:t})]}),(0,K.jsxs)(`div`,{className:`flex gap-1`,children:[(0,K.jsx)(I,{variant:`ghost`,size:`sm`,disabled:!m.length||!!f,onClick:()=>a({expandedFiles:m.map(e=>e.path)}),children:s(`chat:workbench.expandAll`)}),(0,K.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>a({expandedFiles:[]}),children:s(`chat:workbench.collapseAll`)})]})]}),!c.isFetching&&!f&&d.map(e=>(0,K.jsx)(`p`,{role:`status`,className:`break-all px-3 pt-2 text-xs text-content-muted`,children:s(`chat:workbench.fileNoLongerChanged`,{path:e})},e)),c.isPending?(0,K.jsx)(we,{kind:`loading`,title:s(`chat:focusSession.gitLoading`)}):f?(0,K.jsx)(`p`,{role:`alert`,className:`p-3 text-sm text-danger`,children:f}):c.data?.isRepo?m.length?(0,K.jsx)(`div`,{ref:l.ref,className:`min-h-0 flex-1 overflow-y-auto`,children:m.map(t=>{let n=r.expandedFiles.includes(t.path);return(0,K.jsxs)(`article`,{className:`border-b border-stroke-soft`,children:[(0,K.jsxs)(`button`,{"aria-expanded":n,title:t.path,className:`flex min-h-9 w-full min-w-0 items-center gap-2 pr-3 pl-2 text-left text-sm hover:bg-surface-subtle focus-visible:-outline-offset-2 max-[650px]:min-h-11 pointer-coarse:min-h-11 ${n?`bg-surface-subtle`:``}`,onClick:()=>a({expandedFiles:n?r.expandedFiles.filter(e=>e!==t.path):[...r.expandedFiles,t.path]}),children:[(0,K.jsx)(p,{size:14,className:`shrink-0 text-content-muted transition-transform duration-(--d-fast) ${n?`rotate-90`:``}`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:t.path}),(0,K.jsx)(`span`,{className:`min-w-4 shrink-0 text-center font-mono text-xs font-medium text-content-secondary`,children:t.status}),Object.hasOwn(u.files,t.path)&&(0,K.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums`,children:[(0,K.jsxs)(`span`,{className:`text-success`,children:[`+`,u.files[t.path].added]}),` `,(0,K.jsxs)(`span`,{className:`text-danger`,children:[`−`,u.files[t.path].removed]})]})]}),n&&(0,K.jsx)(`p`,{className:`break-all px-3 py-1.5 font-mono text-xs text-content-muted`,children:t.path}),n&&(0,K.jsx)(q,{sessionId:e,path:t.path,scope:`project`,position:r.reading?.[t.path],onReading:e=>a({reading:{...r.reading,[t.path]:e}}),revision:c.dataUpdatedAt})]},t.path)})}):(0,K.jsx)(z,{compact:!0,title:s(`chat:focusSession.fileChangesEmpty`)}):(0,K.jsx)(z,{compact:!0,title:s(`chat:workbench.notRepository`)})]})}function J(e){return e instanceof Error?e.message:String(e)}function Ke({sessionId:e,streaming:t,requestConfirm:n}){let{t:r}=i(),[a,o]=(0,G.useState)(0),[s,c]=(0,G.useState)(0),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(!0),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(``),[y,b]=(0,G.useState)(null),[ee,x]=(0,G.useState)(null),[S,C]=(0,G.useState)(null),w=(0,G.useRef)(!1),T=(0,G.useRef)(0),E=(0,G.useRef)(0),D=(0,G.useRef)(!0),O=(0,G.useRef)(!1),k=(0,G.useRef)(t);return(0,G.useLayoutEffect)(()=>{k.current=t},[t]),(0,G.useLayoutEffect)(()=>(w.current=!0,()=>{w.current=!1,T.current+=1,E.current+=1}),[]),(0,G.useEffect)(()=>{let t=++T.current;return E.current+=1,x(null),C(null),D.current=!0,f(!0),m(``),L.getSessionFileChanges(e).then(e=>{w.current&&t===T.current&&(u(e),c(e=>e+1))},e=>{w.current&&t===T.current&&m(J(e))}).finally(()=>{w.current&&t===T.current&&(D.current=!1,f(!1))}),()=>{T.current+=1}},[a,e,t]),{changes:l,loading:d,error:p,actionError:h,notice:_,running:y,diff:ee,setDiff:x,diffLoading:S,snapshotRevision:s,writesDisabled:d||t||!!y||!!p||!l,pendingCount:l?.summary.pending||0,reversibleCount:l?.files.filter(e=>e.canRevert&&!e.reverted).length||0,displayedError:h||p,viewDiff:async t=>{if(O.current||D.current)return;let n=++E.current;C(t),g(``);try{let i=await L.getSessionFileChangeDiff(e,t);if(!w.current||n!==E.current)return;if(!i.diff?.trim()){g(r(`chat:focusSession.fileChangesNoSnapshot`));return}x({diff:i.diff,truncated:!!i.diffTruncated})}catch(e){w.current&&n===E.current&&g(J(e))}finally{w.current&&n===E.current&&C(null)}},runAction:async t=>{if(!w.current||O.current||D.current||k.current||!l||p||!l.files.filter(e=>t.kind===`approve`?e.pending&&!e.approved&&!e.reverted:e.canRevert&&!e.reverted).some(e=>t.path===void 0||e.path===t.path))return;O.current=!0,b(t),g(``),v(``);let i=++T.current;E.current+=1,x(null),C(null);let a=!1;try{if(t.kind===`revert`&&!await n({title:t.path?r(`chat:focusSession.fileChangesRevertFile`):r(`chat:focusSession.fileChangesRevertAll`),message:t.path?r(`chat:focusSession.fileChangesRevertFileDescription`,{path:t.path}):r(`chat:focusSession.fileChangesRevertAllDescription`),confirmLabel:r(`chat:focusSession.fileChangesConfirmRevert`),tone:`danger`})||!w.current||k.current||D.current||i!==T.current)return;a=!0;let o=t.kind===`approve`?await L.approveSessionFileChanges(e,t.path):await L.revertSessionFileChanges(e,t.path);if(Ce(e),!w.current||i!==T.current)return;u(o),t.kind===`approve`?v(t.path?r(`chat:focusSession.fileChangesApproved`):r(`chat:focusSession.fileChangesApproveDone`)):o.reverted?t.path===void 0&&o.files.some(e=>e.pending)?v(r(`chat:focusSession.fileChangesRevertPartial`,{count:o.reverted})):v(r(`chat:focusSession.fileChangesRevertDone`)):v(r(`chat:focusSession.fileChangesRevertUnavailable`))}catch(e){w.current&&i===T.current&&g(J(e))}finally{O.current=!1,w.current&&(b(null),a&&(D.current=!0,f(!0),o(e=>e+1)))}},refresh:()=>{D.current=!0,f(!0),g(``),o(e=>e+1)}}}var qe=(0,G.lazy)(()=>t(()=>import(`./TaskTerminalView-E0ZkafSN.js`).then(e=>({default:e.TaskTerminalView})),__vite__mapDeps([18,1,2,3,4,5,6,7,8,9,19,10,20,14,13,15,12,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]))),Je=(0,G.lazy)(()=>t(()=>import(`./TaskProcessesPane-CgzN0Oqf.js`).then(e=>({default:e.TaskProcessesPane})),__vite__mapDeps([38,1,2,3,4,5,6,7,8,9,39,10,19,20,40,25,15,29,34,12,13,14,21,22,23,24,26,27,28,30,31,32,33,35,36]))),Ye=(0,G.lazy)(()=>t(()=>import(`./FileAttachmentPreview-CU3DVCec.js`).then(e=>e.n).then(e=>({default:e.FileAttachmentPreview})),__vite__mapDeps([41,1,2,3,4,5,6,7,8,9,42,43,44,45,46,47,10,48,49,11,50,13,29,15,31,51,12,14,52,53,54,32,55,56,57,58,59,25,60,61])));function Xe({sources:e,view:t,onViewChange:n}){let{t:r}=i(),a=_(t.reading?.list,e=>n({reading:{...t.reading,list:e}})),o=(0,G.useContext)(b),[s,c]=(0,G.useState)(``),l=(0,G.useRef)(null),u=e.find(e=>e.id===s),d=e.filter(e=>(!t.filter||e.kind===t.filter)&&e.name.toLocaleLowerCase().includes(t.query.toLocaleLowerCase()));return(0,K.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":r(`chat:workbench.sources`),children:[(0,K.jsxs)(`header`,{className:`flex min-h-10 min-w-0 shrink-0 items-center gap-2 border-b border-stroke-soft pr-1.5 pl-3`,children:[(0,K.jsxs)(`h2`,{className:`min-w-0 flex-1 truncate text-xs font-medium tracking-[.02em] text-content-muted`,children:[r(`chat:workbench.sources`),(0,K.jsx)(`span`,{className:`ml-1.5 tabular-nums`,children:e.length})]}),(0,K.jsx)(`span`,{className:`shrink-0 text-xs text-content-muted`,children:r(`chat:workbench.addSource`)}),(0,K.jsx)(`div`,{ref:o?.setSourceActionHost,className:`grid min-h-7 min-w-7 place-items-center`})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-stroke-soft px-3 py-2.5`,children:[(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:r(`chat:workbench.sourcesScope`)}),(0,K.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,K.jsx)(R,{className:`min-w-0 flex-1`,"aria-label":r(`chat:workbench.searchSources`),placeholder:r(`chat:workbench.searchSources`),value:t.query,onChange:e=>n({query:e.target.value})}),(0,K.jsxs)(De,{"aria-label":r(`chat:workbench.sourceType`),className:`w-auto max-w-[45%] shrink-0`,value:t.filter,onChange:e=>n({filter:e.target.value}),children:[(0,K.jsx)(`option`,{value:``,children:r(`chat:workbench.allTypes`)}),(0,K.jsx)(`option`,{value:`image`,children:r(`chat:workbench.images`)}),(0,K.jsx)(`option`,{value:`text`,children:r(`chat:workbench.text`)}),(0,K.jsx)(`option`,{value:`file`,children:r(`chat:workbench.files`)})]})]})]}),(0,K.jsxs)(`div`,{ref:a.ref,className:`min-h-0 flex-1 overflow-y-auto`,children:[!d.length&&(0,K.jsx)(z,{compact:!0,title:e.length?r(`chat:workbench.noMatches`):r(`chat:workbench.noSources`)}),d.map(e=>{let i=t.selectedSourceId===e.id,a=e.kind===`image`?D:e.method===`path`?O:v;return(0,K.jsxs)(`article`,{className:`border-b border-stroke-soft`,children:[(0,K.jsxs)(`button`,{className:`flex min-h-9 w-full min-w-0 items-center gap-2 px-2 text-left hover:bg-surface-subtle focus-visible:-outline-offset-2 max-[650px]:min-h-11 pointer-coarse:min-h-11 ${i?`bg-surface-subtle`:``}`,"aria-expanded":i,onClick:()=>n({selectedSourceId:i?``:e.id}),children:[(0,K.jsx)(p,{size:14,className:`shrink-0 text-content-muted transition-transform duration-(--d-fast) ${i?`rotate-90`:``}`}),(0,K.jsx)(a,{className:`size-3.5 shrink-0 text-content-muted`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e.name||r(`chat:chatMessage.fileAttachment`)})]}),i&&(0,K.jsxs)(`div`,{className:`space-y-1.5 border-t border-stroke-soft bg-code py-2.5 pr-3 pl-8 text-xs text-content-muted`,children:[(0,K.jsx)(`p`,{className:`break-all font-mono text-content-secondary`,children:e.attachment.path||e.attachment.id||r(`chat:workbench.unavailable`)}),(0,K.jsx)(`p`,{className:`font-mono`,children:e.attachment.mimeType||`application/octet-stream`}),(0,K.jsx)(`p`,{children:e.method===`asset`?r(`chat:workbench.registeredAsset`):e.method===`path`?r(`chat:workbench.pathReference`):r(`chat:workbench.invalidReference`)}),(0,K.jsx)(I,{variant:`secondary`,size:`sm`,className:`mt-1`,disabled:!e.available,onClick:t=>{l.current=t.currentTarget,c(e.id)},children:r(`chat:chatMessage.fileActionPreview`)})]})]},e.id)})]}),u&&(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(Ye,{attachment:u.attachment,onClose:()=>c(``),onRestoreFocus:()=>l.current?.focus(),onDownload:()=>{typeof u.attachment.downloadUrl==`string`&&window.open(u.attachment.downloadUrl,`_blank`,`noopener,noreferrer`)}})})]})}var Ze=`https://www.bing.com/search?q=`;function Qe(e){let t=e.split(`.`);return t.length===4&&t.every(e=>/^\d{1,3}$/.test(e)&&Number(e)<=255)}function $e(e){let t=e.split(/[/?#]/,1)[0]??``;if(!t||t.includes(`@`))return null;if(t.startsWith(`[`))return/^\[[\da-f:.]+\](?::\d{1,5})?$/i.test(t)?t:null;let n=/^([^:]+)(?::(\d{1,5}))?$/.exec(t);return n?n[1]:null}function et(e){if(/\s/.test(e))return null;let t=$e(e);if(!t)return null;let n=t.toLowerCase();if(n.startsWith(`[`)||n===`localhost`||n.endsWith(`.localhost`)||Qe(n))return`local`;let r=n.split(`.`);if(r.length<2||r.some(e=>!/^[\p{L}\p{N}-]+$/u.test(e)))return null;let i=r[r.length-1];return/^(?:\p{L}{2,}|xn--[a-z\d-]+)$/u.test(i)?`public`:null}function tt(e){return`${Ze}${encodeURIComponent(e)}`}function Y(e,t){let n=e.trim();if(!n)return null;if(/^https?:/i.test(n)||n.startsWith(`//`)){let e=U(n,t);return e?{kind:`url`,url:e}:null}let r=et(n);if(r===`local`){let e=je(`http://${n}`,t)?.href;if(e)return{kind:`url`,url:e}}else if(r===`public`){let e=U(n,t);if(e)return{kind:`url`,url:e}}return{kind:`search`,url:tt(n)}}function nt({parentId:e,active:t}){let{t:n}=i(),{entry:r,runtime:a,load:o,setDraft:s}=S(e),c=r.session?.id??``,l=(0,G.useMemo)(()=>e=>a.subscribeSessionState(c,e),[a,c]),d=(0,G.useMemo)(()=>()=>a.getSessionState(c),[a,c]),f=(0,G.useSyncExternalStore)(l,d),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(``),b=(0,G.useRef)(!1),C=(0,G.useRef)(!1),w=(0,G.useRef)(r.draft);w.current=r.draft;let T=(0,G.useRef)(null),D=he(e=>e.bindings),O=ee(f,r.session);(0,G.useEffect)(()=>{t&&o(e)},[t,o,e]);let k=async t=>{t.preventDefault();let n=w.current.trim();if(!(!n||b.current||O||r.expired)){b.current=!0,m(!0),v(``);try{let t=await o(e,!r.session);if(!t?.session)return;let i=t.session.id;if(a.getSessionState(i).streaming)return;w.current.trim()===n&&s(e,``),m(!1),await a.send(i,n),await o(e)}catch(e){v(B(e))}finally{b.current=!1,m(!1)}}},A=(0,G.useCallback)(async()=>{if(!(!c||a.getSessionState(c).streaming)){v(``);try{await a.retry(c),await o(e)}catch(e){v(B(e))}}},[o,e,a,c]),j=async()=>{if(!(!c||h)){g(!0);try{v(``),await a.abort(c)}catch(e){v(B(e))}finally{g(!1)}}},M=(0,K.jsxs)(`div`,{className:`grid h-full min-h-36 place-content-center justify-items-center gap-2 px-3 text-center text-xs text-content-muted`,children:[(0,K.jsx)(`span`,{className:`mb-1 grid size-8 place-items-center rounded-md bg-key text-content-secondary shadow-key ring-1 ring-key-border`,children:(0,K.jsx)(te,{className:`size-4`,"aria-hidden":`true`})}),(0,K.jsx)(`p`,{className:`max-w-64 leading-relaxed`,children:r.expired?n(`chat:sideChat.expired`):n(`chat:sideChat.empty`)}),r.expired&&(0,K.jsxs)(I,{variant:`secondary`,size:`sm`,className:`mt-1`,disabled:r.loading,onClick:async()=>{(await o(e,!0))?.session&&T.current?.focus()},children:[r.loading&&(0,K.jsx)(F,{className:`size-3.5 text-current`}),n(`chat:sideChat.restart`)]})]}),N=_||r.error||f.error;return(0,K.jsxs)(`section`,{"data-side-chat-parent":e,"aria-label":n(`chat:sideChat.title`),className:`flex h-full min-h-0 min-w-0 flex-1 flex-col [container-type:inline-size]`,children:[(0,K.jsx)(`p`,{className:`shrink-0 border-b border-stroke-soft px-3 py-2 text-xs leading-relaxed text-content-muted`,children:n(`chat:sideChat.retention`)}),c?(0,K.jsx)(x,{sessionId:c,messages:f.messages,transcriptLoadState:f.loaded?`ready`:f.error?`error`:`loading`,emptyState:M,messageStart:f.messageStart,hasOlder:f.hasOlder,loadingOlder:f.loadingOlder,olderError:f.olderError,activityFeed:f.activityFeed,tools:f.tools,thinkingText:f.thinkingText,currentActivity:f.currentActivity,compaction:f.compaction,streaming:O,runStartedAt:f.runStartedAt,lastActivityAt:f.lastActivityAt,runFinishedAt:f.runFinishedAt,runStopped:f.runStopped,runNotice:f.runNotice,error:f.error,cwd:r.session?.cwd,onLoadOlder:()=>a.loadOlderMessages(c),onRetryLastTurn:A}):(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:M}),(0,K.jsxs)(`form`,{className:`flex shrink-0 flex-col gap-2 border-t border-stroke-soft p-3`,onSubmit:k,children:[N&&(0,K.jsx)(E,{error:N,onRetry:r.error||!f.loaded?async()=>{await o(e)}:A}),(0,K.jsx)(y,{approvals:f.approvals,onResolve:async(e,t)=>{try{await a.approve(c,e,t)}catch{}}}),(0,K.jsxs)(`div`,{className:`flex min-w-0 items-end gap-2 rounded-[var(--composer-radius,22px)] border border-control bg-panel py-2 pr-2 pl-3 shadow-composer transition-[border-color,box-shadow] duration-(--d-fast) focus-within:border-focus focus-within:ring-3 focus-within:ring-focus-ring`,children:[(0,K.jsx)(`textarea`,{ref:T,rows:2,value:r.draft,"aria-label":n(`chat:sideChat.message`),placeholder:n(`chat:sideChat.placeholder`),className:`max-h-40 min-h-14 min-w-0 flex-1 resize-y border-0 bg-transparent px-1 py-1 text-sm leading-relaxed text-content caret-focus outline-none placeholder:text-content-muted`,onChange:t=>s(e,t.target.value),onCompositionStart:()=>{C.current=!0},onCompositionEnd:()=>{C.current=!1},onKeyDown:e=>{!C.current&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&ge(e.nativeEvent,D.sendMessage)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,K.jsx)(I,{type:O?`button`:`submit`,size:`icon`,className:`size-8 shrink-0 rounded-full max-[650px]:size-11 pointer-coarse:size-11`,"aria-label":n(O?`chat:sideChat.stop`:`chat:sideChat.send`),disabled:O?h:p||r.loading||r.expired||!r.draft.trim(),onClick:O?()=>void j():void 0,children:p||h?(0,K.jsx)(F,{className:`size-4 text-current`}):O?(0,K.jsx)(ne,{size:13,fill:`currentColor`}):(0,K.jsx)(u,{size:17})})]})]})]})}var rt=(0,G.createContext)(null),it=()=>{let e=(0,G.useContext)(rt);if(!e)throw Error(`WebPreview components must be used within a WebPreview`);return e},at=({className:e,children:t,defaultUrl:n=``,onUrlChange:r,...i})=>{let[a,o]=(0,G.useState)(n),[s,c]=(0,G.useState)(!1),l=(0,G.useCallback)(e=>{o(e),r?.(e)},[r]),u=(0,G.useMemo)(()=>({consoleOpen:s,setConsoleOpen:c,setUrl:l,url:a}),[s,l,a]);return(0,K.jsx)(rt.Provider,{value:u,children:(0,K.jsx)(`div`,{className:P(`flex size-full min-h-0 flex-col rounded-lg border bg-card`,e),...i,children:t})})},ot=({className:e,loading:t,src:n,...r})=>{let{url:i}=it();return(0,K.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden bg-background`,children:[(0,K.jsx)(`iframe`,{className:P(`block size-full border-0 bg-background`,e),loading:`lazy`,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-presentation`,src:(n??i)||void 0,title:`Preview`,...r}),t]})},X=1e6;function st(e,t,n,r,i){let a=V(t,i);if(!a)return e;let o=e.find(e=>e.url===a);return[{url:a,title:H(n)||o?.title||``,lastVisitedAt:Math.max(r,o?.lastVisitedAt??0),visits:Math.min(X,(o?.visits??0)+1)},...e.filter(e=>e.url!==a)].slice(0,500)}function ct(e,t,n,r){let i=V(t,r),a=H(n);if(!i||!a)return e;let o=e.findIndex(e=>e.url===i);return o<0||e[o].title===a?e:e.map((e,t)=>t===o?{...e,title:a}:e)}function lt(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=V(t.url);if(!n)return null;let r=typeof t.lastVisitedAt==`number`&&Number.isSafeInteger(t.lastVisitedAt)?Math.max(0,t.lastVisitedAt):0,i=typeof t.visits==`number`&&Number.isSafeInteger(t.visits)?Math.min(X,Math.max(1,t.visits)):1;return{url:n,title:H(t.title),lastVisitedAt:r,visits:i}}function ut(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!t||typeof t!=`object`||Array.isArray(t))return[];let n=t;if(n.version!==1||!Array.isArray(n.entries))return[];let r=new Map;for(let e of n.entries.slice(0,1e3)){let t=lt(e);if(!t)continue;let n=r.get(t.url);n?r.set(t.url,{url:t.url,title:(n.lastVisitedAt>=t.lastVisitedAt?n:t).title,lastVisitedAt:Math.max(n.lastVisitedAt,t.lastVisitedAt),visits:Math.min(X,n.visits+t.visits)}):r.set(t.url,t)}return[...r.values()].sort((e,t)=>t.lastVisitedAt-e.lastVisitedAt).slice(0,500)}function dt(e){let t=e.slice(0,500);if(!t.length)return null;let n=new TextEncoder,r=JSON.stringify({version:1,entries:t});for(;n.encode(r).byteLength>327680&&t.length;)t.splice(-Math.max(1,Math.ceil(t.length/10))),r=JSON.stringify({version:1,entries:t});return t.length?r:null}function ft(e,t){let n=new Date(t);n.setHours(0,0,0,0);let r=n.getTime(),i=new Date(n);i.setDate(i.getDate()-1);let a=new Date(n);a.setDate(a.getDate()-6);let o={today:[],yesterday:[],week:[],earlier:[]};for(let t of e)o[t.lastVisitedAt>=r?`today`:t.lastVisitedAt>=i.getTime()?`yesterday`:t.lastVisitedAt>=a.getTime()?`week`:`earlier`].push(t);return[`today`,`yesterday`,`week`,`earlier`].filter(e=>o[e].length).map(e=>({key:e,entries:o[e]}))}function pt(e){try{return new URL(e).host}catch{return e.slice(0,200)}}var mt=`pisper-browser-history`,ht=1e3,gt=()=>typeof window>`u`?void 0:window.location.origin,_t=ke(mt),Z=Oe(mt,ht);Z.noteStored(_t);var Q=()=>Z.schedule(()=>dt($.getState().entries)),$=a(e=>({entries:ut(_t),visit:(t,n=``)=>{let r=!1;e(e=>{let i=st(e.entries,t,n,Date.now(),gt());return r=i!==e.entries,r?{entries:i}:e}),r&&Q()},title:(t,n)=>{let r=!1;e(e=>{let i=ct(e.entries,t,n,gt());return r=i!==e.entries,r?{entries:i}:e}),r&&Q()},clear:()=>{e({entries:[]}),Q(),Z.flush()}}));function vt({onOpen:e}){let{t}=i(),n=$(e=>e.entries),[r,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(!1),c=(0,G.useRef)(null),l=t(`common:webPreview.history`),u={today:t(`common:webPreview.historyToday`),yesterday:t(`common:webPreview.historyYesterday`),week:t(`common:webPreview.historyWeek`),earlier:t(`common:webPreview.historyEarlier`)},d=r?ft(n,Date.now()):[];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(me,{open:r,onOpenChange:a,children:[(0,K.jsx)(fe,{asChild:!0,children:(0,K.jsx)(I,{ref:c,type:`button`,variant:`ghost`,size:`icon`,"aria-label":l,title:l,children:(0,K.jsx)(M,{size:14})})}),(0,K.jsx)(pe,{align:`end`,className:`w-80 gap-0 p-0`,children:n.length?(0,K.jsxs)(Se,{className:`bg-transparent`,children:[(0,K.jsx)(ve,{placeholder:t(`common:webPreview.historySearch`)}),(0,K.jsxs)(be,{className:`max-h-80`,children:[(0,K.jsx)(ye,{className:`py-0`,children:(0,K.jsx)(z,{compact:!0,title:t(`common:webPreview.historyNoMatch`)})}),d.map(t=>(0,K.jsx)(xe,{heading:u[t.key],children:t.entries.map(t=>{let n=pt(t.url);return(0,K.jsx)(_e,{value:t.url,keywords:t.title?[t.title]:void 0,title:t.url,onSelect:()=>{a(!1),e(t.url)},children:(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:t.title||n}),(0,K.jsx)(`span`,{className:`truncate text-xs text-content-muted`,children:n})]})},t.url)})},t.key))]}),(0,K.jsx)(`div`,{className:`border-t border-stroke-soft p-1`,children:(0,K.jsxs)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full justify-start text-danger`,onClick:()=>{a(!1),s(!0)},children:[(0,K.jsx)(N,{size:14}),t(`common:webPreview.clearHistory`)]})})]}):(0,K.jsx)(z,{compact:!0,icon:M,title:t(`common:webPreview.historyEmpty`)})})]}),(0,K.jsx)(de,{open:o,onOpenChange:s,children:(0,K.jsxs)(oe,{onCloseAutoFocus:e=>{e.preventDefault(),c.current?.focus()},children:[(0,K.jsxs)(ue,{children:[(0,K.jsx)(ae,{children:t(`common:webPreview.clearHistoryTitle`)}),(0,K.jsx)(ie,{children:t(`common:webPreview.clearHistoryDescription`)})]}),(0,K.jsxs)(ce,{children:[(0,K.jsx)(le,{children:t(`common:ui.cancel`)}),(0,K.jsx)(se,{variant:`destructive`,onClick:()=>$.getState().clear(),children:t(`common:webPreview.clearHistoryConfirm`)})]})]})})]})}function yt(e){let t=window.pisperDesktop;return!t||!/Windows|Macintosh/.test(navigator.userAgent)?null:t.browser?e?`failed`:null:`outdated`}function bt({sessionId:e,page:t,onChange:n,onClosed:r}){let{t:a}=i(),{draft:o,url:s}=t,[u,d]=(0,G.useState)(!1),f=(0,G.useRef)(``),p=e=>{!e||e===f.current||(f.current=e,$.getState().visit(e))},_=Pe({sessionId:e,pageId:t.id,enabled:!!window.pisperDesktop?.browser,url:s,popupId:t.resourceId,keepAlive:t.agent,onNavigated:e=>{p(e),e!==s&&n(o===s?{url:e,draft:e}:{url:e})},onTitle:e=>{f.current&&$.getState().title(f.current,e),n({title:e})},onNewWindow:(t,n)=>Ae(e,t,n),onClosed:r}),v=yt(_.unavailable);return(0,G.useEffect)(()=>{_.active||!s||f.current===s||(f.current=s,$.getState().visit(s))},[_.active,s]),(0,K.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col gap-2 p-3`,"aria-label":a(`common:webPreview.title`),children:[(0,K.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault();let t=Y(o,window.location.href);d(!t),t&&n(t.kind===`search`?{url:t.url,draft:t.url}:{url:t.url})},children:[_.active&&(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[(0,K.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`common:webPreview.back`),title:a(`common:webPreview.back`),onClick:()=>_.act(`back`),children:(0,K.jsx)(c,{size:14})}),(0,K.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`common:webPreview.forward`),title:a(`common:webPreview.forward`),onClick:()=>_.act(`forward`),children:(0,K.jsx)(l,{size:14})}),(0,K.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`common:webPreview.reload`),title:a(`common:webPreview.reload`),"aria-busy":_.loading,onClick:()=>_.act(`reload`),children:_.loading?(0,K.jsx)(k,{size:14,className:`animate-spin`}):(0,K.jsx)(Le,{size:14})})]}),(0,K.jsx)(R,{"aria-label":a(`common:webPreview.url`),className:`flex-1 font-mono`,value:o,onChange:e=>n({draft:e.target.value}),placeholder:a(`common:webPreview.urlPlaceholder`),maxLength:2048}),(0,K.jsx)(I,{type:`submit`,variant:`secondary`,children:a(`chat:sessionContext.openUrl`)}),(0,K.jsx)(vt,{onOpen:e=>n({url:e,draft:e})})]}),u&&(0,K.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:a(`chat:sessionContext.invalidUrl`)}),_.active?(0,K.jsx)(`div`,{ref:_.slotRef,role:`group`,"aria-label":a(`common:webPreview.title`),"aria-busy":_.loading,"data-native-browser-slot":!0,className:`min-h-0 flex-1 overflow-hidden rounded-md border border-stroke bg-background`}):s?(0,K.jsx)(at,{className:`min-h-0 flex-1 overflow-hidden rounded-md border-stroke`,defaultUrl:s,children:(0,K.jsx)(ot,{src:s,title:a(`common:webPreview.title`),...Me(s)?{sandbox:Ne}:{}})},s):(0,K.jsx)(z,{icon:h,className:`min-h-0 flex-1`,title:a(`chat:sessionContext.browserEmpty`)}),s&&(0,K.jsxs)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>window.open(s,`_blank`,`noopener,noreferrer`),children:[(0,K.jsx)(g,{size:14}),a(`common:webPreview.openExternal`)]}),!_.active&&v&&s&&(0,K.jsxs)(Ee,{"data-native-browser-fallback":v,children:[(0,K.jsx)(re,{}),(0,K.jsxs)(Te,{className:`flex flex-col items-start gap-2`,children:[a(v===`outdated`?`common:webPreview.shellOutdated`:`common:webPreview.nativeFailed`),v===`outdated`&&(0,K.jsxs)(I,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void window.pisperDesktop?.openReleases(),children:[(0,K.jsx)(m,{size:14}),a(`common:webPreview.downloadDesktop`)]})]})]}),!_.active&&!(v&&s)&&(0,K.jsx)(`p`,{className:`text-xs text-content-muted`,children:a(`common:webPreview.embedNotice`)})]})}export{Je as a,Ge as c,Xe as i,q as l,nt as n,qe as o,Y as r,Ke as s,bt as t,Ue as u};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitDiffViewer-D6X8UoVx.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-DwNgTV1j.js","assets/use-i18n-47vsdOU3.js","assets/i18n-CHUj56MI.js","assets/vendor-router-CSN_DGvx.js","assets/index-Dw3Kz26s.js","assets/index-j6s460ui.css","assets/storage-DtvZ_lEu.js","assets/vendor-state-GkUciC5H.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/x-07u4-129.js","assets/utils-C8uzG5AZ.js","assets/vendor-ui-DvrYggeS.js","assets/button-CCcCN8tE.js","assets/dist-41X0pdUs.js","assets/events-BgoXNekW.js","assets/esm-DCV8yILT.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t}from"./vendor-router-CSN_DGvx.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{t as i}from"./use-i18n-47vsdOU3.js";import{i as a}from"./runtime-capabilities-ChJVNwRz.js";import{t as o}from"./runtime-capabilities-store-BA14peh5.js";import{t as s}from"./activity-BCxvXCG3.js";import{t as c}from"./arrow-left-B8oVrQ2S.js";import{t as l}from"./check-2vYc6QaP.js";import{t as u}from"./chevron-right-C3t2Rckj.js";import{a as d,c as f,i as p,l as m,n as h,o as g,r as _,s as v,t as y,u as b}from"./SessionBrowserPane-DzZvN-iz.js";import{t as x}from"./earth-Ddy13fHh.js";import{a as S,o as C}from"./GitDiffViewer-D6X8UoVx.js";import{b as w}from"./side-chat-context-D9g8NFwu.js";import{t as T}from"./undo-2-ChaURM4t.js";import{t as E}from"./link-2-mgasYn21.js";import{t as D}from"./list-todo-hpikYm6Q.js";import{t as O}from"./message-square-SKjZyY3v.js";import{t as k}from"./plus-fQbSqB1n.js";import{t as A}from"./refresh-cw-TbWxTY4K.js";import{t as j}from"./square-terminal-BVG6cUT1.js";import{t as M}from"./x-07u4-129.js";import{n as N,t as P}from"./button-CCcCN8tE.js";import{s as F}from"./events-BgoXNekW.js";import{a as I,n as L,o as ee,t as te}from"./sheet-BTaIEX4w.js";import{t as R}from"./input-CPw-zkYh.js";import{n as z,t as B}from"./PageState-Cz6vFMXv.js";import{l as ne,r as V,u as re}from"./session-web-preview-BUv0rBHy.js";import"./public-CvQSuCpU.js";import{n as ie}from"./terminal-context-aIsIJPn8.js";var H=e(n(),1),U=r(),W=(0,H.lazy)(()=>t(()=>import(`./GitDiffViewer-D6X8UoVx.js`).then(e=>e.n).then(e=>({default:e.GitDiffDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]))),G=100;function ae({sessionId:e,streaming:t,requestConfirm:n,view:r,onViewChange:a}){let{t:o}=i(),s=S(r?.reading?.list,e=>a?.({reading:{...r?.reading,list:e}})),[c,d]=(0,H.useState)([]),f=r?.expandedFiles||c,p=e=>a?a({expandedFiles:e}):d(e),{changes:h,loading:g,running:_,diff:y,setDiff:b,diffLoading:x,snapshotRevision:w,writesDisabled:E,pendingCount:D,reversibleCount:O,displayedError:k,notice:j,viewDiff:M,runAction:F,refresh:I}=v({sessionId:e,streaming:t,requestConfirm:n}),L=`max-[650px]:size-11 pointer-coarse:size-11`;return(0,U.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":o(`chat:focusSession.fileChanges`),"aria-busy":g||!!_,children:[(0,U.jsxs)(`header`,{className:`flex min-h-10 min-w-0 shrink-0 items-center gap-2 border-b border-stroke-soft pr-1.5 pl-3`,children:[(0,U.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-xs font-medium tracking-[.02em] text-content-muted`,children:o(`chat:focusSession.fileChanges`)}),h&&(0,U.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums`,children:[(0,U.jsxs)(`span`,{className:`text-success`,children:[`+`,h.summary.added]}),` `,(0,U.jsxs)(`span`,{className:`text-danger`,children:[`−`,h.summary.removed]})]}),(0,U.jsx)(P,{type:`button`,variant:`ghost`,size:`icon`,className:L,"aria-label":o(`chat:focusSession.gitRefresh`),title:o(`chat:focusSession.gitRefresh`),disabled:g||!!_,onClick:I,children:(0,U.jsx)(A,{className:g?`animate-spin`:``,size:15})})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-stroke-soft px-3 py-2.5`,children:[h&&(0,U.jsxs)(`p`,{className:`text-xs text-content-secondary tabular-nums`,children:[o(`chat:focusSession.fileChangesCount`,{count:h.summary.files}),D>0&&` · ${o(`chat:focusSession.fileChangesPending`,{count:D})}`]}),(0,U.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:o(`chat:workbench.taskSnapshotScope`)}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-1`,children:[(0,U.jsxs)(`div`,{className:`flex gap-1`,children:[(0,U.jsxs)(P,{type:`button`,variant:`secondary`,size:`sm`,disabled:E||D===0,title:t?o(`chat:focusSession.gitWaitForRunToFinish`):void 0,onClick:()=>void F({kind:`approve`}),children:[_?.kind===`approve`&&!_.path?(0,U.jsx)(A,{className:`animate-spin`,size:14}):(0,U.jsx)(l,{size:14}),o(`chat:focusSession.fileChangesApproveAll`)]}),(0,U.jsxs)(P,{type:`button`,variant:`secondary`,size:`sm`,disabled:E||O===0,title:o(t?`chat:focusSession.gitWaitForRunToFinish`:`chat:focusSession.fileChangesRevertAllDescription`),onClick:()=>void F({kind:`revert`}),children:[_?.kind===`revert`&&!_.path?(0,U.jsx)(A,{className:`animate-spin`,size:14}):(0,U.jsx)(T,{size:14}),o(`chat:focusSession.fileChangesRevertAll`)]})]}),(0,U.jsxs)(`div`,{className:`flex gap-1`,children:[(0,U.jsx)(P,{variant:`ghost`,size:`sm`,disabled:g||!h?.files.length,onClick:()=>p(h?.files.slice(0,G).map(e=>e.path)||[]),children:o(`chat:workbench.expandAll`)}),(0,U.jsx)(P,{variant:`ghost`,size:`sm`,onClick:()=>p([]),children:o(`chat:workbench.collapseAll`)})]})]})]}),k&&(0,U.jsx)(`p`,{role:`alert`,className:`px-3 pt-2.5 text-xs text-danger`,children:k}),j&&!k&&(0,U.jsx)(`p`,{role:`status`,className:`px-3 pt-2.5 text-xs text-content-secondary`,children:j}),g&&!h?(0,U.jsx)(z,{kind:`loading`,title:o(`chat:focusSession.gitLoading`)}):h?.files.length?(0,U.jsxs)(`ul`,{ref:s.ref,className:`min-h-0 flex-1 overflow-y-auto`,"aria-label":o(`chat:focusSession.fileChanges`),children:[h.files.slice(0,G).map(t=>{let n=f.includes(t.path);return(0,U.jsxs)(`li`,{className:`min-w-0 border-b border-stroke-soft`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-0.5 pr-1.5 hover:bg-surface-subtle ${n?`bg-surface-subtle`:``}`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`flex min-h-9 min-w-0 flex-1 items-center gap-2 pl-2 text-left text-xs focus-visible:-outline-offset-2 disabled:opacity-60 max-[650px]:min-h-11 pointer-coarse:min-h-11`,title:t.path,disabled:g||!!_,"aria-busy":x===t.path,"aria-expanded":n,onClick:()=>p(n?f.filter(e=>e!==t.path):[...f,t.path]),children:[(0,U.jsx)(u,{size:14,className:`shrink-0 text-content-muted transition-transform duration-(--d-fast) ${n?`rotate-90`:``}`}),x===t.path?(0,U.jsx)(N,{className:`size-3.5`}):(0,U.jsx)(C,{size:14,className:`flex-none text-content-muted`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:t.path}),(t.reverted||t.approved)&&(0,U.jsx)(`span`,{className:`shrink-0 text-content-muted`,children:t.reverted?o(`chat:focusSession.fileChangesReverted`):o(`chat:focusSession.fileChangesApproved`)}),(0,U.jsxs)(`span`,{className:`shrink-0 font-mono tabular-nums`,children:[(0,U.jsxs)(`span`,{className:`text-success`,children:[`+`,t.added]}),` `,(0,U.jsxs)(`span`,{className:`text-danger`,children:[`−`,t.removed]})]})]}),(0,U.jsx)(P,{type:`button`,variant:`ghost`,size:`icon`,className:L,title:o(`chat:focusSession.fileChangesApproveFile`),"aria-label":`${o(`chat:focusSession.fileChangesApproveFile`)} ${t.path}`,disabled:E||!t.pending||t.approved||t.reverted,onClick:()=>void F({kind:`approve`,path:t.path}),children:(0,U.jsx)(l,{size:14})}),(0,U.jsx)(P,{type:`button`,variant:`ghost`,size:`icon`,className:L,title:o(`chat:focusSession.fileChangesRevertFile`),"aria-label":`${o(`chat:focusSession.fileChangesRevertFile`)} ${t.path}`,disabled:E||t.reverted||!t.canRevert,onClick:()=>void F({kind:`revert`,path:t.path}),children:(0,U.jsx)(T,{size:14})})]}),n&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(m,{sessionId:e,path:t.path,scope:`task`,position:r?.reading?.[t.path],onReading:e=>a?.({reading:{...r?.reading,[t.path]:e}}),revision:w}),(0,U.jsx)(P,{variant:`ghost`,size:`sm`,className:`m-1.5`,onClick:()=>void M(t.path),children:o(`chat:workbench.fullDiff`)})]})]},t.path)}),h.files.length>G&&(0,U.jsx)(`li`,{className:`px-3 py-2 text-xs text-content-muted tabular-nums`,children:o(`chat:focusSession.gitMoreFiles`,{count:h.files.length-G})})]}):!k&&(0,U.jsx)(B,{compact:!0,title:o(`chat:focusSession.fileChangesEmpty`)}),y&&(0,U.jsx)(H.Suspense,{fallback:null,children:(0,U.jsx)(W,{diff:y.diff,truncated:y.truncated,onClose:()=>b(null)})})]})}function oe({tools:e,onSelect:t,onOpenUrl:n}){let{t:r}=i(),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(!1);return(0,U.jsxs)(`section`,{className:`@container/new-tab flex min-h-0 flex-1 flex-col overflow-y-auto bg-panel p-4`,children:[(0,U.jsx)(`h2`,{className:`mb-3 text-sm font-medium text-content`,children:r(`chat:workbench.newTab`)}),(0,U.jsxs)(`form`,{className:`mb-4 flex gap-2`,onSubmit:e=>{e.preventDefault();let t=_(a,window.location.href);c(!t),t&&n(t.url)},children:[(0,U.jsx)(R,{className:`font-mono`,"aria-label":r(`common:webPreview.url`),placeholder:r(`common:webPreview.urlPlaceholder`),value:a,maxLength:2048,onChange:e=>o(e.target.value)}),(0,U.jsx)(P,{type:`submit`,variant:`secondary`,children:r(`chat:sessionContext.openUrl`)})]}),s&&(0,U.jsx)(`p`,{role:`alert`,className:`mb-3 text-xs text-danger`,children:r(`chat:sessionContext.invalidUrl`)}),(0,U.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5 @min-[420px]/new-tab:grid-cols-2`,children:e.map(({id:e,label:n,icon:r,disabled:i})=>(0,U.jsxs)(P,{disabled:i,variant:`ghost`,className:`h-10 min-w-0 justify-start gap-2.5 border-stroke bg-panel px-3 font-normal text-content max-[650px]:h-11 pointer-coarse:h-11 [&_svg]:text-content-muted`,onClick:()=>t(e),children:[(0,U.jsx)(r,{className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate`,children:n})]},e))})]})}function K({panelId:e,compact:t,embedded:n=!1,active:r=!0,sessionId:l,cwd:u=``,sources:m=[],tab:_,plan:v,streaming:S,plansAvailable:T,requestConfirm:A,onTabChange:N,onClose:R,onBack:z}){let{t:W}=i(),G=ie(),K=o(e=>e.capabilities),q=[{id:`terminal`,icon:j,label:W(`terminal:workspace.terminal`)},{id:`processes`,icon:s,label:W(`terminal:workspace.processes`)},{id:`changes`,icon:C,label:W(`chat:workbench.projectChanges`)},{id:`sources`,icon:E,label:W(`chat:workbench.sources`)},{id:`files`,icon:w,label:W(`chat:workbench.taskSnapshots`)},...T?[{id:`plan`,icon:D,label:W(`chat:sessionContext.plan`)}]:[],{id:`browser`,icon:x,label:W(`common:webPreview.title`)},{id:`side-chat`,icon:O,label:W(`chat:sideChat.title`)}],se=(0,H.useMemo)(()=>ne(_),[_]),J=V(e=>Object.prototype.hasOwnProperty.call(e.sessions,l)?e.sessions[l]:void 0)??se,ce=(0,H.useRef)(null),Y=J.pages.find(e=>e.id===J.activeId)??J.pages[0],X=e=>e.kind===`new`?{id:`new`,icon:k,label:W(`chat:workbench.newTab`)}:q.find(t=>t.id===e.kind)??q[0],le=t=>requestAnimationFrame(()=>document.getElementById(`${e}-${t}-tab`)?.focus()),ue=(0,H.useEffectEvent)(()=>{r&&document.getElementById(`${e}-${J.activeId}-tab`)?.focus()});(0,H.useEffect)(()=>{let e=requestAnimationFrame(()=>ue());return()=>cancelAnimationFrame(e)},[e,J.activeId]);let Z=e=>{if(e.type===`view`&&!V.getState().sessions[l])return;[`add`,`open`,`select`,`close`,`kind`].includes(e.type)&&window.dispatchEvent(new Event(F));let t=re(J,e);V.getState().update(l,_,e);let n=t.pages.find(e=>e.id===t.activeId);n&&N(n.kind),(e.type===`add`||e.type===`select`||e.type===`close`)&&le(t.activeId),e.type===`close`&&J.pages.length===1&&R()},Q=W(`chat:sessionContext.addPage`),de=W(`chat:sessionContext.pageLimit`),fe=(0,U.jsx)(P,{variant:`ghost`,size:`icon`,className:`max-[650px]:size-11`,disabled:J.pages.length>=12,"aria-label":Q,title:J.pages.length>=12?de:Q,onClick:()=>Z({type:`add`,kind:`new`}),children:(0,U.jsx)(k,{size:16})}),$=(0,U.jsxs)(`div`,{"data-session-context-panel":!0,className:`flex h-full min-h-0 min-w-0 flex-col bg-panel text-content`,children:[(0,U.jsxs)(`header`,{"data-window-drag-region":!0,className:`auxiliary-page-header flex h-12 shrink-0 items-center gap-1 border-b border-stroke-soft px-2`,children:[z&&(0,U.jsx)(P,{variant:`ghost`,size:`icon`,className:`max-[650px]:size-11`,"aria-label":W(`chat:workbench.backToConversation`),title:W(`chat:workbench.backToConversation`),onClick:z,children:(0,U.jsx)(c,{size:16})}),(0,U.jsx)(`div`,{ref:ce,className:`flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto px-px py-1 [scrollbar-width:none]`,role:`tablist`,"aria-label":W(`chat:sessionContext.title`),onKeyDown:e=>{if(!(e.target instanceof HTMLElement)||e.target.getAttribute(`role`)!==`tab`)return;if(e.key===`Delete`){e.preventDefault(),Z({type:`close`,id:Y.id});return}if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=J.pages.findIndex(e=>e.id===Y.id),n=e.key===`Home`?0:e.key===`End`?J.pages.length-1:(t+(e.key===`ArrowRight`?1:-1)+J.pages.length)%J.pages.length;Z({type:`select`,id:J.pages[n].id})},children:J.pages.map(t=>{let{icon:n,label:r}=X(t);return(0,U.jsxs)(`div`,{className:`relative flex max-w-40 min-w-20 shrink-0 items-center rounded-sm transition-colors duration-(--d-fast) ${t.id===Y.id?`bg-key font-medium text-content shadow-key ring-1 ring-key-border after:absolute after:inset-x-2 after:bottom-0 after:h-0.5 after:rounded-full after:bg-star`:`text-content-muted hover:bg-surface-hover hover:text-content`}`,children:[(0,U.jsxs)(`button`,{id:`${e}-${t.id}-tab`,type:`button`,role:`tab`,"aria-selected":t.id===Y.id,"aria-controls":`${e}-${t.id}-content`,tabIndex:t.id===Y.id?0:-1,className:`flex h-7 min-w-0 flex-1 items-center gap-1.5 rounded-sm pl-2 text-sm focus-visible:outline-offset-0 max-[650px]:h-11`,onClick:()=>Z({type:`select`,id:t.id}),children:[(0,U.jsx)(n,{size:14,className:`shrink-0`}),(0,U.jsx)(`span`,{className:`truncate`,children:r})]}),(0,U.jsx)(`button`,{type:`button`,className:`mx-0.5 grid size-5 shrink-0 place-items-center rounded-xs text-content-muted hover:bg-surface-hover hover:text-content focus-visible:outline-offset-0 max-[650px]:size-11`,"aria-label":`${W(`chat:sessionContext.closePage`)} · ${r}`,onClick:()=>Z({type:`close`,id:t.id}),children:(0,U.jsx)(M,{size:12})})]},t.id)})}),fe]}),J.pages.map(t=>{let n=X(t),r=Y.id===t.id;return(0,U.jsx)(`div`,{id:`${e}-${t.id}-content`,role:`tabpanel`,"aria-labelledby":`${e}-${t.id}-tab`,className:r?`flex min-h-0 flex-1 flex-col`:`hidden`,hidden:!r,children:n.id===`new`?r&&(0,U.jsx)(oe,{tools:q.map(e=>({...e,disabled:e.id===`terminal`||e.id===`processes`?!G||!a(K,`terminal`):e.id===`changes`&&!a(K,`vcs`)})),onOpenUrl:e=>{Z({type:`open`,kind:`browser`,replaceId:t.id}),V.getState().update(l,`browser`,{type:`browser`,id:t.id,url:e,draft:e})},onSelect:e=>Z({type:`open`,kind:e,replaceId:t.id})}):n.id===`changes`?r&&(0,U.jsx)(f,{sessionId:l,cwd:u,streaming:S,view:t.view,onViewChange:e=>Z({type:`view`,id:t.id,patch:e})}):n.id===`sources`?r&&(0,U.jsx)(p,{sources:m,view:t.view,onViewChange:e=>Z({type:`view`,id:t.id,patch:e})}):n.id===`terminal`?r&&(0,U.jsx)(g,{sessionId:l,cwd:u,terminalId:t.resourceId||void 0,onCreated:e=>V.getState().update(l,_,{type:`resource`,id:t.id,resourceId:e})}):n.id===`processes`?r&&(0,U.jsx)(d,{view:t.view,onViewChange:e=>Z({type:`view`,id:t.id,patch:e}),sessionId:l,onOpenTerminal:e=>Z({type:`open`,kind:`terminal`,resourceId:e})}):n.id===`side-chat`?(0,U.jsx)(h,{parentId:l,active:r}):n.id===`browser`?(0,U.jsx)(y,{sessionId:l,page:t,onChange:e=>Z({type:`browser`,id:t.id,...e}),onClosed:()=>Z({type:`close`,id:t.id})}):r&&(n.id===`files`?(0,U.jsx)(ae,{view:t.view,onViewChange:e=>Z({type:`view`,id:t.id,patch:e}),sessionId:l,streaming:S,requestConfirm:A}):(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:v?.items?.length?(0,U.jsx)(b,{plan:v,running:S}):(0,U.jsx)(B,{compact:!0,title:W(`chat:sessionContext.planEmpty`)})}))},t.id)})]});return t?(0,U.jsx)(te,{open:!0,onOpenChange:e=>!e&&R(),children:(0,U.jsxs)(L,{id:e,side:`right`,showCloseButton:!1,className:`gap-0 overflow-hidden p-0`,style:{top:`var(--pisper-safe-area-top)`,right:`var(--pisper-safe-area-right)`,bottom:`var(--pisper-safe-area-bottom)`,height:`auto`,width:`min(calc(100vw - var(--pisper-safe-area-left) - var(--pisper-safe-area-right)), 420px)`,maxWidth:`none`},children:[(0,U.jsx)(I,{className:`sr-only`,children:(0,U.jsx)(ee,{children:W(`chat:sessionContext.title`)})}),$]})}):(0,U.jsx)(`aside`,{id:e,tabIndex:n?-1:void 0,className:`h-full min-h-0 w-full overflow-hidden border-l border-stroke bg-panel`,"aria-label":W(`chat:sessionContext.title`),children:$})}export{K as SessionContextPanel};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitDiffViewer-BFdi1mxr.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-DwNgTV1j.js","assets/use-i18n-CsOCclo6.js","assets/i18n-DyMZgkZI.js","assets/vendor-router-CSN_DGvx.js","assets/index-CiyAfWLi.js","assets/index-j6s460ui.css","assets/storage-DtvZ_lEu.js","assets/vendor-state-GkUciC5H.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/x-07u4-129.js","assets/utils-C8uzG5AZ.js","assets/vendor-ui-DvrYggeS.js","assets/button-CCcCN8tE.js","assets/dist-41X0pdUs.js","assets/events-C8OUQmIW.js","assets/esm-DCV8yILT.js"])))=>i.map(i=>d[i]);
2
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t}from"./vendor-router-CSN_DGvx.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{t as i}from"./use-i18n-CsOCclo6.js";import{i as a}from"./runtime-capabilities-ChJVNwRz.js";import{t as o}from"./runtime-capabilities-store-MtXRlSIi.js";import{t as s}from"./activity-BCxvXCG3.js";import{t as c}from"./arrow-left-B8oVrQ2S.js";import{t as l}from"./check-2vYc6QaP.js";import{t as u}from"./chevron-right-C3t2Rckj.js";import{a as d,c as f,i as p,l as m,n as h,o as g,r as _,s as v,t as y,u as b}from"./SessionBrowserPane-DeOqkbLQ.js";import{t as x}from"./earth-Ddy13fHh.js";import{a as S,o as C}from"./GitDiffViewer-BFdi1mxr.js";import{b as w}from"./side-chat-context-C7vwSBGo.js";import{t as T}from"./undo-2-ChaURM4t.js";import{t as E}from"./link-2-mgasYn21.js";import{t as D}from"./list-todo-hpikYm6Q.js";import{t as O}from"./message-square-SKjZyY3v.js";import{t as k}from"./plus-fQbSqB1n.js";import{t as A}from"./refresh-cw-TbWxTY4K.js";import{t as j}from"./square-terminal-BVG6cUT1.js";import{t as M}from"./x-07u4-129.js";import{n as N,t as P}from"./button-CCcCN8tE.js";import{s as F}from"./events-C8OUQmIW.js";import{a as I,n as L,o as ee,t as te}from"./sheet-BTaIEX4w.js";import{t as R}from"./input-CPw-zkYh.js";import{n as z,t as B}from"./PageState-Cz6vFMXv.js";import{l as ne,r as V,u as re}from"./session-web-preview-DZOVkeBU.js";import"./public-lAWjPSYc.js";import{n as ie}from"./terminal-context-aIsIJPn8.js";var H=e(n(),1),U=r(),W=(0,H.lazy)(()=>t(()=>import(`./GitDiffViewer-BFdi1mxr.js`).then(e=>e.n).then(e=>({default:e.GitDiffDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]))),G=100;function ae({sessionId:e,streaming:t,requestConfirm:n,view:r,onViewChange:a}){let{t:o}=i(),s=S(r?.reading?.list,e=>a?.({reading:{...r?.reading,list:e}})),[c,d]=(0,H.useState)([]),f=r?.expandedFiles||c,p=e=>a?a({expandedFiles:e}):d(e),{changes:h,loading:g,running:_,diff:y,setDiff:b,diffLoading:x,snapshotRevision:w,writesDisabled:E,pendingCount:D,reversibleCount:O,displayedError:k,notice:j,viewDiff:M,runAction:F,refresh:I}=v({sessionId:e,streaming:t,requestConfirm:n}),L=`max-[650px]:size-11 pointer-coarse:size-11`;return(0,U.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":o(`chat:focusSession.fileChanges`),"aria-busy":g||!!_,children:[(0,U.jsxs)(`header`,{className:`flex min-h-10 min-w-0 shrink-0 items-center gap-2 border-b border-stroke-soft pr-1.5 pl-3`,children:[(0,U.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-xs font-medium tracking-[.02em] text-content-muted`,children:o(`chat:focusSession.fileChanges`)}),h&&(0,U.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums`,children:[(0,U.jsxs)(`span`,{className:`text-success`,children:[`+`,h.summary.added]}),` `,(0,U.jsxs)(`span`,{className:`text-danger`,children:[`−`,h.summary.removed]})]}),(0,U.jsx)(P,{type:`button`,variant:`ghost`,size:`icon`,className:L,"aria-label":o(`chat:focusSession.gitRefresh`),title:o(`chat:focusSession.gitRefresh`),disabled:g||!!_,onClick:I,children:(0,U.jsx)(A,{className:g?`animate-spin`:``,size:15})})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-stroke-soft px-3 py-2.5`,children:[h&&(0,U.jsxs)(`p`,{className:`text-xs text-content-secondary tabular-nums`,children:[o(`chat:focusSession.fileChangesCount`,{count:h.summary.files}),D>0&&` · ${o(`chat:focusSession.fileChangesPending`,{count:D})}`]}),(0,U.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:o(`chat:workbench.taskSnapshotScope`)}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-1`,children:[(0,U.jsxs)(`div`,{className:`flex gap-1`,children:[(0,U.jsxs)(P,{type:`button`,variant:`secondary`,size:`sm`,disabled:E||D===0,title:t?o(`chat:focusSession.gitWaitForRunToFinish`):void 0,onClick:()=>void F({kind:`approve`}),children:[_?.kind===`approve`&&!_.path?(0,U.jsx)(A,{className:`animate-spin`,size:14}):(0,U.jsx)(l,{size:14}),o(`chat:focusSession.fileChangesApproveAll`)]}),(0,U.jsxs)(P,{type:`button`,variant:`secondary`,size:`sm`,disabled:E||O===0,title:o(t?`chat:focusSession.gitWaitForRunToFinish`:`chat:focusSession.fileChangesRevertAllDescription`),onClick:()=>void F({kind:`revert`}),children:[_?.kind===`revert`&&!_.path?(0,U.jsx)(A,{className:`animate-spin`,size:14}):(0,U.jsx)(T,{size:14}),o(`chat:focusSession.fileChangesRevertAll`)]})]}),(0,U.jsxs)(`div`,{className:`flex gap-1`,children:[(0,U.jsx)(P,{variant:`ghost`,size:`sm`,disabled:g||!h?.files.length,onClick:()=>p(h?.files.slice(0,G).map(e=>e.path)||[]),children:o(`chat:workbench.expandAll`)}),(0,U.jsx)(P,{variant:`ghost`,size:`sm`,onClick:()=>p([]),children:o(`chat:workbench.collapseAll`)})]})]})]}),k&&(0,U.jsx)(`p`,{role:`alert`,className:`px-3 pt-2.5 text-xs text-danger`,children:k}),j&&!k&&(0,U.jsx)(`p`,{role:`status`,className:`px-3 pt-2.5 text-xs text-content-secondary`,children:j}),g&&!h?(0,U.jsx)(z,{kind:`loading`,title:o(`chat:focusSession.gitLoading`)}):h?.files.length?(0,U.jsxs)(`ul`,{ref:s.ref,className:`min-h-0 flex-1 overflow-y-auto`,"aria-label":o(`chat:focusSession.fileChanges`),children:[h.files.slice(0,G).map(t=>{let n=f.includes(t.path);return(0,U.jsxs)(`li`,{className:`min-w-0 border-b border-stroke-soft`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-0.5 pr-1.5 hover:bg-surface-subtle ${n?`bg-surface-subtle`:``}`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`flex min-h-9 min-w-0 flex-1 items-center gap-2 pl-2 text-left text-xs focus-visible:-outline-offset-2 disabled:opacity-60 max-[650px]:min-h-11 pointer-coarse:min-h-11`,title:t.path,disabled:g||!!_,"aria-busy":x===t.path,"aria-expanded":n,onClick:()=>p(n?f.filter(e=>e!==t.path):[...f,t.path]),children:[(0,U.jsx)(u,{size:14,className:`shrink-0 text-content-muted transition-transform duration-(--d-fast) ${n?`rotate-90`:``}`}),x===t.path?(0,U.jsx)(N,{className:`size-3.5`}):(0,U.jsx)(C,{size:14,className:`flex-none text-content-muted`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:t.path}),(t.reverted||t.approved)&&(0,U.jsx)(`span`,{className:`shrink-0 text-content-muted`,children:t.reverted?o(`chat:focusSession.fileChangesReverted`):o(`chat:focusSession.fileChangesApproved`)}),(0,U.jsxs)(`span`,{className:`shrink-0 font-mono tabular-nums`,children:[(0,U.jsxs)(`span`,{className:`text-success`,children:[`+`,t.added]}),` `,(0,U.jsxs)(`span`,{className:`text-danger`,children:[`−`,t.removed]})]})]}),(0,U.jsx)(P,{type:`button`,variant:`ghost`,size:`icon`,className:L,title:o(`chat:focusSession.fileChangesApproveFile`),"aria-label":`${o(`chat:focusSession.fileChangesApproveFile`)} ${t.path}`,disabled:E||!t.pending||t.approved||t.reverted,onClick:()=>void F({kind:`approve`,path:t.path}),children:(0,U.jsx)(l,{size:14})}),(0,U.jsx)(P,{type:`button`,variant:`ghost`,size:`icon`,className:L,title:o(`chat:focusSession.fileChangesRevertFile`),"aria-label":`${o(`chat:focusSession.fileChangesRevertFile`)} ${t.path}`,disabled:E||t.reverted||!t.canRevert,onClick:()=>void F({kind:`revert`,path:t.path}),children:(0,U.jsx)(T,{size:14})})]}),n&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(m,{sessionId:e,path:t.path,scope:`task`,position:r?.reading?.[t.path],onReading:e=>a?.({reading:{...r?.reading,[t.path]:e}}),revision:w}),(0,U.jsx)(P,{variant:`ghost`,size:`sm`,className:`m-1.5`,onClick:()=>void M(t.path),children:o(`chat:workbench.fullDiff`)})]})]},t.path)}),h.files.length>G&&(0,U.jsx)(`li`,{className:`px-3 py-2 text-xs text-content-muted tabular-nums`,children:o(`chat:focusSession.gitMoreFiles`,{count:h.files.length-G})})]}):!k&&(0,U.jsx)(B,{compact:!0,title:o(`chat:focusSession.fileChangesEmpty`)}),y&&(0,U.jsx)(H.Suspense,{fallback:null,children:(0,U.jsx)(W,{diff:y.diff,truncated:y.truncated,onClose:()=>b(null)})})]})}function oe({tools:e,onSelect:t,onOpenUrl:n}){let{t:r}=i(),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(!1);return(0,U.jsxs)(`section`,{className:`@container/new-tab flex min-h-0 flex-1 flex-col overflow-y-auto bg-panel p-4`,children:[(0,U.jsx)(`h2`,{className:`mb-3 text-sm font-medium text-content`,children:r(`chat:workbench.newTab`)}),(0,U.jsxs)(`form`,{className:`mb-4 flex gap-2`,onSubmit:e=>{e.preventDefault();let t=_(a,window.location.href);c(!t),t&&n(t.url)},children:[(0,U.jsx)(R,{className:`font-mono`,"aria-label":r(`common:webPreview.url`),placeholder:r(`common:webPreview.urlPlaceholder`),value:a,maxLength:2048,onChange:e=>o(e.target.value)}),(0,U.jsx)(P,{type:`submit`,variant:`secondary`,children:r(`chat:sessionContext.openUrl`)})]}),s&&(0,U.jsx)(`p`,{role:`alert`,className:`mb-3 text-xs text-danger`,children:r(`chat:sessionContext.invalidUrl`)}),(0,U.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5 @min-[420px]/new-tab:grid-cols-2`,children:e.map(({id:e,label:n,icon:r,disabled:i})=>(0,U.jsxs)(P,{disabled:i,variant:`ghost`,className:`h-10 min-w-0 justify-start gap-2.5 border-stroke bg-panel px-3 font-normal text-content max-[650px]:h-11 pointer-coarse:h-11 [&_svg]:text-content-muted`,onClick:()=>t(e),children:[(0,U.jsx)(r,{className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate`,children:n})]},e))})]})}function K({panelId:e,compact:t,embedded:n=!1,active:r=!0,sessionId:l,cwd:u=``,sources:m=[],tab:_,plan:v,streaming:S,plansAvailable:T,requestConfirm:A,onTabChange:N,onClose:R,onBack:z}){let{t:W}=i(),G=ie(),K=o(e=>e.capabilities),q=[{id:`terminal`,icon:j,label:W(`terminal:workspace.terminal`)},{id:`processes`,icon:s,label:W(`terminal:workspace.processes`)},{id:`changes`,icon:C,label:W(`chat:workbench.projectChanges`)},{id:`sources`,icon:E,label:W(`chat:workbench.sources`)},{id:`files`,icon:w,label:W(`chat:workbench.taskSnapshots`)},...T?[{id:`plan`,icon:D,label:W(`chat:sessionContext.plan`)}]:[],{id:`browser`,icon:x,label:W(`common:webPreview.title`)},{id:`side-chat`,icon:O,label:W(`chat:sideChat.title`)}],se=(0,H.useMemo)(()=>ne(_),[_]),J=V(e=>Object.prototype.hasOwnProperty.call(e.sessions,l)?e.sessions[l]:void 0)??se,ce=(0,H.useRef)(null),Y=J.pages.find(e=>e.id===J.activeId)??J.pages[0],X=e=>e.kind===`new`?{id:`new`,icon:k,label:W(`chat:workbench.newTab`)}:q.find(t=>t.id===e.kind)??q[0],le=t=>requestAnimationFrame(()=>document.getElementById(`${e}-${t}-tab`)?.focus()),ue=(0,H.useEffectEvent)(()=>{r&&document.getElementById(`${e}-${J.activeId}-tab`)?.focus()});(0,H.useEffect)(()=>{let e=requestAnimationFrame(()=>ue());return()=>cancelAnimationFrame(e)},[e,J.activeId]);let Z=e=>{if(e.type===`view`&&!V.getState().sessions[l])return;[`add`,`open`,`select`,`close`,`kind`].includes(e.type)&&window.dispatchEvent(new Event(F));let t=re(J,e);V.getState().update(l,_,e);let n=t.pages.find(e=>e.id===t.activeId);n&&N(n.kind),(e.type===`add`||e.type===`select`||e.type===`close`)&&le(t.activeId),e.type===`close`&&J.pages.length===1&&R()},Q=W(`chat:sessionContext.addPage`),de=W(`chat:sessionContext.pageLimit`),fe=(0,U.jsx)(P,{variant:`ghost`,size:`icon`,className:`max-[650px]:size-11`,disabled:J.pages.length>=12,"aria-label":Q,title:J.pages.length>=12?de:Q,onClick:()=>Z({type:`add`,kind:`new`}),children:(0,U.jsx)(k,{size:16})}),$=(0,U.jsxs)(`div`,{"data-session-context-panel":!0,className:`flex h-full min-h-0 min-w-0 flex-col bg-panel text-content`,children:[(0,U.jsxs)(`header`,{"data-window-drag-region":!0,className:`auxiliary-page-header flex h-12 shrink-0 items-center gap-1 border-b border-stroke-soft px-2`,children:[z&&(0,U.jsx)(P,{variant:`ghost`,size:`icon`,className:`max-[650px]:size-11`,"aria-label":W(`chat:workbench.backToConversation`),title:W(`chat:workbench.backToConversation`),onClick:z,children:(0,U.jsx)(c,{size:16})}),(0,U.jsx)(`div`,{ref:ce,className:`flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto px-px py-1 [scrollbar-width:none]`,role:`tablist`,"aria-label":W(`chat:sessionContext.title`),onKeyDown:e=>{if(!(e.target instanceof HTMLElement)||e.target.getAttribute(`role`)!==`tab`)return;if(e.key===`Delete`){e.preventDefault(),Z({type:`close`,id:Y.id});return}if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=J.pages.findIndex(e=>e.id===Y.id),n=e.key===`Home`?0:e.key===`End`?J.pages.length-1:(t+(e.key===`ArrowRight`?1:-1)+J.pages.length)%J.pages.length;Z({type:`select`,id:J.pages[n].id})},children:J.pages.map(t=>{let{icon:n,label:r}=X(t);return(0,U.jsxs)(`div`,{className:`relative flex max-w-40 min-w-20 shrink-0 items-center rounded-sm transition-colors duration-(--d-fast) ${t.id===Y.id?`bg-key font-medium text-content shadow-key ring-1 ring-key-border after:absolute after:inset-x-2 after:bottom-0 after:h-0.5 after:rounded-full after:bg-star`:`text-content-muted hover:bg-surface-hover hover:text-content`}`,children:[(0,U.jsxs)(`button`,{id:`${e}-${t.id}-tab`,type:`button`,role:`tab`,"aria-selected":t.id===Y.id,"aria-controls":`${e}-${t.id}-content`,tabIndex:t.id===Y.id?0:-1,className:`flex h-7 min-w-0 flex-1 items-center gap-1.5 rounded-sm pl-2 text-sm focus-visible:outline-offset-0 max-[650px]:h-11`,onClick:()=>Z({type:`select`,id:t.id}),children:[(0,U.jsx)(n,{size:14,className:`shrink-0`}),(0,U.jsx)(`span`,{className:`truncate`,children:r})]}),(0,U.jsx)(`button`,{type:`button`,className:`mx-0.5 grid size-5 shrink-0 place-items-center rounded-xs text-content-muted hover:bg-surface-hover hover:text-content focus-visible:outline-offset-0 max-[650px]:size-11`,"aria-label":`${W(`chat:sessionContext.closePage`)} · ${r}`,onClick:()=>Z({type:`close`,id:t.id}),children:(0,U.jsx)(M,{size:12})})]},t.id)})}),fe]}),J.pages.map(t=>{let n=X(t),r=Y.id===t.id;return(0,U.jsx)(`div`,{id:`${e}-${t.id}-content`,role:`tabpanel`,"aria-labelledby":`${e}-${t.id}-tab`,className:r?`flex min-h-0 flex-1 flex-col`:`hidden`,hidden:!r,children:n.id===`new`?r&&(0,U.jsx)(oe,{tools:q.map(e=>({...e,disabled:e.id===`terminal`||e.id===`processes`?!G||!a(K,`terminal`):e.id===`changes`&&!a(K,`vcs`)})),onOpenUrl:e=>{Z({type:`open`,kind:`browser`,replaceId:t.id}),V.getState().update(l,`browser`,{type:`browser`,id:t.id,url:e,draft:e})},onSelect:e=>Z({type:`open`,kind:e,replaceId:t.id})}):n.id===`changes`?r&&(0,U.jsx)(f,{sessionId:l,cwd:u,streaming:S,view:t.view,onViewChange:e=>Z({type:`view`,id:t.id,patch:e})}):n.id===`sources`?r&&(0,U.jsx)(p,{sources:m,view:t.view,onViewChange:e=>Z({type:`view`,id:t.id,patch:e})}):n.id===`terminal`?r&&(0,U.jsx)(g,{sessionId:l,cwd:u,terminalId:t.resourceId||void 0,onCreated:e=>V.getState().update(l,_,{type:`resource`,id:t.id,resourceId:e})}):n.id===`processes`?r&&(0,U.jsx)(d,{view:t.view,onViewChange:e=>Z({type:`view`,id:t.id,patch:e}),sessionId:l,onOpenTerminal:e=>Z({type:`open`,kind:`terminal`,resourceId:e})}):n.id===`side-chat`?(0,U.jsx)(h,{parentId:l,active:r}):n.id===`browser`?(0,U.jsx)(y,{sessionId:l,page:t,onChange:e=>Z({type:`browser`,id:t.id,...e}),onClosed:()=>Z({type:`close`,id:t.id})}):r&&(n.id===`files`?(0,U.jsx)(ae,{view:t.view,onViewChange:e=>Z({type:`view`,id:t.id,patch:e}),sessionId:l,streaming:S,requestConfirm:A}):(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:v?.items?.length?(0,U.jsx)(b,{plan:v,running:S}):(0,U.jsx)(B,{compact:!0,title:W(`chat:sessionContext.planEmpty`)})}))},t.id)})]});return t?(0,U.jsx)(te,{open:!0,onOpenChange:e=>!e&&R(),children:(0,U.jsxs)(L,{id:e,side:`right`,showCloseButton:!1,className:`gap-0 overflow-hidden p-0`,style:{top:`var(--pisper-safe-area-top)`,right:`var(--pisper-safe-area-right)`,bottom:`var(--pisper-safe-area-bottom)`,height:`auto`,width:`min(calc(100vw - var(--pisper-safe-area-left) - var(--pisper-safe-area-right)), 420px)`,maxWidth:`none`},children:[(0,U.jsx)(I,{className:`sr-only`,children:(0,U.jsx)(ee,{children:W(`chat:sessionContext.title`)})}),$]})}):(0,U.jsx)(`aside`,{id:e,tabIndex:n?-1:void 0,className:`h-full min-h-0 w-full overflow-hidden border-l border-stroke bg-panel`,"aria-label":W(`chat:sessionContext.title`),children:$})}export{K as SessionContextPanel};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{u as t}from"./vendor-router-CSN_DGvx.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{h as i,t as a}from"./routes-BYsK6aeM.js";import{t as o}from"./use-i18n-47vsdOU3.js";import{n as s,t as c}from"./usePhoneShell-Bn3ZlBYr.js";import{t as l}from"./button-CCcCN8tE.js";import{a as u}from"./board-projects-wULJ4QMT.js";import"./public-CUh5RfpQ.js";import{PhoneMenuButton as d}from"./PhoneMenuButton-BtAGHyzX.js";import{n as f}from"./PageState-Cz6vFMXv.js";import{n as p,r as m}from"./session-home-cMbldWP4.js";var h=e(n(),1),g=r();function _(e){let{t:n}=o(),r=t(),_=c(),v=s(),y=!_||v,[b]=(0,h.useState)(m),x=u(),S=p({lastId:b,data:x.data,failed:x.isError&&!x.isFetching}),C=S.kind===`session`?i(S.id):S.kind===`draft`?i():``;(0,h.useEffect)(()=>{C&&r(C,{replace:!0,state:a})},[r,C]);let w=(0,g.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-panel`,children:[!y&&(0,g.jsx)(`header`,{className:`flex h-14 shrink-0 items-center bg-panel px-1`,children:(0,g.jsx)(d,{})}),(0,g.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:S.kind===`error`?(0,g.jsx)(f,{kind:`error`,title:n(`board:home.loadFailed`),description:n(`board:home.loadFailedHint`),action:(0,g.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[(0,g.jsx)(l,{variant:`secondary`,className:`pointer-coarse:min-h-11`,onClick:()=>void x.refetch(),children:n(`navigation:more.retry`)}),(0,g.jsx)(l,{variant:`ghost`,className:`pointer-coarse:min-h-11`,onClick:()=>r(i(),{state:a}),children:n(`board:home.startDraft`)})]})}):(0,g.jsx)(f,{kind:`loading`,title:n(`board:home.loading`)})})]});return(0,g.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,"data-session-shell":y?`desktop`:`phone`,"data-session-home":S.kind,children:(0,g.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:w})})}export{_ as SessionHome};
1
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{u as t}from"./vendor-router-CSN_DGvx.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{h as i,t as a}from"./routes-BYsK6aeM.js";import{t as o}from"./use-i18n-CsOCclo6.js";import{n as s,t as c}from"./usePhoneShell-e-CScTJH.js";import{t as l}from"./button-CCcCN8tE.js";import{a as u}from"./board-projects-DjGBcX8k.js";import"./public-Dr8_scp5.js";import{PhoneMenuButton as d}from"./PhoneMenuButton-Coocnsrf.js";import{n as f}from"./PageState-Cz6vFMXv.js";import{n as p,r as m}from"./session-home-CJcIlNWK.js";var h=e(n(),1),g=r();function _(e){let{t:n}=o(),r=t(),_=c(),v=s(),y=!_||v,[b]=(0,h.useState)(m),x=u(),S=p({lastId:b,data:x.data,failed:x.isError&&!x.isFetching}),C=S.kind===`session`?i(S.id):S.kind===`draft`?i():``;(0,h.useEffect)(()=>{C&&r(C,{replace:!0,state:a})},[r,C]);let w=(0,g.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-panel`,children:[!y&&(0,g.jsx)(`header`,{className:`flex h-14 shrink-0 items-center bg-panel px-1`,children:(0,g.jsx)(d,{})}),(0,g.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:S.kind===`error`?(0,g.jsx)(f,{kind:`error`,title:n(`board:home.loadFailed`),description:n(`board:home.loadFailedHint`),action:(0,g.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[(0,g.jsx)(l,{variant:`secondary`,className:`pointer-coarse:min-h-11`,onClick:()=>void x.refetch(),children:n(`navigation:more.retry`)}),(0,g.jsx)(l,{variant:`ghost`,className:`pointer-coarse:min-h-11`,onClick:()=>r(i(),{state:a}),children:n(`board:home.startDraft`)})]})}):(0,g.jsx)(f,{kind:`loading`,title:n(`board:home.loading`)})})]});return(0,g.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,"data-session-shell":y?`desktop`:`phone`,"data-session-home":S.kind,children:(0,g.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:w})})}export{_ as SessionHome};