@puddle-code/cli 0.3.2 → 0.3.3

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 (212) hide show
  1. package/CHANGELOG.md +5 -4
  2. package/dist/host-control.mjs +11 -4
  3. package/dist/index.js +134 -29
  4. package/dist/public/assets/App-CkunCEjY.js +2 -0
  5. package/dist/public/assets/Dashboard-3XQN7EWB.js +1 -0
  6. package/dist/public/assets/EditorTabClose-CCYbaxcQ.js +1 -0
  7. package/dist/public/assets/FindWidget-BsFwo-Vf.js +1 -0
  8. package/dist/public/assets/LazyTerminal-CRonN-zb.js +2 -0
  9. package/dist/public/assets/{ModelRefcount-Dkp1avzM.js → ModelRefcount-BdmA-Mgb.js} +1 -1
  10. package/dist/public/assets/NewProjectDialog-Bsp8NGgY.js +1 -0
  11. package/dist/public/assets/PaneEditorBody-MSWyifa9.js +299 -0
  12. package/dist/public/assets/PdfViewer-C3kK31fw.js +2 -0
  13. package/dist/public/assets/SettingsDialog-CGT3gjKB.js +8 -0
  14. package/dist/public/assets/Terminal-_KJe85Cp.js +66 -0
  15. package/dist/public/assets/Workspace-ZdFFHXHa.js +20 -0
  16. package/dist/public/assets/abnfDiagram-VCTEODGH-CIbaiPRK.js +1 -0
  17. package/dist/public/assets/architecture-7GRP2DOG-C37y6gLW.js +1 -0
  18. package/dist/public/assets/architectureDiagram-5GKGNRK7-OE8n13hC.js +36 -0
  19. package/dist/public/assets/auth-C3Hg0pRq.js +73 -0
  20. package/dist/public/assets/{blockDiagram-I7D4REHJ-NHlOsaCN.js → blockDiagram-I7D4REHJ-TUFuv4qI.js} +1 -1
  21. package/dist/public/assets/buffer-store-De6oYRzb.js +16 -0
  22. package/dist/public/assets/button-DkCgQgIz.js +1 -0
  23. package/dist/public/assets/{c4Diagram-7LVT6UL2-ZLfrwKT4.js → c4Diagram-7LVT6UL2-Cwvhq15S.js} +1 -1
  24. package/dist/public/assets/channel-Bl1m0NKH.js +1 -0
  25. package/dist/public/assets/chunk-2E4U76K2-3abpRZU5.js +2 -0
  26. package/dist/public/assets/chunk-2ZTRR5NV-NvRGlFrK.js +2 -0
  27. package/dist/public/assets/chunk-3Z5EZCMW-DiR4QWP9.js +1 -0
  28. package/dist/public/assets/{chunk-4HAMMTFA-Brp_wxZT.js → chunk-4HAMMTFA-eolw8o4c.js} +1 -1
  29. package/dist/public/assets/chunk-5V3GS4D5-C1iY134n.js +1 -0
  30. package/dist/public/assets/chunk-6AZGARVD-_0gi5QUW.js +1 -0
  31. package/dist/public/assets/chunk-6EIED4P4-BxkNo1Kd.js +1 -0
  32. package/dist/public/assets/chunk-6K3QC6MW-3E45BuBF.js +1 -0
  33. package/dist/public/assets/chunk-6TQVIW2G-CakkaKNk.js +1 -0
  34. package/dist/public/assets/chunk-747NJXEK-pfB9pTl1.js +2 -0
  35. package/dist/public/assets/{chunk-75Z2AOVW-9vLeKuoB.js → chunk-75Z2AOVW-CYC6lmPG.js} +1 -1
  36. package/dist/public/assets/{chunk-CLGD4ZFX-B8Oa13vy.js → chunk-CLGD4ZFX-85mvsF4F.js} +1 -1
  37. package/dist/public/assets/chunk-DU6HZSFF-1ZoT19aa.js +125 -0
  38. package/dist/public/assets/{chunk-F27PBJKO-I29_mrbz.js → chunk-F27PBJKO-DM71futS.js} +1 -1
  39. package/dist/public/assets/{chunk-GMAD6QVW-ZzqGXNRY.js → chunk-GMAD6QVW-BzDEhlK8.js} +1 -1
  40. package/dist/public/assets/{chunk-GVQU2GXP-DiJctosx.js → chunk-GVQU2GXP-CZrUjjq3.js} +1 -1
  41. package/dist/public/assets/chunk-I5DQTOEV-Dcwirj_w.js +1 -0
  42. package/dist/public/assets/chunk-ICYGCRZG-BJAGKQA9.js +1 -0
  43. package/dist/public/assets/chunk-IH6LHLGP-BN2I9ljI.js +1 -0
  44. package/dist/public/assets/{chunk-IMKFNOWR-yuPnJltA.js → chunk-IMKFNOWR-CLsPi8Op.js} +1 -1
  45. package/dist/public/assets/chunk-KI3K4JFJ-v5_17D28.js +1 -0
  46. package/dist/public/assets/{chunk-L3NEJ4N5-DB3LOw2c.js → chunk-L3NEJ4N5-BW3s5_r9.js} +1 -1
  47. package/dist/public/assets/{chunk-OSK3NFVY-ygO9ccvX.js → chunk-OSK3NFVY-Cs_K17E_.js} +1 -1
  48. package/dist/public/assets/chunk-OUJLGHUK-FHDQe81Z.js +2 -0
  49. package/dist/public/assets/{chunk-P2QGCYS3-CaO30dnF.js → chunk-P2QGCYS3-C5-f0Lvg.js} +1 -1
  50. package/dist/public/assets/{chunk-POPQ4Y6H-BS_wlBQ7.js → chunk-POPQ4Y6H-gkafJx1Z.js} +1 -1
  51. package/dist/public/assets/{chunk-PWAF6VOD-BYtVJDwT.js → chunk-PWAF6VOD-CTSTb7zN.js} +1 -1
  52. package/dist/public/assets/{chunk-SHT3W25Y-DbWwFCez.js → chunk-SHT3W25Y-Cg6sVFNA.js} +1 -1
  53. package/dist/public/assets/{chunk-SVP7TREG-DLDU3lFF.js → chunk-SVP7TREG-DRUnItYx.js} +1 -1
  54. package/dist/public/assets/{chunk-TICWLB2K-Bo_jKuAY.js → chunk-TICWLB2K-HtG8ibWH.js} +1 -1
  55. package/dist/public/assets/chunk-TLUHSLCS-CcE5HWjm.js +2 -0
  56. package/dist/public/assets/chunk-UY3FDG6J-DHD-4eXF.js +1 -0
  57. package/dist/public/assets/chunk-XHIXRSVI-DRL0dwtI.js +1 -0
  58. package/dist/public/assets/classDiagram-ZZMXUADV-AgT8hWlv.js +1 -0
  59. package/dist/public/assets/classDiagram-v2-VYDZK3BY-AgT8hWlv.js +1 -0
  60. package/dist/public/assets/client-settings-CwqpIric.js +1 -0
  61. package/dist/public/assets/context-menu-0Tb8cG9E.js +1 -0
  62. package/dist/public/assets/copy-CKvSfzPk.js +1 -0
  63. package/dist/public/assets/cssMode-CSjHtANE.js +1 -0
  64. package/dist/public/assets/cynefin-OW5HDTMX-Dy2ZNO0g.js +1 -0
  65. package/dist/public/assets/cynefinDiagram-5FMLGOSQ-C2miE5p0.js +62 -0
  66. package/dist/public/assets/{dagre-GXQ25YYZ-DJ40uVpF.js → dagre-GXQ25YYZ-BjnR_o63.js} +1 -1
  67. package/dist/public/assets/{diagram-S7CK7UJ4-CakLFIEW.js → diagram-S7CK7UJ4-CBYedG6v.js} +3 -3
  68. package/dist/public/assets/diagram-UQ7AKVKN-CUL346-t.js +41 -0
  69. package/dist/public/assets/diagram-VSXAHHWV-1DKb_UJ5.js +3 -0
  70. package/dist/public/assets/{diagram-VX7I27RA-VJip2Tpi.js → diagram-VX7I27RA-DYP31PbY.js} +2 -2
  71. package/dist/public/assets/{diagram-Z3DM3KII-CPQuWy39.js → diagram-Z3DM3KII-C-mC8cmq.js} +1 -1
  72. package/dist/public/assets/dialog-UpZ_vNTE.js +41 -0
  73. package/dist/public/assets/disclosure-D7vpyXdR.js +1 -0
  74. package/dist/public/assets/dist-C2WZA469.js +1 -0
  75. package/dist/public/assets/dist-v3Pwgb3Q.js +1 -0
  76. package/dist/public/assets/ebnfDiagram-PWID7BFC-CnSa44Tb.js +1 -0
  77. package/dist/public/assets/{erDiagram-RLTQ6QDP-DqwnnH7t.js → erDiagram-RLTQ6QDP-ZmDlrO9k.js} +1 -1
  78. package/dist/public/assets/{errors-BkbAF9Bu.js → errors-BH_S68Hd.js} +1 -1
  79. package/dist/public/assets/eventmodeling-NTZA5JFV-uFnlWNGc.js +1 -0
  80. package/dist/public/assets/flowDiagram-HODETNUW-CW47qpBT.js +1 -0
  81. package/dist/public/assets/{ganttDiagram-EL5Y4UJY-BvWbPqg4.js → ganttDiagram-EL5Y4UJY-raM_gefY.js} +1 -1
  82. package/dist/public/assets/gitGraph-4MIJSDKK-1PxNX92k.js +1 -0
  83. package/dist/public/assets/gitGraphDiagram-WWUBYQGX-DnLrgk4s.js +106 -0
  84. package/dist/public/assets/htmlMode-CIHMS93l.js +1 -0
  85. package/dist/public/assets/index-xDhpMZgv.js +10 -0
  86. package/dist/public/assets/info-A6RAGUB7-BZV44TW1.js +1 -0
  87. package/dist/public/assets/infoDiagram-27XIBGKW-eCv-Vsx8.js +2 -0
  88. package/dist/public/assets/{ishikawaDiagram-5VMMS53U-Bq13tOFJ.js → ishikawaDiagram-5VMMS53U-DCFnvrdr.js} +1 -1
  89. package/dist/public/assets/{journeyDiagram-3NMN7TZE-7GJvjukT.js → journeyDiagram-3NMN7TZE-6o4KvbhJ.js} +1 -1
  90. package/dist/public/assets/{jsonMode-C6jAdn8r.js → jsonMode-BijgXT6I.js} +1 -1
  91. package/dist/public/assets/jsx-runtime-ffCh33zF.js +1 -0
  92. package/dist/public/assets/{kanban-definition-UXKFOSKX-BIFvSwV9.js → kanban-definition-UXKFOSKX-CQKuhkFV.js} +1 -1
  93. package/dist/public/assets/{line-BjlS8UJs.js → line-D4r_bmlv.js} +1 -1
  94. package/dist/public/assets/markdown-mermaid-D0nzztEz.js +2 -0
  95. package/dist/public/assets/{math-BNNuKpUP.js → math-CSw6sgCC.js} +2 -2
  96. package/dist/public/assets/math-delimiters-BCnTi7Ii.js +1 -0
  97. package/dist/public/assets/media-refresh-store-Ddvr6wz1.js +1 -0
  98. package/dist/public/assets/mermaid-parser.core-CICMKhjq.js +4 -0
  99. package/dist/public/assets/mermaid.core-D2QzpYEE.js +11 -0
  100. package/dist/public/assets/{mindmap-definition-YA3MSWOX-Cy4SIHHe.js → mindmap-definition-YA3MSWOX-DAB8mHOv.js} +1 -1
  101. package/dist/public/assets/monaco.contribution-C0TYpF88.js +2 -0
  102. package/dist/public/assets/notification-delivery-CDu_5PS7.js +1 -0
  103. package/dist/public/assets/packet-AYTQ26CC-Cw5JteoC.js +1 -0
  104. package/dist/public/assets/{pdf-Cnp8bCq1.js → pdf-EQHMWEbX.js} +1 -1
  105. package/dist/public/assets/pegDiagram-XKGWAZYB-BE_LYTdh.js +1 -0
  106. package/dist/public/assets/pie-WAS4IAKB-CnPKaBaN.js +1 -0
  107. package/dist/public/assets/pieDiagram-E7YTZNPT-BRffiJ1a.js +39 -0
  108. package/dist/public/assets/preload-helper-Czpn1I53.js +1 -0
  109. package/dist/public/assets/project-abbrev-Br6sQqPh.js +1 -0
  110. package/dist/public/assets/protocol-support-CLMCHX8i.js +1 -0
  111. package/dist/public/assets/{quadrantDiagram-AXDQQJYC-2BigfRRK.js → quadrantDiagram-AXDQQJYC-DYWp1Jjq.js} +1 -1
  112. package/dist/public/assets/radar-RG4KPBEZ-Dqx79rlE.js +1 -0
  113. package/dist/public/assets/railroad-74A4TZTK-BkDQqaz7.js +1 -0
  114. package/dist/public/assets/railroad-abnf-HS5TGJTU-kgqWL-Ba.js +1 -0
  115. package/dist/public/assets/railroad-ebnf-LZEXJU2U-GspfOzjs.js +1 -0
  116. package/dist/public/assets/railroad-peg-WCYAUIDC-qO23KZap.js +1 -0
  117. package/dist/public/assets/railroadDiagram-O6MQD6OU-wuPYUWJ2.js +1 -0
  118. package/dist/public/assets/{requirementDiagram-BXWQKSXE-BfBBVeo_.js → requirementDiagram-BXWQKSXE-BtGNZ92J.js} +1 -1
  119. package/dist/public/assets/{sankeyDiagram-P5KCCOFB-BHy22mhl.js → sankeyDiagram-P5KCCOFB-XgIIrsbe.js} +1 -1
  120. package/dist/public/assets/{scroll-restoration-rhyw8Ck0.js → scroll-restoration-hNqYmCAE.js} +1 -1
  121. package/dist/public/assets/selection-actions-Bh9Fkkqv.js +1 -0
  122. package/dist/public/assets/{sequenceDiagram-WJ2MYXX4-Dhgnxvrt.js → sequenceDiagram-WJ2MYXX4-CVIIE7ze.js} +1 -1
  123. package/dist/public/assets/{stateDiagram-D77RDMKH-CPWwa5Aj.js → stateDiagram-D77RDMKH-0kIDexDQ.js} +1 -1
  124. package/dist/public/assets/stateDiagram-v2-MP3YSRHH-DdU6a-zG.js +1 -0
  125. package/dist/public/assets/{swimlanes-42K2YHIH-DsqTASlp.js → swimlanes-42K2YHIH-BY2JV_Jb.js} +1 -1
  126. package/dist/public/assets/swimlanesDiagram-VR7AAH4N-BCiIa4tX.js +8 -0
  127. package/dist/public/assets/switch-SW6BMps1.js +1 -0
  128. package/dist/public/assets/{timeline-definition-24CTP7MA-B7hjD0KJ.js → timeline-definition-24CTP7MA-CPRUSXUS.js} +1 -1
  129. package/dist/public/assets/treeView-Q6P3EWNA-CiZNqz_z.js +1 -0
  130. package/dist/public/assets/treemap-WGGIJYW6-5hDYDC6e.js +1 -0
  131. package/dist/public/assets/{tsMode-CillYPbz.js → tsMode-B7q3gz7a.js} +1 -1
  132. package/dist/public/assets/use-ui-state-BiAROr3D.js +1 -0
  133. package/dist/public/assets/{vennDiagram-4TSXK5OY-BvS0i65j.js → vennDiagram-4TSXK5OY-CU1Q7iGV.js} +1 -1
  134. package/dist/public/assets/view-state-store-C6OmciCC.js +1 -0
  135. package/dist/public/assets/wardley-WFR3VGLG-CWb_ROLo.js +1 -0
  136. package/dist/public/assets/{wardleyDiagram-VM6X3IG4-CxconmGB.js → wardleyDiagram-VM6X3IG4-B2Pn7CDF.js} +3 -3
  137. package/dist/public/assets/whole-word-2m2pmAFT.js +1 -0
  138. package/dist/public/assets/workers-Ck67TJT4.js +1 -0
  139. package/dist/public/assets/ws-DNNH0sEH.js +1 -0
  140. package/dist/public/assets/{xychartDiagram-S5SC5T6Z-DSJMW0r7.js → xychartDiagram-S5SC5T6Z-xhQ4tT_S.js} +1 -1
  141. package/dist/public/index.html +5 -1
  142. package/dist/pudl.js +12 -5
  143. package/package.json +1 -1
  144. package/dist/public/assets/App-D_YTB3jH.js +0 -2
  145. package/dist/public/assets/Dashboard-Djw9nPV_.js +0 -1
  146. package/dist/public/assets/EditorTabClose-BCunnuEj.js +0 -1
  147. package/dist/public/assets/FindWidget-Ch-y_4eH.js +0 -1
  148. package/dist/public/assets/LazyTerminal-BN3rEDcD.js +0 -2
  149. package/dist/public/assets/NewProjectDialog-BK_gfWmL.js +0 -1
  150. package/dist/public/assets/PaneEditorBody-ClWRSuGV.js +0 -299
  151. package/dist/public/assets/PdfViewer-CbC1KAkq.js +0 -2
  152. package/dist/public/assets/SettingsDialog-DsmyHhQB.js +0 -8
  153. package/dist/public/assets/Terminal-CDnGRsgd.js +0 -66
  154. package/dist/public/assets/Workspace-CmclLFK3.js +0 -20
  155. package/dist/public/assets/abnfDiagram-VCTEODGH-Aa5uAdnV.js +0 -1
  156. package/dist/public/assets/architecture-7GRP2DOG-D3814jvH.js +0 -1
  157. package/dist/public/assets/architectureDiagram-5GKGNRK7-B0d475xG.js +0 -36
  158. package/dist/public/assets/buffer-store-BtRP7zZm.js +0 -16
  159. package/dist/public/assets/button-D3DTuFk3.js +0 -1
  160. package/dist/public/assets/channel-C6g1aWXR.js +0 -1
  161. package/dist/public/assets/chunk-2E4U76K2-DyVxGuz5.js +0 -2
  162. package/dist/public/assets/chunk-DU6HZSFF-ziCxw8j9.js +0 -125
  163. package/dist/public/assets/chunk-TLUHSLCS-BGFLoTUj.js +0 -2
  164. package/dist/public/assets/classDiagram-ZZMXUADV-BiQrxRCS.js +0 -1
  165. package/dist/public/assets/classDiagram-v2-VYDZK3BY-BiQrxRCS.js +0 -1
  166. package/dist/public/assets/context-menu-CwR-PGrS.js +0 -1
  167. package/dist/public/assets/copy-ZzKoF5dj.js +0 -1
  168. package/dist/public/assets/cssMode-DBrJeag9.js +0 -1
  169. package/dist/public/assets/cynefin-OW5HDTMX-DsXo9hDP.js +0 -1
  170. package/dist/public/assets/cynefinDiagram-5FMLGOSQ-CNr5UISm.js +0 -62
  171. package/dist/public/assets/diagram-UQ7AKVKN-Blm9jWHJ.js +0 -41
  172. package/dist/public/assets/diagram-VSXAHHWV-BzXCydDQ.js +0 -3
  173. package/dist/public/assets/dialog-BoaHxScl.js +0 -41
  174. package/dist/public/assets/disclosure-DNbP2Rp4.js +0 -1
  175. package/dist/public/assets/dist-CQZ_zg-s.js +0 -1
  176. package/dist/public/assets/dist-DUfD4S2p.js +0 -1
  177. package/dist/public/assets/ebnfDiagram-PWID7BFC-x8Hm-8FP.js +0 -1
  178. package/dist/public/assets/eventmodeling-NTZA5JFV-DE-zSV6F.js +0 -1
  179. package/dist/public/assets/flowDiagram-HODETNUW-Cn9XuALP.js +0 -1
  180. package/dist/public/assets/gitGraph-4MIJSDKK-DKeR8Wjx.js +0 -1
  181. package/dist/public/assets/gitGraphDiagram-WWUBYQGX-CPJ482wi.js +0 -106
  182. package/dist/public/assets/htmlMode-CKCaIwmL.js +0 -1
  183. package/dist/public/assets/index-CPKHBs7z.js +0 -82
  184. package/dist/public/assets/info-A6RAGUB7-CYKUxPau.js +0 -1
  185. package/dist/public/assets/infoDiagram-27XIBGKW-5qHuu76B.js +0 -2
  186. package/dist/public/assets/markdown-mermaid-B_y_6yBe.js +0 -2
  187. package/dist/public/assets/media-refresh-store-BnZNW8xS.js +0 -1
  188. package/dist/public/assets/mermaid-parser.core-BwJKOdFv.js +0 -7
  189. package/dist/public/assets/mermaid.core-Cii531li.js +0 -11
  190. package/dist/public/assets/notification-delivery-Cn-YcMec.js +0 -1
  191. package/dist/public/assets/packet-AYTQ26CC-y8aHtpCT.js +0 -1
  192. package/dist/public/assets/pegDiagram-XKGWAZYB-yIL7Oty_.js +0 -1
  193. package/dist/public/assets/pie-WAS4IAKB-DNZ4gYKN.js +0 -1
  194. package/dist/public/assets/pieDiagram-E7YTZNPT-CUwYqrWF.js +0 -39
  195. package/dist/public/assets/project-abbrev-B5CMO00I.js +0 -1
  196. package/dist/public/assets/protocol-support-hVrRUHAd.js +0 -1
  197. package/dist/public/assets/radar-RG4KPBEZ-DCE8-Z-G.js +0 -1
  198. package/dist/public/assets/railroad-74A4TZTK-BfnC2It7.js +0 -1
  199. package/dist/public/assets/railroad-abnf-HS5TGJTU-C8QChwRk.js +0 -1
  200. package/dist/public/assets/railroad-ebnf-LZEXJU2U-DN6nLE-f.js +0 -1
  201. package/dist/public/assets/railroad-peg-WCYAUIDC-emPIg_g-.js +0 -1
  202. package/dist/public/assets/railroadDiagram-O6MQD6OU-DpX2WbJ5.js +0 -1
  203. package/dist/public/assets/selection-actions-BDJnKwuj.js +0 -1
  204. package/dist/public/assets/stateDiagram-v2-MP3YSRHH-CmGYleZg.js +0 -1
  205. package/dist/public/assets/swimlanesDiagram-VR7AAH4N-CUahIPDv.js +0 -8
  206. package/dist/public/assets/switch-DGZtVofo.js +0 -1
  207. package/dist/public/assets/treeView-Q6P3EWNA-WU6eWUi6.js +0 -1
  208. package/dist/public/assets/treemap-WGGIJYW6-BNZcLwqI.js +0 -1
  209. package/dist/public/assets/use-ui-state-BZeOd2de.js +0 -1
  210. package/dist/public/assets/view-state-store-BEl9Q1Jm.js +0 -1
  211. package/dist/public/assets/wardley-WFR3VGLG-ChvHhLGz.js +0 -1
  212. package/dist/public/assets/ws-B6RLTvWI.js +0 -1
package/CHANGELOG.md CHANGED
@@ -4,16 +4,17 @@ Archived release changelog. Governance lives in CLAUDE.md §"Changelog disciplin
4
4
 
5
5
  # Changelog
6
6
 
7
- ## [0.3.2] — 2026-10-14
7
+ ## [0.3.3] — 2026-10-15
8
8
 
9
9
  ### Added
10
10
 
11
- - Support Claude Code, Codex, OpenCode and Gemini CLI in Puddlang with per-agent interactive or headless execution, persisted mode selection, exact reply correlation and account-preserving native conversation resume (daemon protocol 24.0).
11
+ - Reveal local files and folders in Finder, File Explorer or the system file manager from file-tree and editor-tab menus, including locally served browser cockpits; SSH and remote hosts omit the action (protocol 24.2).
12
12
 
13
13
  ### Changed
14
14
 
15
- - Rename Puddlang's `scripted` execution mode to `headless` across spawn options, session state, agent modules, examples and documentation; migrate existing placements and advance daemon protocol to 24.0 and remote protocol to 4.
15
+ - Show desktop notifications with host/project, session title and message preview in that order: native text fields on macOS and Windows, and a separate session line above the preview on Linux (protocol 24.1).
16
+ - Prefix web/mobile notification titles with the project abbreviation (`[ABBRV] Session title`) for both live alerts and encrypted background push.
16
17
 
17
18
  ### Fixed
18
19
 
19
- - Include the Puddlang runner and its imports in standalone daemon archives, with a release smoke test that executes a TypeScript programme using both `puddlang` and `zod`.
20
+ - Attach desktop SSH authentication prompts to their host's window, display the target explicitly, and discard pending and late requests when that host closes while retaining at most one request per host.
@@ -14557,6 +14557,7 @@ var notificationContentSchema = external_exports.object({
14557
14557
  var desktopNotificationRequestSchema = external_exports.object({
14558
14558
  id: external_exports.string().min(1).max(128),
14559
14559
  title: external_exports.string().min(1).max(160),
14560
+ subtitle: external_exports.string().min(1).max(160).optional(),
14560
14561
  body: external_exports.string().min(1).max(256),
14561
14562
  target: notificationTargetSchema.optional()
14562
14563
  }).strict();
@@ -15110,13 +15111,13 @@ var archiveRequestSchema = external_exports.object({
15110
15111
  });
15111
15112
 
15112
15113
  // ../shared/src/api/projects.ts
15113
- var projectAbbrev = external_exports.string().min(1).max(5);
15114
+ var projectAbbrev2 = external_exports.string().min(1).max(5);
15114
15115
  var projectSchema = external_exports.object({
15115
15116
  id: projectId,
15116
15117
  profile_id: profileId,
15117
15118
  repo_id: rowId,
15118
15119
  name: external_exports.string(),
15119
- abbrev: projectAbbrev.nullable().default(null),
15120
+ abbrev: projectAbbrev2.nullable().default(null),
15120
15121
  /**
15121
15122
  * Hidden from the homescreen but never deleted — every session, worktree, and
15122
15123
  * bit of data is retained, and un-archiving restores it all (SPEC §11).
@@ -15130,11 +15131,11 @@ var createProjectRequestSchema = external_exports.object({
15130
15131
  profile_id: profileId,
15131
15132
  repo_id: rowId,
15132
15133
  name: external_exports.string().min(1).max(100),
15133
- abbrev: projectAbbrev.optional()
15134
+ abbrev: projectAbbrev2.optional()
15134
15135
  });
15135
15136
  var patchProjectRequestSchema = external_exports.object({
15136
15137
  name: external_exports.string().min(1).max(100).optional(),
15137
- abbrev: projectAbbrev.optional(),
15138
+ abbrev: projectAbbrev2.optional(),
15138
15139
  archived: external_exports.boolean().optional()
15139
15140
  });
15140
15141
  var projectDetailSchema = external_exports.object({
@@ -15749,6 +15750,12 @@ var cockpitRefreshResponseSchema = external_exports.object({
15749
15750
  refreshId: external_exports.string().uuid(),
15750
15751
  instance: external_exports.string().uuid()
15751
15752
  });
15753
+ var cockpitFileManagerSchema = external_exports.object({
15754
+ name: external_exports.enum(["Finder", "File Explorer", "File Manager"]).nullable()
15755
+ });
15756
+ var cockpitRevealRequestSchema = external_exports.object({
15757
+ path: external_exports.string().min(1).max(4096).refine((path) => !path.includes("\0"))
15758
+ }).strict();
15752
15759
 
15753
15760
  // ../shared/src/ws/messages.ts
15754
15761
  var termId = external_exports.string().regex(/^(agent|shell-[0-9]+)$/);
package/dist/index.js CHANGED
@@ -3925,7 +3925,7 @@ import { createInterface } from "node:readline";
3925
3925
  import { Writable } from "node:stream";
3926
3926
 
3927
3927
  // ../shared/src/protocol.ts
3928
- var PROTOCOL_VERSION = { major: 24, minor: 0 };
3928
+ var PROTOCOL_VERSION = { major: 24, minor: 2 };
3929
3929
 
3930
3930
  // ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
3931
3931
  var external_exports = {};
@@ -18477,6 +18477,7 @@ var notificationContentSchema = external_exports.object({
18477
18477
  var desktopNotificationRequestSchema = external_exports.object({
18478
18478
  id: external_exports.string().min(1).max(128),
18479
18479
  title: external_exports.string().min(1).max(160),
18480
+ subtitle: external_exports.string().min(1).max(160).optional(),
18480
18481
  body: external_exports.string().min(1).max(256),
18481
18482
  target: notificationTargetSchema.optional()
18482
18483
  }).strict();
@@ -19030,13 +19031,13 @@ var archiveRequestSchema = external_exports.object({
19030
19031
  });
19031
19032
 
19032
19033
  // ../shared/src/api/projects.ts
19033
- var projectAbbrev = external_exports.string().min(1).max(5);
19034
+ var projectAbbrev2 = external_exports.string().min(1).max(5);
19034
19035
  var projectSchema = external_exports.object({
19035
19036
  id: projectId,
19036
19037
  profile_id: profileId,
19037
19038
  repo_id: rowId,
19038
19039
  name: external_exports.string(),
19039
- abbrev: projectAbbrev.nullable().default(null),
19040
+ abbrev: projectAbbrev2.nullable().default(null),
19040
19041
  /**
19041
19042
  * Hidden from the homescreen but never deleted — every session, worktree, and
19042
19043
  * bit of data is retained, and un-archiving restores it all (SPEC §11).
@@ -19050,11 +19051,11 @@ var createProjectRequestSchema = external_exports.object({
19050
19051
  profile_id: profileId,
19051
19052
  repo_id: rowId,
19052
19053
  name: external_exports.string().min(1).max(100),
19053
- abbrev: projectAbbrev.optional()
19054
+ abbrev: projectAbbrev2.optional()
19054
19055
  });
19055
19056
  var patchProjectRequestSchema = external_exports.object({
19056
19057
  name: external_exports.string().min(1).max(100).optional(),
19057
- abbrev: projectAbbrev.optional(),
19058
+ abbrev: projectAbbrev2.optional(),
19058
19059
  archived: external_exports.boolean().optional()
19059
19060
  });
19060
19061
  var projectDetailSchema = external_exports.object({
@@ -19669,6 +19670,12 @@ var cockpitRefreshResponseSchema = external_exports.object({
19669
19670
  refreshId: external_exports.string().uuid(),
19670
19671
  instance: external_exports.string().uuid()
19671
19672
  });
19673
+ var cockpitFileManagerSchema = external_exports.object({
19674
+ name: external_exports.enum(["Finder", "File Explorer", "File Manager"]).nullable()
19675
+ });
19676
+ var cockpitRevealRequestSchema = external_exports.object({
19677
+ path: external_exports.string().min(1).max(4096).refine((path) => !path.includes("\0"))
19678
+ }).strict();
19672
19679
 
19673
19680
  // ../shared/src/ws/messages.ts
19674
19681
  var termId = external_exports.string().regex(/^(agent|shell-[0-9]+)$/);
@@ -21773,7 +21780,7 @@ async function acquireAuthority(transport) {
21773
21780
  // src/cli/run.ts
21774
21781
  init_attach();
21775
21782
  import { existsSync as existsSync7 } from "node:fs";
21776
- import { dirname as dirname12, join as join17 } from "node:path";
21783
+ import { dirname as dirname13, join as join17 } from "node:path";
21777
21784
  import { fileURLToPath as fileURLToPath5 } from "node:url";
21778
21785
 
21779
21786
  // src/lib/browser.ts
@@ -21817,7 +21824,7 @@ import { readFileSync as readFileSync4 } from "node:fs";
21817
21824
  import { dirname as dirname4, join as join5 } from "node:path";
21818
21825
  import { fileURLToPath as fileURLToPath2 } from "node:url";
21819
21826
  function cliVersion() {
21820
- if (true) return "0.3.2";
21827
+ if (true) return "0.3.3";
21821
21828
  const here = dirname4(fileURLToPath2(import.meta.url));
21822
21829
  for (const candidate of [
21823
21830
  join5(here, "..", "..", "package.json"),
@@ -22217,7 +22224,8 @@ var RELEASE_PROTOCOLS = {
22217
22224
  "0.2.24": { major: 22, minor: 5 },
22218
22225
  "0.3.0": { major: 23, minor: 0 },
22219
22226
  "0.3.1": { major: 23, minor: 0 },
22220
- "0.3.2": { major: 24, minor: 0 }
22227
+ "0.3.2": { major: 24, minor: 0 },
22228
+ "0.3.3": { major: 24, minor: 2 }
22221
22229
  };
22222
22230
  function validProtocol(value) {
22223
22231
  if (typeof value !== "object" || value === null) return false;
@@ -23663,6 +23671,34 @@ async function checkRemoteRegistration(req, res, authorised) {
23663
23671
  }
23664
23672
  }
23665
23673
 
23674
+ // src/lib/serve/file-manager.ts
23675
+ function fileManagerHandler(manager) {
23676
+ let busy = false;
23677
+ return async (req, res, authorised) => {
23678
+ if (req.method === "GET") return json2(res, 200, { name: manager?.name ?? null });
23679
+ if (req.method !== "POST") return fail(res, 405, "method_not_allowed");
23680
+ if (!manager) return fail(res, 404, "file_manager_unavailable");
23681
+ const request = cockpitRevealRequestSchema.parse(await readJson(req));
23682
+ if (!authorised()) return fail(res, 401, "browser_rejected");
23683
+ if (busy) return fail(res, 409, "file_manager_busy", "A folder is already being revealed.");
23684
+ busy = true;
23685
+ try {
23686
+ await manager.reveal(request.path, authorised);
23687
+ res.writeHead(204);
23688
+ res.end();
23689
+ } catch (error51) {
23690
+ fail(
23691
+ res,
23692
+ 400,
23693
+ "reveal_failed",
23694
+ error51 instanceof Error ? error51.message : "Could not reveal this path."
23695
+ );
23696
+ } finally {
23697
+ busy = false;
23698
+ }
23699
+ };
23700
+ }
23701
+
23666
23702
  // src/lib/serve/ui-server.ts
23667
23703
  var DEFAULT_UI_PORT = 7433;
23668
23704
  var MAX_PORT_PROBES = 50;
@@ -23672,6 +23708,9 @@ async function startUiServer(opts) {
23672
23708
  const tracker = new ProxySocketTracker();
23673
23709
  const serveStatic = createStaticHandler(opts.assetsDir);
23674
23710
  const handleRemoteAccess = remoteAccessHandler(opts.remoteAccess);
23711
+ const handleFileManager = fileManagerHandler(
23712
+ opts.identity === "local" ? opts.fileManager : void 0
23713
+ );
23675
23714
  const nonce = randomUUID3();
23676
23715
  let origin = "";
23677
23716
  let proxyOrigin = "";
@@ -23720,6 +23759,8 @@ async function startUiServer(opts) {
23720
23759
  }
23721
23760
  if (url2.pathname === "/cockpit/local-sync")
23722
23761
  return handleLocalSync(req, res, opts.localSync, () => browsers.valid(browser));
23762
+ if (url2.pathname === "/cockpit/file-manager")
23763
+ return handleFileManager(req, res, () => browsers.valid(browser));
23723
23764
  if (url2.pathname === "/cockpit/remote")
23724
23765
  return handleRemoteAccess(req, res, () => browsers.valid(browser));
23725
23766
  if (url2.pathname === "/cockpit/remote/registration") {
@@ -24383,6 +24424,69 @@ function sanitise(record2) {
24383
24424
  // src/lib/start.ts
24384
24425
  import { join as join14 } from "node:path";
24385
24426
  init_types();
24427
+
24428
+ // src/lib/file-manager.ts
24429
+ import { execFile, spawn as spawn6 } from "node:child_process";
24430
+ import { lstat, stat } from "node:fs/promises";
24431
+ import { dirname as dirname9, isAbsolute, win32 } from "node:path";
24432
+ import { pathToFileURL } from "node:url";
24433
+ import { promisify } from "node:util";
24434
+ var execute = promisify(execFile);
24435
+ function localFileManager(platform = process.platform) {
24436
+ const name = platform === "darwin" ? "Finder" : platform === "win32" ? "File Explorer" : platform === "linux" ? "File Manager" : null;
24437
+ if (!name) return;
24438
+ return {
24439
+ name,
24440
+ async reveal(path, authorised) {
24441
+ if (!(platform === "win32" ? win32.isAbsolute(path) : isAbsolute(path)) || path.includes("\0"))
24442
+ throw new Error("Expected an absolute local path.");
24443
+ const entry = await lstat(path);
24444
+ const directory = entry.isDirectory() || entry.isSymbolicLink() && await stat(path).then(
24445
+ (target) => target.isDirectory(),
24446
+ () => false
24447
+ );
24448
+ const run3 = async (command, args, detached = false) => {
24449
+ if (!authorised()) throw new Error("Browser authorisation expired.");
24450
+ if (detached) {
24451
+ await new Promise((resolve6, reject) => {
24452
+ const child = spawn6(command, args, { stdio: "ignore", detached: true });
24453
+ child.once("error", reject);
24454
+ child.once("spawn", () => {
24455
+ child.unref();
24456
+ resolve6();
24457
+ });
24458
+ });
24459
+ return;
24460
+ }
24461
+ await execute(command, args, { timeout: 1e4, maxBuffer: 16384, windowsHide: true });
24462
+ };
24463
+ if (platform === "darwin") {
24464
+ await run3("/usr/bin/open", directory ? ["-a", "Finder", "--", path] : ["-R", "--", path]);
24465
+ } else if (platform === "win32") {
24466
+ await run3("explorer.exe", directory ? [path] : ["/select,", path], true);
24467
+ } else {
24468
+ try {
24469
+ await run3("gdbus", [
24470
+ "call",
24471
+ "--session",
24472
+ "--dest",
24473
+ "org.freedesktop.FileManager1",
24474
+ "--object-path",
24475
+ "/org/freedesktop/FileManager1",
24476
+ "--method",
24477
+ `org.freedesktop.FileManager1.${directory ? "ShowFolders" : "ShowItems"}`,
24478
+ JSON.stringify([pathToFileURL(path).href]),
24479
+ ""
24480
+ ]);
24481
+ } catch {
24482
+ await run3("xdg-open", [directory ? path : dirname9(path)], true);
24483
+ }
24484
+ }
24485
+ }
24486
+ };
24487
+ }
24488
+
24489
+ // src/lib/start.ts
24386
24490
  async function startLocal(opts) {
24387
24491
  const logger = opts.logger ?? silentLogger;
24388
24492
  const transport = new LocalTransport();
@@ -24417,6 +24521,7 @@ async function startLocal(opts) {
24417
24521
  target: { host: "127.0.0.1", port: endpoint.port },
24418
24522
  ...opts.onRefreshRequest !== void 0 ? { control: { onRefresh: opts.onRefreshRequest } } : {},
24419
24523
  localSync: { file: join14(clientHome(), "local-sync.json") },
24524
+ fileManager: localFileManager(),
24420
24525
  remoteAccess: new RemoteAccessControl(transport)
24421
24526
  });
24422
24527
  currentUi = ui;
@@ -24471,23 +24576,23 @@ init_types();
24471
24576
 
24472
24577
  // src/cli/manage-cli.ts
24473
24578
  init_types();
24474
- import { spawn as spawn7 } from "node:child_process";
24475
- import { dirname as dirname10 } from "node:path";
24579
+ import { spawn as spawn8 } from "node:child_process";
24580
+ import { dirname as dirname11 } from "node:path";
24476
24581
 
24477
24582
  // src/lib/standalone-cli.ts
24478
24583
  init_types();
24479
- import { spawn as spawn6 } from "node:child_process";
24584
+ import { spawn as spawn7 } from "node:child_process";
24480
24585
  import { existsSync as existsSync5, lstatSync as lstatSync2, readFileSync as readFileSync9, realpathSync as realpathSync2 } from "node:fs";
24481
24586
  import { mkdir as mkdir2, readFile as readFile2, rm as rm2, unlink } from "node:fs/promises";
24482
- import { basename, dirname as dirname9, isAbsolute, join as join15, resolve as resolve5 } from "node:path";
24587
+ import { basename, dirname as dirname10, isAbsolute as isAbsolute2, join as join15, resolve as resolve5 } from "node:path";
24483
24588
  import { fileURLToPath as fileURLToPath4 } from "node:url";
24484
24589
  function standaloneInstallation(entryFile = fileURLToPath4(import.meta.url), execPath = process.execPath) {
24485
- const release = resolve5(dirname9(entryFile), "..");
24590
+ const release = resolve5(dirname10(entryFile), "..");
24486
24591
  if (!existsSync5(join15(release, "STANDALONE"))) return null;
24487
24592
  try {
24488
24593
  const root = resolve5(release, "..", "..");
24489
24594
  const record2 = JSON.parse(readFileSync9(join15(root, "installation.json"), "utf8"));
24490
- if (readFileSync9(join15(release, "STANDALONE"), "utf8").trim() !== "puddle-cli" || readFileSync9(join15(root, "INSTALLATION"), "utf8").trim() !== "puddle-cli" || dirname9(release) !== join15(root, "versions") || realpathSync2(release) !== release || realpathSync2(execPath) !== join15(release, "bin/node") || record2.kind !== "puddle-cli" || typeof record2.launcher !== "string" || !isAbsolute(record2.launcher) || record2.scriptLauncher !== void 0 && record2.scriptLauncher !== join15(dirname9(record2.launcher), "pudl") && record2.scriptLauncher !== join15(dirname9(record2.launcher), "puddlang"))
24595
+ if (readFileSync9(join15(release, "STANDALONE"), "utf8").trim() !== "puddle-cli" || readFileSync9(join15(root, "INSTALLATION"), "utf8").trim() !== "puddle-cli" || dirname10(release) !== join15(root, "versions") || realpathSync2(release) !== release || realpathSync2(execPath) !== join15(release, "bin/node") || record2.kind !== "puddle-cli" || typeof record2.launcher !== "string" || !isAbsolute2(record2.launcher) || record2.scriptLauncher !== void 0 && record2.scriptLauncher !== join15(dirname10(record2.launcher), "pudl") && record2.scriptLauncher !== join15(dirname10(record2.launcher), "puddlang"))
24491
24596
  throw new Error("Installation metadata does not match this CLI");
24492
24597
  return {
24493
24598
  root,
@@ -24511,12 +24616,12 @@ function upgradeStandaloneCli(installation, version2, repo) {
24511
24616
  "--prefix",
24512
24617
  installation.root,
24513
24618
  "--bin-dir",
24514
- dirname9(installation.launcher)
24619
+ dirname10(installation.launcher)
24515
24620
  ];
24516
24621
  if (version2 !== void 0) args.push("--version", version2);
24517
24622
  if (repo !== void 0) args.push("--repo", repo);
24518
24623
  return new Promise((resolve6, reject) => {
24519
- const child = spawn6("sh", args, { stdio: ["pipe", "inherit", "inherit"] });
24624
+ const child = spawn7("sh", args, { stdio: ["pipe", "inherit", "inherit"] });
24520
24625
  child.on("error", reject);
24521
24626
  child.stdin.on("error", (error51) => {
24522
24627
  if (error51.code !== "EPIPE") reject(error51);
@@ -24571,7 +24676,7 @@ function upgradeCli(version2, logger) {
24571
24676
  const spec = `@puddle-code/cli@${version2 ?? "latest"}`;
24572
24677
  logger.info(`puddle CLI ${cliVersion()} \u2014 asking npm for ${version2 ?? "the latest release"}`);
24573
24678
  return new Promise((resolve6, reject) => {
24574
- const child = spawn7("npm", ["install", "-g", spec], { stdio: "inherit" });
24679
+ const child = spawn8("npm", ["install", "-g", spec], { stdio: "inherit" });
24575
24680
  child.on(
24576
24681
  "error",
24577
24682
  () => reject(
@@ -24596,7 +24701,7 @@ async function removeCli(yes, logger) {
24596
24701
  const standalone = standaloneInstallation();
24597
24702
  if (standalone) {
24598
24703
  const proceed2 = await confirm(
24599
- `Remove the standalone CLI at ${standalone.root} and its launcher in ${dirname10(standalone.launcher)}? Close its cockpits first; daemons and their sessions are untouched.`,
24704
+ `Remove the standalone CLI at ${standalone.root} and its launcher in ${dirname11(standalone.launcher)}? Close its cockpits first; daemons and their sessions are untouched.`,
24600
24705
  { skip: yes }
24601
24706
  );
24602
24707
  if (!proceed2) {
@@ -24608,7 +24713,7 @@ async function removeCli(yes, logger) {
24608
24713
  return 0;
24609
24714
  }
24610
24715
  const managed = await new Promise((resolve6) => {
24611
- const child = spawn7("npm", ["ls", "-g", "@puddle-code/cli", "--depth=0"], { stdio: "ignore" });
24716
+ const child = spawn8("npm", ["ls", "-g", "@puddle-code/cli", "--depth=0"], { stdio: "ignore" });
24612
24717
  child.on("error", () => resolve6(false));
24613
24718
  child.on("exit", (code) => resolve6(code === 0));
24614
24719
  });
@@ -24628,7 +24733,7 @@ async function removeCli(yes, logger) {
24628
24733
  return 0;
24629
24734
  }
24630
24735
  return new Promise((resolve6, reject) => {
24631
- const child = spawn7("npm", ["uninstall", "-g", "@puddle-code/cli"], { stdio: "inherit" });
24736
+ const child = spawn8("npm", ["uninstall", "-g", "@puddle-code/cli"], { stdio: "inherit" });
24632
24737
  child.on("error", () => reject(new CliError("not_installed", "npm is not on PATH")));
24633
24738
  child.on("exit", (code) => {
24634
24739
  if (code === 0) {
@@ -24642,7 +24747,7 @@ async function removeCli(yes, logger) {
24642
24747
  }
24643
24748
 
24644
24749
  // src/cli/manage.ts
24645
- import { spawn as spawn9 } from "node:child_process";
24750
+ import { spawn as spawn10 } from "node:child_process";
24646
24751
  import { existsSync as existsSync6 } from "node:fs";
24647
24752
  import { chmod as chmod2, copyFile, mkdir as mkdir3, rename, rm as rm3 } from "node:fs/promises";
24648
24753
  import { homedir as homedir2 } from "node:os";
@@ -24783,9 +24888,9 @@ async function upgradeDaemon(transport, opts = {}) {
24783
24888
  }
24784
24889
 
24785
24890
  // src/cli/detach.ts
24786
- import { spawn as spawn8 } from "node:child_process";
24891
+ import { spawn as spawn9 } from "node:child_process";
24787
24892
  import { closeSync as closeSync2, mkdirSync as mkdirSync6, openSync as openSync2, readFileSync as readFileSync10 } from "node:fs";
24788
- import { dirname as dirname11 } from "node:path";
24893
+ import { dirname as dirname12 } from "node:path";
24789
24894
  init_types();
24790
24895
  var COCKPIT_CHILD_ENV = "PUDDLE_COCKPIT_CHILD";
24791
24896
  var READY_TIMEOUT_MS = 3e5;
@@ -24824,10 +24929,10 @@ async function launchDetached(opts) {
24824
24929
  }
24825
24930
  if (target !== "local") await new SshTransport(target).open();
24826
24931
  const logFile = cockpitLogPath(target);
24827
- mkdirSync6(dirname11(logFile), { recursive: true });
24932
+ mkdirSync6(dirname12(logFile), { recursive: true });
24828
24933
  const fd = openSync2(logFile, "w");
24829
24934
  const argv = opts.argv ?? process.argv.slice(2);
24830
- const child = spawn8(process.execPath, [process.argv[1] ?? "", ...argv], {
24935
+ const child = spawn9(process.execPath, [process.argv[1] ?? "", ...argv], {
24831
24936
  detached: true,
24832
24937
  stdio: ["ignore", fd, fd, "ipc"],
24833
24938
  env: { ...process.env, [COCKPIT_CHILD_ENV]: "1" }
@@ -24892,7 +24997,7 @@ async function followStartup(target, childPid, logFile) {
24892
24997
  }
24893
24998
  function spawnDetachedRefresh(target, argv, refreshId) {
24894
24999
  const logFile = cockpitLogPath(target);
24895
- mkdirSync6(dirname11(logFile), { recursive: true });
25000
+ mkdirSync6(dirname12(logFile), { recursive: true });
24896
25001
  const fd = openSync2(logFile, "a");
24897
25002
  const env = {
24898
25003
  ...process.env,
@@ -24900,7 +25005,7 @@ function spawnDetachedRefresh(target, argv, refreshId) {
24900
25005
  PUDDLE_INTERNAL_REFRESH: "1"
24901
25006
  };
24902
25007
  delete env[COCKPIT_CHILD_ENV];
24903
- const child = spawn8(process.execPath, [process.argv[1] ?? "", ...argv], {
25008
+ const child = spawn9(process.execPath, [process.argv[1] ?? "", ...argv], {
24904
25009
  detached: true,
24905
25010
  stdio: ["ignore", fd, fd],
24906
25011
  env
@@ -25135,7 +25240,7 @@ async function installDesktopAppImage(version2, logger) {
25135
25240
  ...protocol ? { protocol } : {}
25136
25241
  });
25137
25242
  logger.info(`installed \u2014 run it directly (${target}) or add it to your launcher`);
25138
- const opener = spawn9("xdg-open", [dir], { stdio: "ignore", detached: true });
25243
+ const opener = spawn10("xdg-open", [dir], { stdio: "ignore", detached: true });
25139
25244
  opener.on("error", () => void 0);
25140
25245
  opener.unref();
25141
25246
  return 0;
@@ -25302,7 +25407,7 @@ function timestampedLogger() {
25302
25407
 
25303
25408
  // src/cli/run.ts
25304
25409
  function assetsDir() {
25305
- const here = dirname12(fileURLToPath5(import.meta.url));
25410
+ const here = dirname13(fileURLToPath5(import.meta.url));
25306
25411
  for (const candidate of [join17(here, "public"), join17(here, "..", "..", "dist", "public")]) {
25307
25412
  if (existsSync7(join17(candidate, "index.html"))) return candidate;
25308
25413
  }
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SettingsDialog-CGT3gjKB.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/auth-C3Hg0pRq.js","assets/LazyTerminal-CRonN-zb.js","assets/preload-helper-Czpn1I53.js","assets/dialog-UpZ_vNTE.js","assets/button-DkCgQgIz.js","assets/x-CZCUod6A.js","assets/createLucideIcon-DyMAgLa3.js","assets/notification-delivery-CDu_5PS7.js","assets/dist-v3Pwgb3Q.js","assets/protocol-support-CLMCHX8i.js","assets/switch-SW6BMps1.js","assets/client-settings-CwqpIric.js","assets/index-xDhpMZgv.js","assets/index-CAvJOpdz.css","assets/disclosure-D7vpyXdR.js","assets/chevron-down--sjpQEHH.js","assets/dist-C2WZA469.js","assets/code-DRWf9a5s.js","assets/errors-BH_S68Hd.js","assets/use-debounced-value-C86N-mOK.js","assets/Dashboard-3XQN7EWB.js","assets/project-abbrev-Br6sQqPh.js","assets/context-menu-0Tb8cG9E.js","assets/NewProjectDialog-Bsp8NGgY.js","assets/ws-DNNH0sEH.js","assets/Workspace-ZdFFHXHa.js","assets/copy-CKvSfzPk.js","assets/media-refresh-store-Ddvr6wz1.js","assets/use-ui-state-BiAROr3D.js","assets/preview-kind-QJSMKfUN.js","assets/debounce-B9DrqirV.js","assets/whole-word-2m2pmAFT.js","assets/selection-actions-Bh9Fkkqv.js","assets/drafts-B_tChlzR.js","assets/buffer-logic-BAkSBQT7.js","assets/view-state-store-C6OmciCC.js","assets/scroll-restoration-hNqYmCAE.js","assets/Workspace-DdL3ODEC.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./jsx-runtime-ffCh33zF.js";import{B as i,O as a,V as o,j as s,l as c,o as l,r as u,v as d}from"./auth-C3Hg0pRq.js";import{c as f,f as p,i as m,o as h,s as g,u as _}from"./LazyTerminal-CRonN-zb.js";import{a as v,b as y,d as b,f as x,g as S,h as C,i as w,l as T,m as E,o as D,p as O,s as k,t as A,u as j,v as M,x as ee}from"./notification-delivery-CDu_5PS7.js";import{i as te,r as ne,t as re}from"./client-settings-CwqpIric.js";import{t as ie}from"./preload-helper-Czpn1I53.js";import{a as ae,n as oe,o as se,r as ce,t as le}from"./index-xDhpMZgv.js";import{i as ue,n as de,t as fe}from"./dist-v3Pwgb3Q.js";import{$t as pe,A as me,B as he,Bt as N,C as ge,D as _e,E as P,Et as ve,F as ye,Gt as be,Ht as xe,It as Se,Jt as Ce,K as we,Kt as F,M as Te,Mt as Ee,N as De,Nt as Oe,O as ke,P as Ae,Pt as je,Qt as Me,St as Ne,T as Pe,Ut as Fe,V as Ie,Vt as Le,W as Re,Wt as ze,Xt as Be,Y as Ve,Yt as He,Z as Ue,Zt as We,_ as Ge,a as Ke,b as qe,ct as Je,ft as Ye,g as Xe,gt as Ze,ht as Qe,k as $e,lt as et,m as tt,mt as nt,nt as rt,ot as it,p as at,pt as ot,qt as st,rt as ct,st as lt,tt as ut,w as dt,x as ft,y as pt,zt as mt}from"./protocol-support-CLMCHX8i.js";import{n as ht,t as gt}from"./copy-CKvSfzPk.js";import{a as _t,c as vt,d as yt,i as bt,l as xt,n as St,o as Ct,s as wt,t as Tt,u as Et}from"./project-abbrev-Br6sQqPh.js";import{S as I,c as Dt,l as Ot,n as kt,s as At,t as jt,u as Mt,v as L}from"./dialog-UpZ_vNTE.js";import{i as Nt,t as R}from"./button-DkCgQgIz.js";import{a as Pt,c as Ft,d as It,f as Lt,l as Rt,t as zt,u as Bt}from"./switch-SW6BMps1.js";import{$ as Vt,G as Ht,H as Ut,J as Wt,K as Gt,Q as Kt,U as qt,W as Jt,X as Yt,Y as Xt,at as Zt,d as Qt,et as $t,f as en,h as z,i as tn,it as B,m as nn,nt as rn,ot as V,p as an,q as on,r as sn,rt as H,t as cn,tt as ln}from"./use-ui-state-BiAROr3D.js";import{n as U}from"./x-CZCUod6A.js";import{t as W}from"./createLucideIcon-DyMAgLa3.js";import{t as un}from"./NewProjectDialog-Bsp8NGgY.js";import{n as G}from"./errors-BH_S68Hd.js";import{t as K}from"./ws-DNNH0sEH.js";var q=e(t(),1),J=r();function dn(){let[e,t]=(0,q.useState)(`Opening forwarded application…`);return(0,q.useEffect)(()=>{if(!/^\/forward\/([^/]+)\/(\d+)$/.exec(window.location.pathname)){t(`This forwarding link is invalid.`);return}let e=!0;return ht(new URL(window.location.href)).then(t=>{e&&window.location.replace(t)}).catch(()=>{e&&t(`The application is unavailable. Reconnect to Puddle and open this link again.`)}),()=>{e=!1}},[]),(0,J.jsx)(`p`,{className:`p-8 text-sm text-fg-secondary`,children:e})}var fn=class extends We{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new je({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=pn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=pn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=pn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=pn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){N.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ze(t,e))}findAll(e={}){return this.getAll().filter(t=>ze(e,t))}notify(e){N.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return N.batch(()=>Promise.all(e.map(e=>e.continue().catch(F))))}};function pn(e){return e.options.scope?.id}var mn=class extends We{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Fe(r,t),a=this.get(i);return a||(a=new Se({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){N.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>be(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>be(e,t)):t}notify(e){N.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){N.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){N.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},hn=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new mn,this.#t=e.mutationCache||new fn,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Be.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=mt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Ce(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=Le(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return N.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;N.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return N.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=N.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(F).catch(F)}invalidateQueries(e,t={}){return N.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=N.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(F)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(F)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Ce(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(F).catch(F)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(F).catch(F)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return mt.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(xe(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{st(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(xe(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{st(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Fe(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===He&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},gn=class extends q.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidUpdate(e){this.state.error!==null&&e.resetOn!==this.props.resetOn&&this.setState({error:null})}componentDidCatch(e,t){console.error(`Puddle: the ${this.props.scope} crashed`,e,t.componentStack)}render(){let{error:e}=this.state;return e===null?this.props.children:(0,J.jsxs)(`div`,{className:`flex h-full min-h-40 flex-col items-center justify-center gap-4 px-8 py-10 text-center`,children:[(0,J.jsxs)(`p`,{className:`text-sm text-fg`,children:[`The `,this.props.scope,` stopped rendering.`]}),(0,J.jsx)(`p`,{className:`max-w-lg font-mono text-2xs leading-relaxed text-interrupted`,children:e.message||String(e)}),(0,J.jsx)(`p`,{className:`max-w-sm text-2xs leading-relaxed text-fg-muted`,children:`Your sessions and their worktrees are on the daemon and untouched; the layout is saved. The console has the full stack.`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>this.setState({error:null}),className:`text-2xs font-medium text-fg-gold transition-colors hover:underline`,children:`Try again`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Reload`})]})]})}};function _n(){return(0,J.jsx)(fe,{theme:(0,q.useSyncExternalStore)(ae,ce),position:`bottom-right`,toastOptions:{style:{background:`var(--bg-elevated)`,border:`none`,boxShadow:`0 8px 30px rgb(0 0 0 / 0.25)`,color:`var(--text-primary)`},classNames:{description:`whitespace-pre-wrap break-words font-mono text-2xs leading-snug max-h-40 overflow-y-auto`}}})}function vn(){return(0,J.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,J.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-24`,children:[(0,J.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm leading-relaxed text-fg-secondary`,children:[(0,J.jsxs)(`p`,{children:[`Authorise this browser by running`,` `,(0,J.jsx)(`span`,{className:`font-mono text-accent`,children:`puddle launch`}),` in a terminal.`]}),(0,J.jsx)(`p`,{children:`Use the link it opens. Your sessions, drafts and layouts stay in place.`})]})]})})}var yn=e(n(),1),bn=`a, button, [role="button"], [role="slider"], input, select, textarea, summary, label, [onclick], .cursor-pointer`,xn=`.monaco-editor`;function Sn(e,t){return e?.closest(xn)&&!e.closest(t)?`text`:e?.closest(bn)?`interactive`:`default`}function Cn(e,t=`.no-custom-caret`){(0,q.useEffect)(()=>{let n=e.current;if(!n)return;let r=window.matchMedia(`(pointer: fine)`),i=()=>{n.style.opacity=`0`},a=e=>{if(e.pointerType===`touch`||!r.matches){i();return}n.style.transform=`translate3d(${e.clientX}px, ${e.clientY}px, 0) translate(-50%, -50%)`;let a=e.target instanceof Element?e.target:null;if(a instanceof HTMLIFrameElement){i();return}n.style.opacity=`1`;let o=a?.closest(xn),s=Sn(a,t),c=s===`text`,l=s===`interactive`,u=c;if(c&&o){let e=getComputedStyle(o);n.style.setProperty(`--custom-cursor-caret-height`,`${Math.round(Number.parseFloat(e.fontSize)*1.3)}px`)}else if(!l&&a&&!a.closest(t)&&Array.from(a.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())){let e=getComputedStyle(a);e.userSelect!==`none`&&(u=!0,n.style.setProperty(`--custom-cursor-caret-height`,`${Math.round(Number.parseFloat(e.fontSize)*1.3)}px`))}n.classList.toggle(`is-interactive`,l),n.classList.toggle(`is-text`,u)};return window.addEventListener(`pointermove`,a,{passive:!0}),document.documentElement.addEventListener(`pointerleave`,i),window.addEventListener(`blur`,i),()=>{window.removeEventListener(`pointermove`,a),document.documentElement.removeEventListener(`pointerleave`,i),window.removeEventListener(`blur`,i)}},[t,e])}var wn=[`top`,`right`,`bottom`,`left`];function Tn(){let e=(0,q.useRef)(null);return Cn(e),(0,J.jsx)(`div`,{ref:e,className:`custom-cursor drafting-cursor`,"aria-hidden":`true`,children:wn.map(e=>(0,J.jsx)(`span`,{className:`drafting-cursor-tick`,"data-side":e},e))})}function En(){let e=(0,q.useRef)(null);return Cn(e),(0,J.jsx)(`div`,{ref:e,className:`custom-cursor invert-cursor`,"aria-hidden":`true`})}var Dn=`h1, h2, h3, h4, h5, h6, .no-rangefinder-caret`,On=40.5,Y=4.05,kn=Y*Math.sqrt(3)/2;function An(){let e=[],t=[],n=On/2,r=Math.ceil(n/kn)+1,i=e=>Math.round(e*100)/100,a=e=>`M${e.map(([e,t])=>`${i(e)} ${i(t)}`).join(`L`)}Z`;for(let i=-r;i<r;i+=1){let o=n+i*kn,s=o+kn,c=(i%2+2)%2*(Y/2);for(let i=-r;i<r;i+=1){let r=n+i*Y+c,l=[[r+Y/2,o],[r,s],[r+Y,s]],u=[[r+Y/2,o],[r+3*Y/2,o],[r+Y,s]],d=e=>{let t=e.map(([e])=>e),n=e.map(([,e])=>e);return Math.max(...t)>0&&Math.min(...t)<On&&Math.max(...n)>0&&Math.min(...n)<On};d(l)&&e.push(a(l)),d(u)&&t.push(a(u))}}return{light:e.join(``),dark:t.join(``)}}var jn=An();function Mn(){let e=(0,q.useRef)(null);return Cn(e,Dn),(0,J.jsx)(`div`,{ref:e,className:`custom-cursor rangefinder-cursor`,"aria-hidden":`true`,children:(0,J.jsxs)(`svg`,{className:`rangefinder-cursor-facets`,viewBox:`0 0 ${On} ${On}`,focusable:`false`,children:[(0,J.jsx)(`path`,{className:`rangefinder-cursor-facet-light`,d:jn.light}),(0,J.jsx)(`path`,{className:`rangefinder-cursor-facet-dark`,d:jn.dark})]})})}function Nn(){let{cursorPackage:e}=te(),t=null;switch(e){case`rangefinder`:t=(0,J.jsx)(Mn,{});break;case`drafting`:t=(0,J.jsx)(Tn,{});break;case`invert`:t=(0,J.jsx)(En,{});break;case`system`:return null}return(0,yn.createPortal)(t,document.body)}var Pn=W(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),Fn=W(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),In=W(`monitor-cog`,[[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`m14.305 7.53.923-.382`,key:`1mlnsw`}],[`path`,{d:`m15.228 4.852-.923-.383`,key:`82mpwg`}],[`path`,{d:`m16.852 3.228-.383-.924`,key:`ln4sir`}],[`path`,{d:`m16.852 8.772-.383.923`,key:`1dejw0`}],[`path`,{d:`m19.148 3.228.383-.924`,key:`192kgf`}],[`path`,{d:`m19.53 9.696-.382-.924`,key:`fiavlr`}],[`path`,{d:`m20.772 4.852.924-.383`,key:`1j8mgp`}],[`path`,{d:`m20.772 7.148.924.383`,key:`zix9be`}],[`path`,{d:`M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7`,key:`1tnzv8`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}]]),Ln=W(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),Rn=W(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),zn=W(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Bn=W(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]);function Vn(){let e=nt(),t=Ie(),[n,r]=(0,q.useState)(``),[i,a]=(0,q.useState)(s),o=()=>{n.trim()&&t.mutate({name:n.trim(),branch_prefix:i.trim()},{onSuccess:e=>Pe(e.id)})},c=(e.data?.length??0)>0;return(0,J.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,J.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-16`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,J.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Who is working?`})]}),c&&(0,J.jsx)(`div`,{className:`flex flex-col`,children:e.data.map(e=>(0,J.jsxs)(`button`,{onClick:()=>Pe(e.id),className:`flex items-center gap-3 rounded-md px-3 py-2.5 text-left transition-colors hover:bg-elevated active:bg-border/70`,children:[(0,J.jsx)(C,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,J.jsx)(`span`,{className:U(`text-base`,S(e.icon_colour)||`text-fg`),children:e.name}),e.branch_prefix&&(0,J.jsxs)(`span`,{className:`ml-auto text-2xs text-fg-muted`,children:[e.branch_prefix,`…`]})]},e.id))}),(0,J.jsxs)(`form`,{className:`flex flex-col gap-5`,onSubmit:e=>{e.preventDefault(),o()},children:[c&&(0,J.jsx)(`p`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`or create a profile`}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(h,{htmlFor:`profile-name`,children:`Name`}),(0,J.jsx)(g,{id:`profile-name`,placeholder:`e.g. alice`,value:n,onChange:e=>r(e.target.value),className:`h-10`,autoFocus:!c})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(h,{htmlFor:`branch-prefix`,children:`Branch prefix`}),(0,J.jsx)(g,{id:`branch-prefix`,placeholder:`no prefix`,value:i,onChange:e=>a(e.target.value),className:`h-10`})]}),t.error&&(0,J.jsx)(`p`,{className:`text-xs text-danger`,children:t.error.message}),(0,J.jsx)(R,{type:`submit`,size:`lg`,className:`self-start px-6`,disabled:!n.trim()||t.isPending,children:`Create profile`})]})]})})}var Hn=1,Un=.9,Wn=.8,Gn=.17,Kn=.1,qn=.999,Jn=.9999,Yn=.99,Xn=/[\\\/_+.#"@\[\(\{&]/,Zn=/[\\\/_+.#"@\[\(\{&]/g,Qn=/[\s-]/,$n=/[\s-]/g;function er(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Hn:Yn;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=er(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Hn:Xn.test(e.charAt(l-1))?(d*=Wn,p=e.slice(i,l-1).match(Zn),p&&i>0&&(d*=qn**+p.length)):Qn.test(e.charAt(l-1))?(d*=Un,m=e.slice(i,l-1).match($n),m&&i>0&&(d*=qn**+m.length)):(d*=Gn,i>0&&(d*=qn**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=Jn)),(d<Kn&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=er(e,t,n,r,l+1,a+2,o),f*Kn>d&&(d=f*Kn)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function tr(e){return e.toLowerCase().replace($n,` `)}function nr(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,er(e,t,tr(e),tr(t),0,0,{})}var rr=`[cmdk-group=""]`,ir=`[cmdk-group-items=""]`,ar=`[cmdk-group-heading=""]`,or=`[cmdk-item=""]`,sr=`${or}:not([aria-disabled="true"])`,cr=`cmdk-item-select`,X=`data-value`,lr=(e,t,n)=>nr(e,t,n),ur=q.createContext(void 0),dr=()=>q.useContext(ur),fr=q.createContext(void 0),pr=()=>q.useContext(fr),mr=q.createContext(void 0),hr=q.forwardRef((e,t)=>{let n=Dr(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Dr(()=>new Set),i=Dr(()=>new Map),a=Dr(()=>new Map),o=Dr(()=>new Set),s=Er(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=L(),y=L(),b=L(),x=q.useRef(null),S=kr();Q(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Q(()=>{S(6,k)},[]);let C=q.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=q.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??lr;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(ir);t?t.appendChild(e.parentElement===t?e:e.closest(`${ir} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${ir} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${rr}[${X}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(X);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(rr)?.querySelector(ar))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${or}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(sr)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(X))}function ee(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(X))}function te(e){let t=A()?.closest(rr),n;for(;t&&!n;)t=e>0?wr(t,rr):Tr(t,rr),n=t?.querySelector(sr);n?C.setState(`value`,n.getAttribute(X)):ee(e)}let ne=()=>M(j().length-1),re=e=>{e.preventDefault(),e.metaKey?ne():e.altKey?te(1):ee(1)},ie=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?te(-1):ee(-1)};return q.createElement(I.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&re(e);break;case`ArrowDown`:re(e);break;case`p`:case`k`:g&&e.ctrlKey&&ie(e);break;case`ArrowUp`:ie(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),ne();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(cr);t.dispatchEvent(e)}}}}},q.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Mr},c),jr(e,e=>q.createElement(fr.Provider,{value:C},q.createElement(ur.Provider,{value:w},e))))}),gr=q.forwardRef((e,t)=>{let n=L(),r=q.useRef(null),i=q.useContext(mr),a=dr(),o=Er(e),s=o.current?.forceMount??i?.forceMount;Q(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Or(n,r,[e.value,e.children,r],e.keywords),l=pr(),u=$(e=>e.value&&e.value===c.current),d=$(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);q.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(cr,f),()=>t.removeEventListener(cr,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return q.createElement(I.div,{ref:Nt(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),_r=q.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=L(),s=q.useRef(null),c=q.useRef(null),l=L(),u=dr(),d=$(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Q(()=>u.group(o),[]),Or(o,s,[e.value,e.heading,c]);let f=q.useMemo(()=>({id:o,forceMount:i}),[i]);return q.createElement(I.div,{ref:Nt(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&q.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),jr(e,e=>q.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},q.createElement(mr.Provider,{value:f},e))))}),vr=q.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=q.useRef(null),a=$(e=>!e.search);return!n&&!a?null:q.createElement(I.div,{ref:Nt(i,t),...r,"cmdk-separator":``,role:`separator`})}),yr=q.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=pr(),o=$(e=>e.search),s=$(e=>e.selectedItemId),c=dr();return q.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),q.createElement(I.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),br=q.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=q.useRef(null),o=q.useRef(null),s=$(e=>e.selectedItemId),c=dr();return q.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),q.createElement(I.div,{ref:Nt(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},jr(e,e=>q.createElement(`div`,{ref:Nt(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),xr=q.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return q.createElement(At,{open:n,onOpenChange:r},q.createElement(Mt,{container:o},q.createElement(Ot,{"cmdk-overlay":``,className:i}),q.createElement(Dt,{"aria-label":e.label,"cmdk-dialog":``,className:a},q.createElement(hr,{ref:t,...s}))))}),Sr=q.forwardRef((e,t)=>$(e=>e.filtered.count===0)?q.createElement(I.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Cr=q.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return q.createElement(I.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},jr(e,e=>q.createElement(`div`,{"aria-hidden":!0},e)))}),Z=Object.assign(hr,{List:br,Item:gr,Input:yr,Group:_r,Separator:vr,Dialog:xr,Empty:Sr,Loading:Cr});function wr(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Tr(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Er(e){let t=q.useRef(e);return Q(()=>{t.current=e}),t}var Q=typeof window>`u`?q.useEffect:q.useLayoutEffect;function Dr(e){let t=q.useRef();return t.current===void 0&&(t.current=e()),t}function $(e){let t=pr(),n=()=>e(t.snapshot());return q.useSyncExternalStore(t.subscribe,n,n)}function Or(e,t,n,r=[]){let i=q.useRef(),a=dr();return Q(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(X,s),i.current=s}),i}var kr=()=>{let[e,t]=q.useState(),n=Dr(()=>new Map);return Q(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Ar(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function jr({asChild:e,children:t},n){return e&&q.isValidElement(t)?q.cloneElement(Ar(t),{ref:t.ref},n(t.props.children)):n(t)}var Mr={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Nr({className:e,...t}){return(0,J.jsx)(Z,{className:U(`flex size-full flex-col overflow-hidden rounded-lg bg-elevated`,e),...t})}function Pr({open:e,onOpenChange:t,children:n}){return(0,J.jsx)(jt,{open:e,onOpenChange:t,children:(0,J.jsx)(kt,{className:`max-w-lg overflow-hidden p-0 [&>button]:hidden`,children:(0,J.jsx)(Nr,{loop:!0,children:n})})})}function Fr({className:e,...t}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pt-1`,children:[(0,J.jsx)(rn,{className:`size-4 shrink-0 text-fg-muted`}),(0,J.jsx)(Z.Input,{className:U(`flex h-10 w-full bg-transparent text-sm text-fg outline-none placeholder:text-fg-muted`,e),...t})]})}function Ir({className:e,...t}){return(0,J.jsx)(Z.List,{className:U(`max-h-72 overflow-y-auto p-1`,e),...t})}function Lr(e){return(0,J.jsx)(Z.Empty,{className:`py-6 text-center text-sm text-fg-muted`,...e})}function Rr({className:e,...t}){return(0,J.jsx)(Z.Group,{className:U(`overflow-hidden [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-2xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wide [&_[cmdk-group-heading]]:text-fg-muted`,e),...t})}function zr({className:e,...t}){return(0,J.jsx)(Z.Item,{className:U(p,_,`[&_svg]:size-3.5 [&_svg]:text-fg-muted data-[selected=true]:[&_svg]:text-action-ink`,e),...t})}function Br({className:e,...t}){return(0,J.jsx)(`span`,{className:U(`ml-auto font-mono text-2xs tracking-widest text-fg-muted`,e),...t})}var Vr=new class{transport;reload;pause;phase=`idle`;pending=null;constructor(e=fetch,t=()=>window.location.reload(),n=e=>new Promise(t=>setTimeout(t,e))){this.transport=e,this.reload=t,this.pause=n}refresh(e=12e4){return this.pending||=this.run(e).finally(()=>{this.pending=null}),this.pending}async run(e){this.phase=`requesting`;let t={authorization:`Bearer ${u.get()??``}`,"content-type":`application/json`};try{let n=await this.transport(`/cockpit/refresh`,{method:`POST`,headers:t,signal:AbortSignal.timeout(1e4),body:JSON.stringify({refreshId:crypto.randomUUID()})});if(n.status!==202)throw Error(`refresh rejected`);let r=d.parse(await n.json());this.phase=`waiting`;let i=Date.now()+e;for(;Date.now()<i;){await this.pause(1e3);try{let e=await this.transport(`/cockpit/status`,{headers:t,cache:`no-store`,signal:AbortSignal.timeout(3e3)});if(!e.ok)continue;let n=c.parse(await e.json());if(n.instance===r.instance||n.refreshId!==r.refreshId||n.upstream!==`ready`)continue;return this.phase=`complete`,this.reload(),!0}catch{}}}catch{}return this.phase=`failed`,!1}},Hr=null;function Ur(e){return Hr=e,()=>{Hr===e&&(Hr=null)}}function Wr(){Hr?.()}var Gr=new Set;function Kr(){return[...Gr].flatMap(e=>e())}function qr({onNewSession:e,onNewProject:t}){let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(`commands`),[o,s]=(0,q.useState)(``),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(!1),f=Et(),p=yt(),m=P(),h=p.id,g=Ze(m??void 0),_=ve(h),v=Xt();(0,q.useEffect)(()=>qe(`palette.toggle`,()=>r(e=>!e)),[]),(0,q.useEffect)(()=>Vt(()=>r(!0)),[]),(0,q.useEffect)(()=>{n||(a(`commands`),s(``),l(null),d(!1))},[n]);let b=(0,q.useMemo)(()=>{let n=[];for(let e of g.data??[])n.push({id:`project-${e.id}`,group:`Projects`,label:e.name,icon:St,keywords:`switch project open`,run:()=>void f(`/project/${e.id}`)});for(let e of _.data??[])e.status!==`archived`&&n.push({id:`session-${e.id}`,group:`Sessions`,label:v(e),icon:Tt,keywords:`switch session ${e.branch}`,run:()=>void f(`/project/${e.project_id}/session/${e.id}`)});return h!==void 0&&e&&n.push({id:`new-agent`,group:`Actions`,label:`New agent`,icon:Lt,keywords:`new agent create start session`,run:()=>e()},{id:`new-terminal`,group:`Actions`,label:`New terminal`,icon:Tt,keywords:`new terminal create start shell session`,run:()=>e({kind:`terminal`})}),h!==void 0&&n.push({id:`open-path`,group:`Actions`,label:`Open path`,icon:St,keywords:`open path file directory folder editor tree browse absolute relative home`,closeOnRun:!1,run:()=>{s(``),l(null),a(`path`)}}),t&&n.push({id:`new-project`,group:`Actions`,label:`New project`,icon:It,keywords:`new project open create repository repo workspace`,run:t}),n.push({id:`theme-dark`,group:`Theme`,label:`Switch theme: dark`,icon:y,keywords:`switch theme dark appearance`,run:()=>void le(`dark`)},{id:`theme-light`,group:`Theme`,label:`Switch theme: light`,icon:M,keywords:`switch theme light appearance`,run:()=>void le(`light`)},{id:`theme-system`,group:`Theme`,label:`Switch theme: system`,icon:In,keywords:`switch theme system appearance`,run:()=>void le(`system`)},{id:`open-settings`,group:`Actions`,label:`Settings`,icon:Bn,keywords:`open settings preferences options configure`,run:()=>Pt()},{id:`switch-profile`,group:`Actions`,label:`Switch profile`,icon:Ft,keywords:`switch profile identity user change`,run:()=>dt.set(null)},{id:`refresh-connection`,group:`Actions`,label:`Refresh connection`,icon:Bt,keywords:`refresh connection reconnect restart cockpit tunnel ssh daemon`,run:()=>Wr()}),[...n,...Kr()]},[g.data,_.data,h,f,e,t,v]),x=(0,q.useMemo)(()=>{let e=new Map;for(let t of b){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return[...e.entries()]},[b]),S=async()=>{let e=o.trim();if(!(e===``||u)){d(!0),l(null);try{await Yt(e),r(!1)}catch(e){l(e instanceof Error?e.message:`Could not open that path.`)}finally{d(!1)}}};return(0,J.jsxs)(Pr,{open:n,onOpenChange:r,children:[(0,J.jsx)(Fr,{value:o,onValueChange:e=>{s(e),l(null)},placeholder:i===`path`?`Enter a path…`:`Type a command or search…`,onKeyDown:e=>{i===`path`&&(e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),S()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),a(`commands`),s(``),l(null)))}}),i===`path`?(0,J.jsx)(Ir,{children:(0,J.jsxs)(`div`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[(0,J.jsx)(`p`,{children:`Relative paths start from the bound worktree or project. Absolute and ~ paths work too.`}),(0,J.jsx)(`p`,{className:c?`mt-2 text-danger`:`mt-2`,"aria-live":`polite`,children:c??(u?`Opening…`:`Press Enter to open.`)})]})}):(0,J.jsxs)(Ir,{children:[(0,J.jsx)(Lr,{children:`Nothing matches.`}),x.map(([e,t])=>(0,J.jsx)(Rr,{heading:e,children:t.map(e=>{let t=e.icon;return(0,J.jsxs)(zr,{value:`${e.label} ${e.keywords??``}`,onSelect:()=>{e.closeOnRun!==!1&&r(!1),e.run()},children:[t&&(0,J.jsx)(t,{}),e.label,e.shortcut&&(0,J.jsx)(Br,{children:e.shortcut})]},e.id)})},e))]})]})}function Jr(){let e=document.activeElement;return e instanceof Element&&e.closest(`.xterm`)!==null}function Yr(){let e=document.activeElement;return e instanceof Element&&e.closest(`.monaco-editor`)!==null}function Xr(){let e=ot(P()??void 0).data?.hotkeys;return(0,q.useEffect)(()=>{ft(e&&typeof e==`object`?e:void 0)},[e]),(0,q.useEffect)(()=>qe(`window.close`,()=>{let e=Me();e?.closeWindow?e.closeWindow():window.close()}),[]),(0,q.useEffect)(()=>{let e=e=>{let t=tt(e);if(!t)return;let n=at(t);if(!n)return;let r=Xe(n);if(!r||!pt(r,Yr()))return;let i=Ge(n);i&&(e.preventDefault(),e.stopPropagation(),i())},t=e=>{let t=tt(e);if(!t)return;let n=at(t);if(!n)return;let r=Xe(n);if(!r||r.editor&&Yr()||r.deferInTerminal&&Jr())return;let i=Ge(n);i&&(e.preventDefault(),i())};return window.addEventListener(`keydown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,e,!0),window.removeEventListener(`keydown`,t)}},[]),null}var Zr=4e3;function Qr(){let[e,t]=(0,q.useState)(`hidden`),n=(0,q.useRef)(e);n.current=e,(0,q.useEffect)(()=>{let e=null,r=K.onConnectionChange(r=>{if(r){e!==null&&clearTimeout(e),e=null,n.current===`lost`&&t(`hidden`);return}e!==null||n.current!==`hidden`||(e=setTimeout(()=>{e=null,n.current===`hidden`&&t(`lost`)},Zr))});return()=>{r(),e!==null&&clearTimeout(e)}},[]);let r=(0,q.useCallback)(async()=>{n.current!==`refreshing`&&(t(`refreshing`),await Vr.refresh()||(de.error(`The cockpit has not come back — it may need a terminal (ssh re-auth): puddle refresh`),t(K.isConnected()?`hidden`:`lost`)))},[]);return(0,q.useEffect)(()=>Ur(()=>void r()),[r]),e===`hidden`?null:(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 bg-elevated px-3 py-2`,children:[(0,J.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:e===`refreshing`?`Restarting the cockpit.`:`Connection to the daemon lost.`}),e===`lost`&&(0,J.jsxs)(R,{size:`sm`,className:`ml-auto`,onClick:()=>void r(),children:[(0,J.jsx)(Bt,{}),`Refresh connection`]})]})}function $r({label:e,percentage:t,hint:n}){let r=Math.max(0,Math.min(100,t));return(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`w-24 shrink-0 truncate text-2xs text-fg-muted`,title:e,children:e}),(0,J.jsx)(`span`,{className:`relative h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-border`,children:(0,J.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full ${r>=90?`bg-danger`:r>=75?`bg-warning`:`bg-action`}`,style:{width:`${r}%`}})}),(0,J.jsxs)(`span`,{className:`shrink-0 text-2xs tabular-nums text-fg-muted`,children:[Math.round(r),`%`,n?` · ${n}`:``]})]})}function ei(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ti(e){if(e===null)return`never`;let t=new Date(e).getTime(),n=Math.max(0,Math.round((Date.now()-t)/1e3));if(n<60)return`just now`;let r=Math.round(n/60);if(r<60)return`${r}m ago`;let i=Math.round(r/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}function ni({account:e,onLogin:t,onStartSession:n,installed:r=!0}){let i=Te(e.id),a=e.logged_in?n:r?t:null,o=i.data?.subscription;return(0,J.jsxs)(`div`,{className:`rounded-md px-2 py-2 transition-colors hover:bg-elevated`,children:[(0,J.jsxs)(`button`,{type:`button`,disabled:a===null,onClick:()=>a?.(),className:`flex w-full items-center gap-3 text-left disabled:cursor-default`,children:[(0,J.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${e.logged_in?`bg-success`:`bg-idle`}`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.label}),(0,J.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[e.logged_in?`logged in`:`logged out`,i.data&&(0,J.jsxs)(J.Fragment,{children:[` · `,i.data.session_count,` session`,i.data.session_count===1?``:`s`,i.data.active_session_count>0&&` (${i.data.active_session_count} active)`,` · `,`last `,ti(i.data.last_activity_at)]})]}),i.data?.agent_usage&&(0,J.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[ei(i.data.agent_usage.input_tokens),` in ·`,` `,ei(i.data.agent_usage.output_tokens),` out ·`,` `,ei(i.data.agent_usage.cache_read_input_tokens),` cached ·`,` `,i.data.agent_usage.message_count,` msgs`]}),i.data?.live_usage?.context_used_percentage!=null&&(0,J.jsx)(`span`,{className:`mt-1 block`,children:(0,J.jsx)($r,{label:`context`,percentage:i.data.live_usage.context_used_percentage})})]}),(0,J.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted`,children:r?e.logged_in?n?`new agent`:``:(0,J.jsxs)(`span`,{className:`flex items-center gap-1 text-warning`,children:[(0,J.jsx)(ee,{className:`size-3`}),`sign in`]}):`unavailable`})]}),o!=null&&o.windows.length>0&&(0,J.jsx)(`div`,{className:`mt-2 flex flex-col gap-1 pl-5`,children:o.windows.map(e=>(0,J.jsx)($r,{label:e.label,percentage:e.used_percentage,hint:e.resets==null?void 0:`resets ${e.resets}`},e.key))})]})}function ri(){let[e,t]=(0,q.useState)(!1),[n,r]=(0,q.useState)(!1),i=P(),a=nt(),o=Je(),s=a.data?.find(e=>e.id===i),c=De(i??void 0),l=Ae(),u=ct(),{open:d,handler:f}=Wt(),[p,m]=(0,q.useState)(null),h=e=>u.mutate(e.id,{onSuccess:t=>m({stream:t.stream,label:`${e.agent_type}/${e.label}`}),onError:e=>G(e)}),g=e=>{t(!1),d({accountId:e.id})};return n&&s?(0,J.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-3`,children:[(0,J.jsx)(C,{icon:s.icon,colour:s.icon_colour}),(0,J.jsx)($t,{initial:s.name,maxLength:100,className:U(`w-32 text-sm`,S(s.icon_colour)),onCommit:e=>{r(!1);let t=e.trim();!i||!t||t===s?.name||o.mutate({id:i,name:t},{onError:e=>G(e)})},onCancel:()=>r(!1)})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(x,{open:e,onOpenChange:t,children:[(0,J.jsxs)(H,{children:[(0,J.jsx)(V,{asChild:!0,children:(0,J.jsx)(E,{asChild:!0,children:(0,J.jsxs)(R,{variant:`ghost`,size:`sm`,className:`font-sans compact:h-7 compact:px-1.5`,children:[(0,J.jsx)(C,{icon:s?.icon,colour:s?.icon_colour}),(0,J.jsx)(`span`,{className:S(s?.icon_colour),...ln(()=>{t(!1),r(!0)}),children:s?.name??`…`})]})})}),(0,J.jsx)(B,{children:`Profile`})]}),(0,J.jsxs)(O,{className:`w-[28rem] max-w-[calc(100vw-1rem)]`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(l.data??[]).map(e=>{let t=c.data?.filter(t=>t.agent_type===e.id)??[];if(t.length===0)return null;let n=e.available!==!1;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,J.jsxs)(`span`,{className:`px-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:[e.display_name,!n&&(0,J.jsxs)(`span`,{className:`ml-2 normal-case tracking-normal text-fg-muted`,children:[`not installed — no `,e.binary??e.id,` on PATH`]})]}),t.map(e=>(0,J.jsx)(ni,{account:e,onLogin:()=>h(e),onStartSession:f&&n?()=>g(e):null,installed:n},e.id))]},e.id)}),c.data?.length===0&&(0,J.jsx)(`p`,{className:`px-2 text-sm text-fg-muted`,children:`No accounts yet — add one in settings.`})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,J.jsxs)(R,{variant:`ghost`,size:`sm`,onClick:()=>{t(!1),Pt(`accounts`)},children:[(0,J.jsx)(It,{}),`Add account`]}),(0,J.jsxs)(R,{variant:`ghost`,size:`sm`,className:`ml-auto`,onClick:()=>{t(!1),dt.set(null)},children:[(0,J.jsx)(zn,{}),`Switch profile`]})]})]})]}),p&&(0,J.jsx)(b,{stream:p.stream,label:p.label,onClose:()=>m(null)})]})}var ii=`desktop-update`;function ai(){let e=(0,q.useRef)(null);return(0,q.useEffect)(()=>{let t=Me();if(t?.updateReady===void 0||t.onUpdateReady===void 0)return;let n=t=>{e.current!==t&&(e.current=t,de(`Puddle ${t} is downloaded and ready.`,{id:ii,duration:1/0,closeButton:!0,action:{label:`Restart to update`,onClick:()=>{Me()?.installUpdate?.(),de.loading(`Restarting into Puddle ${t}…`,{id:`${ii}-restarting`,duration:1/0})}}}))};return t.updateReady().then(e=>{e!==null&&n(e)}),t.onUpdateReady(n)},[]),null}function oi(){let e=P(),t=nt().data?.find(t=>t.id===e),n=ot(e??void 0),r=Ne(e??void 0,void 0),i=te(),a=D(),o=k(),s=et(e??``),c=Je(),l=Re(),[u,d]=(0,q.useReducer)(e=>e+1,0);(0,q.useEffect)(()=>ae(()=>d()),[]);let f=(0,q.useRef)(null);(0,q.useEffect)(()=>{f.current=null},[t?.name]);let p=a.data?.available===!0?a.data.file:void 0,m=t!==void 0&&e!==null&&n.data!==void 0&&r.data!==void 0&&p!==void 0,h=t&&p?v(p,t.name):void 0,g=s.isPending||c.isPending||l.isPending||o.isPending||n.isFetching||r.isFetching;(0,q.useEffect)(()=>{if(!m||!h?.enabled||g)return;let a={client:i,theme:se(),profileSettings:n.data,profile:t,scratchpad:r.data},u={setClient:e=>ne(e),setTheme:e=>{typeof e==`string`&&le(e)},patchProfileSettings:e=>s.mutate(e),patchProfileColumns:t=>c.mutate({id:e,...t}),createScratchpad:t=>{for(let n of t)l.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},d=JSON.stringify(h.doc);if(f.current!==d){f.current=d,T(h.doc,u,a,h.groups);return}let p=j(h.groups,a),_=JSON.stringify(p);_!==d&&(f.current=_,o.mutate({profile:t.name,entry:{...h,doc:p,updatedAt:new Date().toISOString()}}))})}function si(e){let t=t=>{let n=o.safeParse(t);n.success&&e(n.data)},n=Me()?.onNotificationClick?.((e,n)=>t(n)),r=e=>{e.data?.t===`notification-click`&&t(e.data.target)};return navigator.serviceWorker?.addEventListener(`message`,r),()=>{n?.(),navigator.serviceWorker?.removeEventListener(`message`,r)}}var ci=5e3,li=`[data-notification-session]`;function ui(e){let t=null,n=()=>{t=null},r=e=>e.target instanceof Element?e.target.closest(li):null,i=e=>{if(!e.isTrusted)return;let n=r(e),i=n?.dataset.notificationSession;t=n&&i?{element:n,session:i,at:performance.now()}:null},a=e=>{r(e)!==t?.element&&n()},o=[`pointerdown`,`keydown`,`input`,`paste`];for(let t of o)e.addEventListener(t,i,!0);return e.addEventListener(`focusin`,a,!0),e.addEventListener(`visibilitychange`,n),e.defaultView?.addEventListener(`blur`,n),{isInteracting(n){return t!==null&&t.session===n&&performance.now()-t.at<ci&&e.visibilityState===`visible`&&e.hasFocus()&&t.element.isConnected&&t.element.dataset.notificationSession===n&&t.element.getClientRects().length>0},dispose(){n();for(let t of o)e.removeEventListener(t,i,!0);e.removeEventListener(`focusin`,a,!0),e.removeEventListener(`visibilitychange`,n),e.defaultView?.removeEventListener(`blur`,n)}}}var di=new Set,fi=e=>!!e&&di.has(e),pi=i.parse({});function mi(e){return e.prefs.muted_projects.includes(e.projectId)?{desktop:!1,sound:!1}:{desktop:e.prefs.desktop&&(e.permission===`granted`||e.permission===`unverified`)&&(e.prefs.when_focused||!e.sessionFocused),sound:e.prefs.sound}}function hi(e,t){for(let[,n]of e.getQueriesData({queryKey:[`sessions`]})){let e=n?.find(e=>e.id===t);if(e)return e}for(let[,n]of e.getQueriesData({queryKey:[`project`]})){let e=n?.sessions.find(e=>e.id===t);if(e)return e}}function gi(e){return e.title??e.agent_title??e.osc_title??e.id.slice(0,8)}function _i(){try{let e=new AudioContext,t=e.createGain();t.gain.value=.04,t.connect(e.destination);for(let[n,r]of[[880,0],[1318.5,.09]]){let i=e.createOscillator();i.type=`sine`,i.frequency.value=n,i.connect(t),i.start(e.currentTime+r),i.stop(e.currentTime+r+.12)}setTimeout(()=>void e.close(),400)}catch{}}function vi(){let e=Et(),t=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=ui(document);return t.current=e,()=>{t.current=null,e.dispose()}},[]),(0,q.useEffect)(()=>si(t=>{t.host||e(`/project/${t.project}/session/${t.session}`,{state:{notificationSession:t.session}})}),[e]),yi(t=>{e(`/project/${t.project_id}/session/${t.id}`,{state:{notificationSession:t.id}})},e=>t.current?.isInteracting(e.id)??!1)}function yi(e,t=()=>document.hasFocus()){let n=Oe(),r=(0,q.useRef)(e);r.current=e;let a=(0,q.useRef)(t);a.current=t;let o=$e(ut().data)??`Puddle`,s=(0,q.useRef)(o);(0,q.useEffect)(()=>{document.title===s.current&&(document.title=o),s.current=o},[o]),(0,q.useEffect)(()=>{let e=new Set,t=()=>{document.title=e.size>0?`(${e.size}) ${s.current}`:s.current},o=!0,c=async e=>{let t=hi(n,e.session);if(!t)try{t=(await _e(n)).find(t=>t.id===e.session)}catch{return}if(!o||!t)return;let c=t,u,d;try{let e=await n.fetchQuery({queryKey:[`project`,c.project_id],queryFn:()=>ue(`GET`,`/api/projects/${c.project_id}`),staleTime:1e4});if(!o)return;d=e.project;let t=d.profile_id,r=await n.fetchQuery({queryKey:[`profile-settings`,t],queryFn:()=>ue(`GET`,`/api/profiles/${t}/settings`),staleTime:1e4});u=i.catch(pi).parse(r.notifications??{})}catch{return}if(!o)return;let f=mi({prefs:u,projectId:c.project_id,sessionFocused:a.current(c),permission:w()});f.sound&&_i(),f.desktop&&!fi(l()?.scope)&&await A({id:e.id?`puddle-event-${e.id}`:`puddle-agent-${c.id}`,title:e.content?.title??gi(c).slice(0,160),body:e.content?.body??(e.reason===`exited`?`Agent finished running`:`Waiting for your input`),target:{project:c.project_id,session:c.id,...l()?.notificationHost?{host:l().notificationHost}:{}}},()=>{o&&r.current(c)},{host:s.current,project:d})},u=K.onAgentNotification(e=>{c(e)}),d=K.onStatus(r=>{let i=e.has(r.session);r.status===`waiting_input`?e.add(r.session):e.delete(r.session),t(),!(r.status!==`waiting_input`||i)&&n.fetchQuery({queryKey:[`version`],queryFn:()=>ue(`GET`,`/api/version`),staleTime:1/0}).then(e=>{if(!(e.protocol.major>22||e.protocol.major===22&&e.protocol.minor>=3))return c({session:r.session,reason:`waiting_input`})}).catch(()=>{})});return()=>{o=!1,d(),u(),document.title=s.current}},[n])}function bi({initial:e,defaultScope:t,allowProject:n=!0,agents:r,onSave:i,onCancel:a}){let[o,s]=(0,q.useState)(e?.title??``),[c,l]=(0,q.useState)(e?.body??``),[u,d]=(0,q.useState)(n?e?.scope??t:`profile`),[p,m]=(0,q.useState)((e?.tags??[]).join(`, `)),[h,_]=(0,q.useState)(e?.agent_type??null),v=()=>{let e=c.trim();e&&i({title:o.trim()||null,body:e,scope:u,tags:p.split(`,`).map(e=>e.trim()).filter(Boolean),agent_type:h})};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(g,{value:o,placeholder:`Title (optional)`,spellCheck:!1,onChange:e=>s(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`h-9 text-sm font-medium`}),(0,J.jsx)(f,{autoFocus:!0,value:c,placeholder:`Prompt or note…`,spellCheck:!1,rows:10,onChange:e=>l(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`?a():e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&v()},className:`resize-y text-sm leading-relaxed`}),(0,J.jsx)(g,{value:p,placeholder:`tags, comma, separated`,spellCheck:!1,onChange:e=>m(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`h-8 text-xs`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,J.jsxs)(`label`,{className:`flex items-center gap-1.5 text-2xs text-fg-secondary`,children:[(0,J.jsx)(zt,{checked:u===`profile`,onCheckedChange:e=>d(e?`profile`:`project`)}),`Profile-wide`]}),(0,J.jsx)(`div`,{className:`ml-auto flex items-center gap-1`,children:r.map(e=>(0,J.jsxs)(`button`,{type:`button`,title:e.display_name,"aria-pressed":h===e.id,onClick:()=>_(t=>t===e.id?null:e.id),className:U(`rounded-md p-1 transition-colors`,h===e.id?`bg-surface text-fg`:`text-fg-gold hover:bg-surface hover:text-fg`),children:[(0,J.jsx)(Gt,{type:e.id,className:`size-3.5`}),(0,J.jsx)(`span`,{className:`sr-only`,children:e.display_name})]},e.id))})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,J.jsx)(R,{variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,J.jsx)(R,{size:`sm`,disabled:!c.trim(),onClick:v,children:`Save`})]})]})}function xi(){let e=Ht(),t=P(),n=yt().id,r=Ne(t??void 0,n).data??[],i=Ae().data??[],a=Re(),o=Ye(),s=Ue(),c=Jt(),[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(null),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(null),[_,v]=(0,q.useState)(null);(0,q.useEffect)(()=>qe(`scratchpad.toggle`,qt),[]),(0,q.useEffect)(()=>{e||(u(null),f(null),m(null))},[e]);let y=(0,q.useMemo)(()=>[...new Set(r.flatMap(e=>e.tags))].sort((e,t)=>e.localeCompare(t)),[r]),b=(0,q.useMemo)(()=>[...new Set(r.map(e=>e.agent_type).filter(e=>e!==null))],[r]),S=d!==null||p!==null,C=r.filter(e=>(d===null||e.tags.includes(d))&&(p===null||e.agent_type===p)),w=S?C:_??r,T=e=>{t&&(a.mutate({profile_id:t,scope:e.scope,project_id:e.scope===`project`?n:void 0,title:e.title??void 0,body:e.body,tags:e.tags,agent_type:e.agent_type??void 0}),u(null))},D=(e,t)=>{o.mutate({id:e,scope:t.scope,project_id:t.scope===`project`?n??null:null,title:t.title,body:t.body,tags:t.tags,agent_type:t.agent_type}),u(null)},k=(e,t)=>{let n=_??r,i=n.findIndex(t=>t.id===e),a=n.findIndex(e=>e.id===t);if(i===-1||a===-1||i===a)return;let o=n.slice(),[s]=o.splice(i,1);o.splice(a,0,s),v(o)},A=()=>{let e=h,t=_;if(g(null),v(null),e===null||!t)return;let n=t.findIndex(t=>t.id===e);if(n===-1)return;let r=t[n-1],i=t[n+1],a=r?i?(r.position+i.position)/2:r.position+1:(i?i.position:0)-1;o.mutate({id:e,position:a})},j=e=>{navigator.clipboard?.writeText(e.body),de.success(`Copied to clipboard`)};return(0,J.jsxs)(x,{open:e,onOpenChange:Ut,children:[(0,J.jsxs)(H,{children:[(0,J.jsx)(V,{asChild:!0,children:(0,J.jsx)(E,{asChild:!0,children:(0,J.jsxs)(R,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,J.jsx)(Ln,{}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Scratchpad`})]})})}),(0,J.jsx)(B,{children:`Scratchpad`})]}),(0,J.jsxs)(O,{className:`w-[34rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,J.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Scratchpad`}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>u(l===`new`?null:`new`),className:`ml-auto flex items-center rounded-md p-1 text-fg-gold transition-colors hover:bg-surface hover:text-fg`,children:[(0,J.jsx)(It,{className:`size-4`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`New entry`})]})]}),(y.length>0||b.length>0)&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:[y.map(e=>(0,J.jsx)(`button`,{type:`button`,onClick:()=>f(t=>t===e?null:e),className:U(`rounded-full px-2 py-0.5 text-2xs transition-colors`,d===e?`bg-action text-action-ink`:`bg-surface text-fg-secondary hover:text-fg`),children:e},e)),b.map(e=>(0,J.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>m(t=>t===e?null:e),className:U(`rounded-md p-1 transition-colors`,p===e?`bg-action text-action-ink`:`text-fg-gold hover:bg-surface`),children:(0,J.jsx)(Gt,{type:e,className:`size-3.5`})},e))]}),(0,J.jsxs)(`div`,{className:`no-scrollbar max-h-[65vh] overflow-y-auto px-2 pb-3`,children:[l===`new`&&(0,J.jsx)(`div`,{className:`px-3 py-2`,children:(0,J.jsx)(bi,{defaultScope:n?`project`:`profile`,allowProject:n!==void 0,agents:i,onSave:T,onCancel:()=>u(null)})}),w.length===0&&l!==`new`&&(0,J.jsx)(`p`,{className:`px-3 py-3 text-sm text-fg-muted`,children:S?`Nothing matches this filter.`:`No entries yet — press + to add a reusable prompt or note.`}),(0,J.jsx)(`ul`,{className:`flex flex-col`,children:w.map(e=>l===e.id?(0,J.jsx)(`li`,{className:`px-3 py-2`,children:(0,J.jsx)(bi,{initial:e,defaultScope:e.scope,allowProject:n!==void 0||e.scope===`project`,agents:i,onSave:t=>D(e.id,t),onCancel:()=>u(null)})},e.id):(0,J.jsx)(`li`,{draggable:!S&&l===null,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,g(e.id)},onDragOver:t=>{h!==null&&(t.preventDefault(),h!==e.id&&k(h,e.id))},onDragEnd:A,className:U(`transition-opacity`,h===e.id&&`opacity-50`),children:(0,J.jsx)(Si,{entry:e,onInsert:c?()=>{c(e.body),Ut(!1)}:null,onCopy:()=>j(e),onEdit:()=>u(e.id),onDelete:()=>s.mutate(e.id)})},e.id))})]})]})]})}function Si({entry:e,onInsert:t,onCopy:n,onEdit:r,onDelete:i}){let[a,o]=(0,q.useState)(!1);return(0,J.jsxs)(`div`,{onClick:e=>{e.target.closest(`button`)||r()},className:`cursor-pointer rounded-md px-3 py-2.5 transition-colors hover:bg-surface`,children:[e.title&&(0,J.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.title}),(0,J.jsx)(`p`,{className:U(`line-clamp-3 whitespace-pre-wrap text-sm text-fg-secondary`,e.title&&`mt-0.5`),children:e.body}),a?(0,J.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,J.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:`Delete this entry? This can’t be undone.`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),i()},className:`text-2xs font-medium text-interrupted transition-colors hover:underline`,children:`Delete`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Cancel`})]}):(0,J.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:e.scope===`profile`?`Profile-wide`:`Project`}),e.agent_type&&(0,J.jsx)(Gt,{type:e.agent_type,className:`size-3 text-fg-gold`}),e.tags.map(e=>(0,J.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-2xs text-fg-secondary`,children:e},e)),(0,J.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[t&&(0,J.jsx)(Ci,{icon:Pn,label:`Insert into focused terminal`,onClick:t}),(0,J.jsx)(Ci,{icon:gt,label:`Copy`,onClick:n}),(0,J.jsx)(Ci,{icon:m,label:`Edit`,onClick:r}),(0,J.jsx)(Ci,{icon:Rt,label:`Delete`,onClick:()=>o(!0)})]})]})]})}function Ci({icon:e,label:t,onClick:n}){return(0,J.jsxs)(H,{children:[(0,J.jsx)(V,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,J.jsx)(e,{className:`size-3.5`}),(0,J.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,J.jsx)(B,{children:t})]})}var wi=a.parse({});function Ti(e,t){let[n,r]=(0,q.useState)(null),i=ye(t).data,a=Ze(e??void 0,t&&e!==null).data;return(0,q.useEffect)(()=>{if(!t||e===null){r(null);return}let n=!1,i;try{i=cn(sessionStorage.getItem(sn(e)))}catch{i={kind:`absent`}}if(i.kind===`present`){r(i.snapshot);return}return ke(e).then(e=>{n||r(e?e.ui_state:wi)}).catch(()=>{n||r(wi)}),()=>{n=!0}},[t,e]),(0,q.useMemo)(()=>{if(!t||e===null||n===null)return null;let o=t=>{if(!i||!a)return!1;let{patch:o,projectBased:s}=tn(n,t,{alive:new Set(i.filter(e=>e.status!==`archived`).map(e=>e.id)),sessionProject:new Map(i.map(e=>[e.id,e.project_id])),projectIds:a.map(e=>e.id),currentProject:null}),c={...n,...o};r(c),me(e,c).catch(e=>console.warn(`ui-state save failed: ${e.message}`));try{sessionStorage.setItem(sn(e),JSON.stringify(c))}catch(e){console.warn(`ui-state write failed: ${e.message}`)}return re().projectBasedLayout!==s&&ne({projectBasedLayout:s}),!0},s=Object.fromEntries(Object.entries(n.project_layouts).map(([e,t])=>[e,{layoutRef:t.layout_ref,signature:z(t.layout_tree)}]));return(n.layout_mode??`profile`)===`project`?{headless:!0,scope:`project`,projectId:``,layoutRef:null,signature:z(null),slices:s,capture:()=>({layout_tree:null,active_session:null}),apply:o}:{scope:`profile`,projectId:``,layoutRef:n.layout_ref,signature:z(n.layout_tree),slices:s,capture:()=>({layout_tree:n.layout_tree,active_session:n.active_session}),apply:o}},[t,e,n,i,a])}var Ei=z(null);function Di(){let e=nn(),t=Et(),n=P(),r=an(),i=Ti(n,e&&r===null),a=r??i,o=rt(n??void 0,void 0).data??[],s=Ze(n??void 0,e&&n!==null).data??[],c=he(),l=lt(),u=Ve(),[d,f]=(0,q.useState)(``),[p,m]=(0,q.useState)(!1),[h,_]=(0,q.useState)(null);(0,q.useEffect)(()=>qe(`layouts.toggle`,en),[]),(0,q.useEffect)(()=>{e||(f(``),m(!1),_(null))},[e]);let v=a?.headless===!0,y=a===null||v?null:o.find(e=>e.id===a.layoutRef)??null,b=a!==null&&!v&&(y===null?a.signature!==Ei:z(y.layout_tree)!==a.signature),S=e=>{let t=a?.slices?.[e];if(!t)return!1;let n=t.layoutRef===null?null:o.find(e=>e.id===t.layoutRef)??null;return n?z(n.layout_tree)!==t.signature:t.signature!==Ei},C=e=>a===null?!1:e.scope===`profile`?a.scope===`profile`&&b:e.project_id===null?!1:a.scope===`project`?!v&&e.project_id===a.projectId?b:S(e.project_id):b||S(e.project_id),w=e=>y!==null&&e.id===y.id,T=e=>(e===null?void 0:s.find(t=>t.id===e)?.name)??`Project`,D=a!==null&&!v&&a.scope===`project`?o.filter(e=>e.scope===`profile`||e.project_id===a.projectId):o,k=[...D.some(e=>e.scope===`profile`)?[{key:`profile`,name:`Profile-wide`}]:[],...[...new Set(D.flatMap(e=>e.project_id===null?[]:[e.project_id]))].map(e=>({key:e,name:T(e)})).sort((e,t)=>e.name.localeCompare(t.name))],A=h===null?D:h===`profile`?D.filter(e=>e.scope===`profile`):D.filter(e=>e.project_id===h),j=e=>a!==null&&e.scope===a.scope&&(a.scope===`profile`||e.project_id===a.projectId),M=(e,t,r)=>{!a||!n||c.mutate({profile_id:n,scope:a.scope,project_id:a.scope===`project`?a.projectId:void 0,name:e,...t},{onSuccess:e=>{r&&a.apply(e)},onError:e=>G(e)})},ee=e=>{if(!a)return;let t=j(e)?e:o.find(t=>t.name===e.name&&j(t));if(!t){M(e.name,a.capture(),!0);return}l.mutate({id:t.id,...a.capture()},{onSuccess:e=>a.apply(e),onError:e=>G(e)})},te=(e,t)=>M(t,{layout_tree:e.layout_tree,active_session:e.active_session},!1),ne=e=>{if(a){if(!a.apply(e)){de.error(`Workspace is still loading — try again in a moment`);return}e.project_id!==null&&e.project_id!==a.projectId&&t(`/project/${e.project_id}`),Qt(!1)}};return(0,J.jsxs)(x,{open:e,onOpenChange:Qt,children:[(0,J.jsxs)(H,{children:[(0,J.jsx)(V,{asChild:!0,children:(0,J.jsx)(E,{asChild:!0,children:(0,J.jsxs)(R,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,J.jsx)(Fn,{}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Layouts`})]})})}),(0,J.jsx)(B,{children:`Layouts`})]}),(0,J.jsxs)(O,{className:`w-[26rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,J.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Layouts`}),a!==null&&!v&&(0,J.jsxs)(`button`,{type:`button`,onClick:()=>m(e=>!e),className:`ml-auto flex items-center rounded-md p-1 text-fg-gold transition-colors hover:bg-surface hover:text-fg`,children:[(0,J.jsx)(It,{className:`size-4`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Save the current layout as a new layout`})]})]}),a===null?(0,J.jsx)(`p`,{className:`px-5 pb-3 text-sm text-fg-muted`,children:`Loading the profile’s layout state…`}):v?(0,J.jsx)(`p`,{className:`px-5 pb-3 text-sm text-fg-muted`,children:`Project-based layout is on — every project keeps its own layout. Open a project to name or save it; loading works from here.`}):(y===null||p)&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 px-5 pb-3`,children:[y===null&&(0,J.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:`Unnamed layout`}),(0,J.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:a.scope===`profile`?`Profile-wide`:`Project`}),(0,J.jsx)(`span`,{className:`ml-auto text-2xs text-interrupted`,children:`Unsaved`})]}),(0,J.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:e=>{e.preventDefault();let t=d.trim();t&&(M(t,a.capture(),!0),f(``),m(!1))},children:[(0,J.jsx)(g,{autoFocus:p,value:d,placeholder:y===null?`Name this layout…`:`Save as a new layout…`,spellCheck:!1,onChange:e=>f(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&m(!1)},className:`h-8 flex-1 text-sm`}),(0,J.jsx)(R,{size:`sm`,type:`submit`,disabled:!d.trim(),children:`Save`}),y!==null&&(0,J.jsx)(R,{variant:`ghost`,size:`sm`,onClick:()=>m(!1),children:`Cancel`})]})]}),k.length>1&&(0,J.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:k.map(e=>(0,J.jsx)(Ai,{active:h===e.key,onClick:()=>_(t=>t===e.key?null:e.key),children:e.name},e.key))}),(0,J.jsxs)(`div`,{className:`no-scrollbar max-h-[60vh] overflow-y-auto px-2 pb-3`,children:[A.length===0&&(0,J.jsx)(`p`,{className:`px-3 py-3 text-sm text-fg-muted`,children:h===null?`No layouts yet — name and save the current layout to keep it.`:`Nothing matches this filter.`}),(0,J.jsx)(`ul`,{className:`flex flex-col`,children:A.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(Oi,{layout:e,projectLabel:e.scope===`profile`?null:T(e.project_id),isCurrent:w(e),dirty:b,loadable:a!==null,savable:a!==null&&!v,confirmBeforeLoad:C(e),overwrites:j(e),onLoad:()=>ne(e),onRename:t=>l.mutate({id:e.id,name:t}),onDelete:()=>u.mutate(e.id),onSaveAs:()=>ee(e),onDuplicate:t=>te(e,t)})},e.id))})]})]})]})}function Oi({layout:e,projectLabel:t,isCurrent:n,dirty:r,loadable:i,savable:a,confirmBeforeLoad:o,overwrites:s,onLoad:c,onRename:l,onDelete:u,onSaveAs:d,onDuplicate:f}){let[p,h]=(0,q.useState)(null),[_,v]=(0,q.useState)(null),[y,b]=(0,q.useState)(e.name),x=()=>{if(!(!i||_!==null)){if(o&&p!==`load`){h(`load`);return}h(null),c()}},S=t=>{h(null),b(t===`rename`?e.name:`${e.name} copy`),v(t)},C=()=>{if(n){d();return}h(`save`)},w=n?r?`unsaved`:`active`:null;return(0,J.jsxs)(`div`,{onClick:e=>{e.target.closest(`button, input`)||x()},className:U(`rounded-md px-3 py-2.5 transition-colors`,i&&`cursor-pointer hover:bg-surface`),children:[_===null?(0,J.jsxs)(`p`,{className:U(`flex items-baseline gap-2 text-sm font-medium`,w===`active`?`text-success`:w===`unsaved`?`text-interrupted`:`text-fg`),children:[e.name,w!==null&&(0,J.jsx)(`span`,{className:`text-2xs font-normal`,children:w===`active`?`Active`:`Unsaved`})]}):(0,J.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:t=>{t.preventDefault();let n=y.trim();n&&(_===`rename`?n!==e.name&&l(n):f(n)),v(null)},children:[(0,J.jsx)(g,{autoFocus:!0,value:y,spellCheck:!1,onChange:e=>b(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&v(null)},className:`h-7 flex-1 text-sm`}),(0,J.jsx)(R,{size:`sm`,type:`submit`,disabled:!y.trim(),children:_===`rename`?`Rename`:`Save`})]}),p===`save`?(0,J.jsx)(ki,{question:s?`Overwrite “${e.name}” with the current layout?`:`Save the current layout as “${e.name}” here?`,verb:s?`Overwrite`:`Save`,onConfirm:()=>{h(null),d()},onCancel:()=>h(null)}):p===`delete`?(0,J.jsx)(ki,{question:`Delete this layout? This can’t be undone.`,verb:`Delete`,onConfirm:()=>{h(null),u()},onCancel:()=>h(null)}):p===`load`?(0,J.jsx)(ki,{question:`Loading discards unsaved layout changes.`,verb:`Load`,onConfirm:x,onCancel:()=>h(null)}):(0,J.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[t!==null&&(0,J.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:t}),(0,J.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[a&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ji,{icon:Rn,label:n?`Save`:`Save the current layout as “${e.name}”`,onClick:C}),(0,J.jsx)(ji,{icon:gt,label:`Duplicate`,onClick:()=>S(`duplicate`)})]}),(0,J.jsx)(ji,{icon:m,label:`Rename`,onClick:()=>S(`rename`)}),(0,J.jsx)(ji,{icon:Rt,label:`Delete`,onClick:()=>h(`delete`)})]})]})]})}function ki({question:e,verb:t,onConfirm:n,onCancel:r}){return(0,J.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,J.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e}),(0,J.jsx)(`button`,{type:`button`,onClick:n,className:`text-2xs font-medium text-interrupted transition-colors hover:underline`,children:t}),(0,J.jsx)(`button`,{type:`button`,onClick:r,className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Cancel`})]})}function Ai({active:e,onClick:t,children:n}){return(0,J.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:t,className:U(`rounded-full px-2 py-0.5 text-2xs transition-colors`,e?`bg-action text-action-ink`:`bg-surface text-fg-secondary hover:text-fg`),children:n})}function ji({icon:e,label:t,onClick:n}){return(0,J.jsxs)(H,{children:[(0,J.jsx)(V,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,J.jsx)(e,{className:`size-3.5`}),(0,J.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,J.jsx)(B,{children:t})]})}var Mi=Me()!==void 0&&/Mac/.test(navigator.platform),Ni=(0,q.lazy)(()=>ie(()=>import(`./SettingsDialog-CGT3gjKB.js`).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])));function Pi(){let e=Oe();(0,q.useEffect)(()=>{let t=t=>{for(let[n,r]of e.getQueriesData({queryKey:[`sessions`]}))r&&e.setQueryData(n,r.map(t));for(let[n,r]of e.getQueriesData({queryKey:[`project`]}))r&&e.setQueryData(n,{...r,sessions:r.sessions.map(t)})},n=K.onStatus(e=>t(t=>t.id===e.session?{...t,status:e.status,last_activity_at:e.last_activity_at}:t)),r=K.onRenamed(e=>t(t=>t.id===e.session?{...t,title:e.title,agent_title:`agent_title`in e?e.agent_title:t.agent_title,osc_title:`osc_title`in e?e.osc_title:t.osc_title}:t)),i=K.onAccount(t=>{for(let[n,r]of e.getQueriesData({queryKey:[`accounts`]}))r&&e.setQueryData(n,r.map(e=>e.id===t.account_id?{...e,logged_in:t.logged_in}:e))}),a=t=>{e.invalidateQueries({queryKey:[`sessions`]});for(let n of t)e.invalidateQueries({queryKey:[`project`,n]})},o=K.onSessionsChanged(e=>a(e.project_ids)),s=K.onSessionSwitched(e=>a([e.target_project]));return()=>{n(),r(),i(),o(),s()}},[e])}function Fi(){let e=ut(),t=it(),[n,r]=(0,q.useState)(!1),i=$e(e.data),a=n=>{r(!1);let a=n.trim();a!==i&&t.mutate({displayName:a===e.data?.hostname?``:a},{onError:e=>G(e)})},o=!Mi&&(0,J.jsx)(`img`,{src:`/puddle.svg`,alt:`Puddle`,className:`size-4`}),s=U(`flex shrink-0 items-center gap-2`,Mi&&`[-webkit-app-region:no-drag]`),c=`truncate text-sm font-semibold text-fg-secondary`;return n&&i!==void 0?(0,J.jsxs)(`div`,{className:s,children:[o,(0,J.jsx)($t,{initial:e.data?.displayName??i,maxLength:64,className:U(c,`w-40`),onCommit:a,onCancel:()=>r(!1)})]}):(0,J.jsxs)(_t,{to:`/`,className:U(s,`transition-opacity hover:opacity-70`),title:`All projects`,children:[o,i!==void 0&&(0,J.jsx)(`span`,{className:c,...ln(()=>r(!0)),children:i})]})}function Ii(){let e=yt(),t=ge(`palette.toggle`),n=Qe(e.id).data?.project,r=n!==void 0&&n.id===e.id?n.name:void 0;return(0,J.jsxs)(`button`,{type:`button`,onClick:Kt,className:U(`absolute left-1/2 flex h-6 w-[min(30rem,42%)] -translate-x-1/2 items-center justify-center gap-2 rounded-md bg-ground text-fg-muted transition-colors hover:bg-elevated hover:text-fg-secondary`,Mi&&`[-webkit-app-region:no-drag]`),children:[(0,J.jsx)(`span`,{className:`truncate text-xs`,children:r??`Puddle`}),(0,J.jsx)(`span`,{className:`text-2xs`,children:t})]})}function Li(){let{fullScreen:e,animate:t}=pe();return(0,J.jsxs)(`header`,{className:U(`relative flex h-9 shrink-0 items-center gap-3 bg-surface pl-3 pr-3`,Mi&&!e&&`pl-[88px] [-webkit-app-region:drag]`,t&&`transition-[padding] duration-200 ease-out`),children:[(0,J.jsx)(Fi,{}),(0,J.jsx)(Ii,{}),(0,J.jsxs)(`div`,{className:U(`ml-auto flex items-center`,Mi&&`[-webkit-app-region:no-drag]`),children:[(0,J.jsxs)(H,{children:[(0,J.jsx)(V,{asChild:!0,children:(0,J.jsxs)(R,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,onClick:()=>Pt(),children:[(0,J.jsx)(Bn,{}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Settings`})]})}),(0,J.jsx)(B,{children:`Settings`})]}),(0,J.jsx)(Di,{}),(0,J.jsx)(xi,{}),(0,J.jsx)(ri,{})]})]})}function Ri(){Pi(),oi(),vi();let{handler:e}=Wt(),t=P(),{pathname:n}=xt(),[r,i]=(0,q.useState)(!1),a=we(),o=a.data!==void 0&&Ke(a.data.protocol);return(0,q.useEffect)(()=>{if(!o)return;let e=()=>{let e=oe();K.reportTheme(e(`--text-primary`),e(`--bg-base`))};return e(),ae(e)},[o]),(0,J.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden overscroll-y-none bg-ground`,children:[(0,J.jsx)(Li,{}),(0,J.jsx)(`main`,{className:`min-h-0 flex-1`,children:(0,J.jsx)(gn,{resetOn:n,scope:n.startsWith(`/project/`)?`workspace`:`view`,children:(0,J.jsx)(Ct,{})})}),(0,J.jsx)(Qr,{}),(0,J.jsx)(ai,{}),(0,J.jsx)(qr,{onNewSession:e??void 0,onNewProject:()=>i(!0)}),t!==null&&(0,J.jsx)(un,{profileId:t,open:r,onOpenChange:i}),(0,J.jsx)(q.Suspense,{fallback:null,children:(0,J.jsx)(Ni,{})}),(0,J.jsx)(Xr,{})]})}function zi(){return(0,J.jsx)(on,{children:(0,J.jsx)(Ri,{})})}var Bi=(0,q.lazy)(()=>ie(()=>import(`./Dashboard-3XQN7EWB.js`).then(e=>({default:e.Dashboard})),__vite__mapDeps([24,1,2,3,4,5,6,7,8,9,10,13,12,25,26,20,27,23,22,28]))),Vi=(0,q.lazy)(()=>ie(()=>import(`./Workspace-ZdFFHXHa.js`).then(e=>({default:e.Workspace})),__vite__mapDeps([29,1,2,3,4,5,6,7,8,9,10,15,16,17,12,13,30,31,25,14,32,33,34,26,20,35,18,19,36,28,22,37,38,39,40,41]))),Hi=new hn({defaultOptions:{queries:{retry:1,staleTime:5e3}},mutationCache:new fn({onError:e=>G(e)})});function Ui(){let e=P(),t=nt(),n=e!==null&&t.data!==void 0&&!t.data.some(t=>t.id===e);return e===null||n?(0,J.jsx)(Vn,{}):(0,J.jsx)(bt,{useTransitions:!1,children:(0,J.jsx)(q.Suspense,{fallback:null,children:(0,J.jsx)(vt,{children:(0,J.jsxs)(wt,{element:(0,J.jsx)(zi,{}),children:[(0,J.jsx)(wt,{path:`/`,element:(0,J.jsx)(Bi,{})}),(0,J.jsx)(wt,{path:`/project/:id`,element:(0,J.jsx)(Vi,{})}),(0,J.jsx)(wt,{path:`/project/:id/session/:sid`,element:(0,J.jsx)(Vi,{})})]})})})})}function Wi(){let e=(0,q.useSyncExternalStore)(u.subscribe,u.get);return(0,J.jsx)(Ee,{client:Hi,children:(0,J.jsxs)(Zt,{delayDuration:300,children:[(0,J.jsx)(Nn,{}),(0,J.jsx)(gn,{scope:`app`,children:e?window.location.pathname.startsWith(`/forward/`)?(0,J.jsx)(dn,{}):(0,J.jsx)(Ui,{}):(0,J.jsx)(vn,{})}),(0,J.jsx)(_n,{})]})})}export{Wi as App};